-
Notifications
You must be signed in to change notification settings - Fork 47
Introduction of field API interface in ectrans #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 81 commits
5471960
9b1c055
07e1b4f
653cecc
33cf796
de15138
b61e65a
b3f485d
e24f2a9
93377c3
f37bb3e
276bf7e
c79dd56
9e86a4a
5a95205
21db9d2
a13d6c8
f6a97e6
17731e8
327c5e1
b11f38e
881d086
c17ab29
35a6865
a1795a4
6c4c9e3
ec38922
67cf8ce
06d62a8
4850f25
1f3b3ac
8f9a3b3
8b4bca9
0ff0555
173b345
5157617
f690b01
2a7aa87
8bee757
5f3bbc1
cceb0df
139b63e
4e273f5
1f222f6
6fd0c5e
8fdabd1
4a13d05
be6d356
c3a2d47
13289bc
33ba60f
12ae322
1e15620
68717ed
60de653
7baa6aa
9546644
c71ce22
ddde970
7a758a8
2bd0671
d3c5042
b682f3c
dac476f
dafa4db
620326d
e636642
3c506ab
d05dc84
41b01bd
b233e3d
3fc859c
008ef1d
41fd1f4
0bd76d1
e673165
30dc1aa
453eb0c
3c1e77a
252d7a0
174b0b1
501fa6a
c90fa73
f060de5
28feac0
d810d5f
88af96b
ae111c6
ce5ae51
9bf2044
d4768aa
ecbf2d2
059309a
7cc7912
c7af7ea
fd0ef29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,121 @@ | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # This software is licensed under the terms of the Apache Licence Version 2.0 | ||||||||||||||||||||||||
| # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||||||||||||||||||||||||
| # In applying this licence, ECMWF does not waive the privileges and immunities | ||||||||||||||||||||||||
| # granted to it by virtue of its status as an intergovernmental organisation | ||||||||||||||||||||||||
| # nor does it submit to any jurisdiction. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function(generate_file) | ||||||||||||||||||||||||
| set (options) | ||||||||||||||||||||||||
| set (oneValueArgs INPUT OUTPUT BACKEND) | ||||||||||||||||||||||||
| set (multiValueArgs) | ||||||||||||||||||||||||
| cmake_parse_arguments(_PAR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| set(output ${_PAR_OUTPUT}) | ||||||||||||||||||||||||
| set(input ${_PAR_INPUT}) | ||||||||||||||||||||||||
| set(backend ${_PAR_BACKEND}) | ||||||||||||||||||||||||
| set(sed_rules ${PROJECT_SOURCE_DIR}/src/field_api/sedrenames.txt) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| set( JPRB_dp JPRD ) | ||||||||||||||||||||||||
| set( jprb_dp jprd ) | ||||||||||||||||||||||||
| set( JPRB_sp JPRM ) | ||||||||||||||||||||||||
| set( jprb_sp jprm ) | ||||||||||||||||||||||||
| set( JPRB_gpu_dp JPRD ) | ||||||||||||||||||||||||
| set( jprb_gpu_dp jprd ) | ||||||||||||||||||||||||
| set( JPRB_gpu_sp JPRM ) | ||||||||||||||||||||||||
| set( jprb_gpu_sp jprm ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| add_custom_command( | ||||||||||||||||||||||||
| OUTPUT ${output} | ||||||||||||||||||||||||
| COMMAND cat ${sed_rules} | | ||||||||||||||||||||||||
| sed -e "s/VARIANTDESIGNATOR/${backend}/g" | | ||||||||||||||||||||||||
| sed -e "s/TYPEDESIGNATOR_UPPER/${JPRB_${backend}}/g" | | ||||||||||||||||||||||||
| sed -e "s/TYPEDESIGNATOR_LOWER/${jprb_${backend}}/g" | | ||||||||||||||||||||||||
| sed -rf - ${input} > ${output} | ||||||||||||||||||||||||
| DEPENDS ${input} ${sed_rules} | ||||||||||||||||||||||||
| COMMENT "Generating ${output}" | ||||||||||||||||||||||||
| VERBATIM | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| endfunction(generate_file) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function(generate_backend_sources) | ||||||||||||||||||||||||
| set (options) | ||||||||||||||||||||||||
| set (oneValueArgs BACKEND DESTINATION OUTPUT) | ||||||||||||||||||||||||
| set (multiValueArgs) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| cmake_parse_arguments(_PAR "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||||||||||||||||||||||||
| set(backend ${_PAR_BACKEND}) | ||||||||||||||||||||||||
| set(destination ${_PAR_DESTINATION}) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| set(files) | ||||||||||||||||||||||||
| list( APPEND files | ||||||||||||||||||||||||
| field_api_ectrans_mod.F90 | ||||||||||||||||||||||||
| trans/dir_trans_field_api.F90 | ||||||||||||||||||||||||
| trans/inv_trans_field_api.F90 | ||||||||||||||||||||||||
| field_api_basic_type_mod.F90 | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| set(outfiles) | ||||||||||||||||||||||||
| foreach(file_i ${files}) | ||||||||||||||||||||||||
| get_filename_component(outfile_name ${file_i} NAME) | ||||||||||||||||||||||||
| get_filename_component(outfile_name_we ${file_i} NAME_WE) | ||||||||||||||||||||||||
| get_filename_component(outfile_ext ${file_i} EXT) | ||||||||||||||||||||||||
| get_filename_component(outfile_dir ${file_i} DIRECTORY) | ||||||||||||||||||||||||
| set(outfile "${destination}/${file_i}") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| generate_file(BACKEND ${backend} INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${file_i} OUTPUT ${outfile}) | ||||||||||||||||||||||||
| list(APPEND outfiles ${outfile}) | ||||||||||||||||||||||||
| endforeach(file_i) | ||||||||||||||||||||||||
| set(${_PAR_OUTPUT} ${outfiles} PARENT_SCOPE) | ||||||||||||||||||||||||
| endfunction(generate_backend_sources) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| set( BUILD_INTERFACE_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/ectrans ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| set (platforms) | ||||||||||||||||||||||||
| if (HAVE_CPU) | ||||||||||||||||||||||||
| list(APPEND platforms cpu) | ||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||
| if (HAVE_GPU) | ||||||||||||||||||||||||
| list(APPEND platforms gpu) | ||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||
| foreach(platform ${platforms}) | ||||||||||||||||||||||||
| foreach( prec dp sp) | ||||||||||||||||||||||||
| if( HAVE_${prec}) | ||||||||||||||||||||||||
| if (${platform} MATCHES "gpu") | ||||||||||||||||||||||||
| set (platform_tag "gpu_") | ||||||||||||||||||||||||
| else() | ||||||||||||||||||||||||
| set (platform_tag "") | ||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| generate_backend_sources(BACKEND ${platform_tag}${prec} | ||||||||||||||||||||||||
| OUTPUT ectrans_field_api_${platform_tag}${prec}_src | ||||||||||||||||||||||||
| DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/generated/ectrans_field_api_${platform_tag}${prec}) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ecbuild_add_library( | ||||||||||||||||||||||||
| TARGET ectrans_field_api_${platform_tag}${prec} | ||||||||||||||||||||||||
| LINKER_LANGUAGE Fortran | ||||||||||||||||||||||||
| SOURCES ${ectrans_field_api_${platform_tag}${prec}_src} | ||||||||||||||||||||||||
| PUBLIC_LIBS ectrans_${platform_tag}${prec} field_api_${prec} fiat parkind_${prec} | ||||||||||||||||||||||||
| PUBLIC_INCLUDES $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/trans/include/ectrans> | ||||||||||||||||||||||||
| $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/field_api/include> | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ectrans_target_fortran_module_directory( | ||||||||||||||||||||||||
| TARGET ectrans_field_api_${platform_tag}${prec} | ||||||||||||||||||||||||
| MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/module/ectrans | ||||||||||||||||||||||||
| INSTALL_DIRECTORY module/ectrans | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (${platform} MATCHES "gpu") | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| if( CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC" ) | ||||||||||||||||||||||||
| set_source_files_properties( ${ectrans_field_api_${platform_tag}${prec}_src} PROPERTIES COMPILE_OPTIONS "-acc" ) | ||||||||||||||||||||||||
| # set_source_files_properties( ${ectrans_field_api_${platform_tag}${prec}_src} PROPERTIES COMPILE_OPTIONS "-O1" ) | ||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| if (${platform} MATCHES "gpu") | |
| if( CMAKE_Fortran_COMPILER_ID MATCHES "NVHPC" ) | |
| set_source_files_properties( ${ectrans_field_api_${platform_tag}${prec}_src} PROPERTIES COMPILE_OPTIONS "-acc" ) | |
| # set_source_files_properties( ${ectrans_field_api_${platform_tag}${prec}_src} PROPERTIES COMPILE_OPTIONS "-O1" ) | |
| endif() | |
| endif() | |
| if (${platform} MATCHES "gpu") | |
| if (HAVE_ACC) | |
| target_link_libraries( ectrans_field_api_${platform_tag}${prec} PRIVATE OpenACC::OpenACC_Fortran ) | |
| endif() | |
| endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wdeconinck
Not sure what to do here. I just removed the instructions from L109 to 114, which had nothing to do with linkin,. they were adding the compilation options -acc -o1 to the field_api interface file.
I did not add the target_link_libraries, and it seems that everything compiles fine without.
Is it mandatory ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPDATE: I had to put them back, otherwise the files in the field_api folder were not compiled with "-acc"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally target_link_libraries( ectrans_field_api_${platform_tag}${prec} PRIVATE OpenACC::OpenACC_Fortran ) should do a number of things given OpenACC::OpenACC_Fortran is a cmake target:
- compile the files with the -acc flag and others possibly when defined in the toolchain as "OpenACC_Fortran_FLAGS"
- add link flags or link libraries
- add include directories defined by the target
Because it is marked as PRIVATE it does not propagate the compile flags to downstream, which is good. But then when downstream also needs those flags then that code is responsible to link with OpenACC itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wdeconinck Thanks for the explanation. It is fixed now
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| ! (C) Copyright 2001- ECMWF. | ||
| ! (C) Copyright 2001- Meteo-France. | ||
| ! | ||
| ! This software is licensed under the terms of the Apache Licence Version 2.0 | ||
| ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
| ! In applying this licence, ECMWF does not waive the privileges and immunities | ||
| ! granted to it by virtue of its status as an intergovernmental organisation | ||
| ! nor does it submit to any jurisdiction. | ||
|
|
||
| MODULE FIELD_API_BASIC_TYPE_MOD | ||
|
|
||
| USE FIELD_BASIC_MODULE, ONLY: FIELD_BASIC | ||
|
|
||
| IMPLICIT NONE | ||
|
|
||
| TYPE FIELD_BASIC_PTR | ||
| ! A pointer to field API field with additional METADA | ||
| CLASS (FIELD_BASIC), POINTER :: PTR ! POINTER TO FIELD_BASIC from field API | ||
| INTEGER, ALLOCATABLE :: IVSET(:) ! b-set for spectral fields | ||
| CHARACTER(LEN=10) :: NAME ! Name | ||
| END TYPE | ||
|
|
||
| END MODULE FIELD_API_BASIC_TYPE_MOD | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed
