-
Notifications
You must be signed in to change notification settings - Fork 213
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
Gpu improvements #4334
Closed
Closed
Gpu improvements #4334
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d2197e0
add GPU_TYPE and GPU_OFFLOAD variables
jedwards4b 9151667
do not use none in gpu_type
jedwards4b 2cb56df
add gpu_type and gpu_offload options to create_newcase
jedwards4b b03129b
fix unit test
jedwards4b c1d60ba
one more unit test fix
jedwards4b 3f4b1ab
improve gpu functionality
jedwards4b 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
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 |
---|---|---|
|
@@ -1261,6 +1261,8 @@ def configure( | |
extra_machines_dir=None, | ||
case_group=None, | ||
ngpus_per_node=0, | ||
gpu_type=None, | ||
gpu_offload=None, | ||
): | ||
|
||
expect( | ||
|
@@ -1509,47 +1511,35 @@ def configure( | |
|
||
# ---------------------------------------------------------------------------------------------------------- | ||
# Sanity check: | ||
# 1. We assume that there is always a string "gpu" in the compiler name if we want to enable GPU | ||
# 2. For compilers without the string "gpu" in the name: | ||
# 2.1. the ngpus-per-node argument would not update the NGPUS_PER_NODE XML variable, as long as | ||
# the MAX_GPUS_PER_NODE XML variable is not defined (i.e., this argument is not in effect). | ||
# 2.2. if the MAX_GPUS_PER_NODE XML variable is defined, then the ngpus-per-node argument | ||
# must be set to 0. Otherwise, an error will be triggered. | ||
# 3. For compilers with the string "gpu" in the name: | ||
# 3.1. if ngpus-per-node argument is smaller than 0, an error will be triggered. | ||
# 3.2. if ngpus_per_node argument is larger than the value of MAX_GPUS_PER_NODE, the NGPUS_PER_NODE | ||
# 1. GPU_TYPE and GPU_OFFLOAD must both be defined to use GPUS | ||
# 2. if ngpus_per_node argument is larger than the value of MAX_GPUS_PER_NODE, the NGPUS_PER_NODE | ||
# XML variable in the env_mach_pes.xml file would be set to MAX_GPUS_PER_NODE automatically. | ||
# 3.3. if ngpus-per-node argument is equal to 0, it will be updated to 1 automatically. | ||
# 3. if ngpus-per-node argument is equal to 0, it will be updated to 1 automatically. | ||
# ---------------------------------------------------------------------------------------------------------- | ||
max_gpus_per_node = self.get_value("MAX_GPUS_PER_NODE") | ||
if max_gpus_per_node: | ||
if "gpu" in compiler: | ||
if not ngpus_per_node: | ||
ngpus_per_node = 1 | ||
logger.warning( | ||
"Setting ngpus_per_node to 1 for compiler {}".format(compiler) | ||
) | ||
expect( | ||
ngpus_per_node > 0, | ||
" ngpus_per_node is expected > 0 for compiler {}; current value is {}".format( | ||
compiler, ngpus_per_node | ||
), | ||
) | ||
else: | ||
expect( | ||
ngpus_per_node == 0, | ||
" ngpus_per_node is expected = 0 for compiler {}; current value is {}".format( | ||
compiler, ngpus_per_node | ||
), | ||
) | ||
if gpu_type: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 on removing this init stub for ngpus as it makes the definition explicit. |
||
expect(max_gpus_per_node, "GPUS are not defined for this machine") | ||
expect( | ||
gpu_offload, | ||
"Both gpu-type and gpu-offload must be defined if either is defined", | ||
) | ||
self.set_value("GPU_TYPE", gpu_type) | ||
self.set_value("GPU_OFFLOAD", gpu_offload) | ||
|
||
if ngpus_per_node >= 0: | ||
self.set_value( | ||
"NGPUS_PER_NODE", | ||
ngpus_per_node | ||
max(1, ngpus_per_node) | ||
if ngpus_per_node <= max_gpus_per_node | ||
else max_gpus_per_node, | ||
) | ||
|
||
elif gpu_offload: | ||
expect( | ||
False, | ||
"Both gpu-type and gpu-offload must be defined if either is defined", | ||
) | ||
|
||
self.initialize_derived_attributes() | ||
|
||
# -------------------------------------------- | ||
|
@@ -2308,6 +2298,8 @@ def create( | |
extra_machines_dir=None, | ||
case_group=None, | ||
ngpus_per_node=0, | ||
gpu_type=None, | ||
gpu_offload=None, | ||
): | ||
try: | ||
# Set values for env_case.xml | ||
|
@@ -2381,6 +2373,8 @@ def create( | |
extra_machines_dir=extra_machines_dir, | ||
case_group=case_group, | ||
ngpus_per_node=ngpus_per_node, | ||
gpu_type=gpu_type, | ||
gpu_offload=gpu_offload, | ||
) | ||
|
||
self.create_caseroot() | ||
|
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
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.
Starting a discussion from E3SM perspective:
As this mandates GPU_OFFLOAD, we probably have to add a third option to handle the case for C++ codebases that use a library approach as it won't be OpenMP or OpenACC.
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.
Sarats - there is an ongoing discussion in #4334, I will copy this comment there.