-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implement offload instructions via macros #80
Open
awnawab
wants to merge
10
commits into
ecmwf-ifs:main
Choose a base branch
from
awnawab:naan-offload-macros
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,209
−193
Open
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f379dfe
Remove unecessary CUDAFOR imports
awnawab e64e194
Remove CUDAFOR from HOST_ALLOC_MODULE
awnawab 96240dc
FYPP: fypp now only supported if installed as a pip package
awnawab b1b714f
WIP: implement macro based offload instructions for Nvidia OpenACC in…
awnawab f49858f
WIP: python macros adapted for host only functionality
awnawab 249974e
FIELD_ASYNC: convert to fypp file
awnawab 3062bd8
Implement NVHPCOpenaCC entirely using python macros
awnawab 04188f5
Adapt CUDA backend to use python macros
awnawab aac718d
Generalise offload related preproc definitions
awnawab f5dc280
Use nvhpc naming convention for offload macros
awnawab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
field_module.F90 | ||
*.swp | ||
build | ||
**__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# (C) Copyright 2022- ECMWF. | ||
# (C) Copyright 2022- 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. | ||
|
||
############################################################################## | ||
#.rst: | ||
# | ||
# field_api_get_offload_model | ||
# =========================== | ||
# | ||
# Determine the GPU offload model to be used. :: | ||
# | ||
# field_api_get_offload_model() | ||
# | ||
############################################################################## | ||
|
||
macro( field_api_get_offload_model ) | ||
|
||
## find OpenACC | ||
if( ${CMAKE_VERSION} VERSION_LESS "3.25" ) | ||
if ( FIELD_API_ENABLE_ACC OR (NOT DEFINED FIELD_API_ENABLE_ACC AND (ENABLE_ACC OR NOT DEFINED ENABLE_ACC)) ) | ||
# See https://gitlab.kitware.com/cmake/cmake/-/issues/23691, fixed in CMake 3.25 | ||
# (TL;DR: FindOpenACC sets OpenACC_<LANG>_FOUND correctly but does not set | ||
# OpenACC_FOUND unless all three C, CXX, and Fortran have been found - even if | ||
# only one language has been requested via COMPONENTS) | ||
find_package( OpenACC COMPONENTS Fortran ) | ||
if( OpenACC_Fortran_FOUND ) | ||
set( OpenACC_FOUND ON ) | ||
endif() | ||
endif() | ||
endif() | ||
ecbuild_add_option( FEATURE ACC | ||
DEFAULT ON | ||
DESCRIPTION "Support for using GPUs with OpenACC" | ||
REQUIRED_PACKAGES "OpenACC COMPONENTS Fortran" | ||
CONDITION CMAKE_Fortran_COMPILER_ID MATCHES "PGI|NVHPC") | ||
|
||
## check for CUDA | ||
include(CheckLanguage) | ||
check_language(CUDA) | ||
ecbuild_add_option( FEATURE CUDA | ||
DESCRIPTION "CUDA" DEFAULT ON | ||
CONDITION CMAKE_CUDA_COMPILER AND HAVE_ACC ) | ||
|
||
set(FIELD_API_OFFLOAD_MODEL "HostOnly") | ||
if( HAVE_CUDA ) | ||
set(FIELD_API_OFFLOAD_MODEL "NVHPCOpenACCCUDA") | ||
elseif( HAVE_ACC ) | ||
set(FIELD_API_OFFLOAD_MODEL "NVHPCOpenACC") | ||
endif() | ||
|
||
unset(FIELD_API_OFFLOAD_DEFINITIONS) | ||
if( HAVE_ACC ) | ||
list(APPEND FIELD_API_OFFLOAD_DEFINITIONS WITH_GPU_OFFLOAD) | ||
endif() | ||
|
||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# (C) Copyright 2022- ECMWF. | ||
# (C) Copyright 2022- 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. | ||
|
||
from offload_backends.nvhpc import * | ||
from offload_backends.host_only import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# (C) Copyright 2022- ECMWF. | ||
# (C) Copyright 2022- 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. | ||
|
||
from offload_backends.nvhpc.openacc import * | ||
from offload_backends.nvhpc.openacc_cuda import * |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Small comment from something we've hit very recently: Bare-metal Python installations may come without any pip or only ancient versions available. But they are guaranteed to have a bootstrap mechanism for it that ensures that you have at least a pip version equivalent to the ensurepip version packaged with the installation. For this, add the following:
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.
I didn't even know we could have pip-less python, thanks!