Skip to content
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

remove RDC flags when using CMake language CUDA #5564

Merged
merged 6 commits into from
Oct 28, 2022

Conversation

ibaned
Copy link
Contributor

@ibaned ibaned commented Oct 17, 2022

When compiling with CUDA as a CMake language,
the RDC aspect is handled by CMake's
CUDA_SEPARABLE_COMPILATION property on targets and the associated CMAKE_CUDA_SEPARABLE_COMPILATION
variable that sets the default value for that
property.
The arguments set by this part of Kokkos' CMake
actually conflict with the above.

When compiling with CUDA as a CMake language,
the RDC aspect is handled by CMake's
CUDA_SEPARABLE_COMPILATION property on targets and
the associated CMAKE_CUDA_SEPARABLE_COMPILATION
variable that sets the default value for that
property.
The arguments set by this part of Kokkos' CMake
actually conflict with the above.
@masterleinad
Copy link
Contributor

Should KOKKOS_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE=ON then set CMAKE_CUDA_SEPARABLE_COMPILATION=ON when compiling with CUDA as a CMake language?

@ibaned
Copy link
Contributor Author

ibaned commented Oct 17, 2022

Should KOKKOS_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE=ON then set CMAKE_CUDA_SEPARABLE_COMPILATION=ON when compiling with CUDA as a CMake language?

Yes, that makes sense! Can you help me identify where in the Kokkos CMake files that should be set? I can add it to this PR then if you'd like.

@crtrott
Copy link
Member

crtrott commented Oct 17, 2022

Yeah agreed, we should set that option then, and/or warn if there is a mismatch of that with the Kokkos setting.

@ibaned
Copy link
Contributor Author

ibaned commented Oct 17, 2022

Is the place I already modified a good place to set the value? it happens before all Kokkos targets get created right? I'll do that unless someone tells me otherwise

the Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE
and CMAKE_CUDA_SEPARABLE_COMPILATION options
both control whether CUDA RDC is on when
we are building using CUDA as a CMake language.
This code makes sure that if either of those
options is on, the other one is also on.
This way, both older build scripts that used
the first option and "proper CMake" scripts
that use the latter will have the same effect
if building Kokkos with CUDA as a CMake
language is enabled.
@ibaned
Copy link
Contributor Author

ibaned commented Oct 17, 2022

Okay, I added some code to ensure that, if we are building using CMake's CUDA language, then setting either of those options on will set both of them on. Let me know if anything else is missing from this.

Comment on lines 139 to 142
IF (CMAKE_CUDA_SEPARABLE_COMPILATION)
ELSE()
SET(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
ENDIF()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
IF (CMAKE_CUDA_SEPARABLE_COMPILATION)
ELSE()
SET(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
ENDIF()
IF (NOT CMAKE_CUDA_SEPARABLE_COMPILATION)
SET(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
ENDIF()

NVIDIA --relocatable-device-code=true
NVHPC -gpu=rdc
)
IF (NOT KOKKOS_COMPILE_LANGUAGE STREQUAL CUDA)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem right
Assume RDC is OFF but we are using NVHPC L462 we'd still be adding the -gpu=nordc flag

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. This if condition should guard from setting any flags.

Comment on lines 139 to 141
IF (NOT CMAKE_CUDA_SEPARABLE_COMPILATION)
SET(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
ENDIF()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to raise a warning (or display a STATUS message) when setting the CMAKE_CUDA_SEPARABLE_COMPILATION variable

@ibaned
Copy link
Contributor Author

ibaned commented Oct 27, 2022

Thank you @masterleinad and @dalg24 for your reviews! I believe I've just addressed both of your suggestions, please let me know if other changes are desired.

@dalg24 dalg24 merged commit 26e9ba2 into kokkos:develop Oct 28, 2022
@dalg24 dalg24 mentioned this pull request Oct 28, 2022
@ibaned ibaned deleted the rdc-cmake-lang branch October 28, 2022 17:25
cz4rs pushed a commit to cz4rs/kokkos that referenced this pull request Nov 10, 2022
* remove RDC flags when using CMake language CUDA

When compiling with CUDA as a CMake language,
the RDC aspect is handled by CMake's
CUDA_SEPARABLE_COMPILATION property on targets and
the associated CMAKE_CUDA_SEPARABLE_COMPILATION
variable that sets the default value for that
property.
The arguments set by this part of Kokkos' CMake
actually conflict with the above.

* ensure both RDC options are consistent

the Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE
and CMAKE_CUDA_SEPARABLE_COMPILATION options
both control whether CUDA RDC is on when
we are building using CUDA as a CMake language.
This code makes sure that if either of those
options is on, the other one is also on.
This way, both older build scripts that used
the first option and "proper CMake" scripts
that use the latter will have the same effect
if building Kokkos with CUDA as a CMake
language is enabled.

* try to apply Daniel Arndt's suggestions

* don't set any compiler RDC flags when CMake lang

see comment kokkos#5564 (comment)

* add warning when changing CMake RDC flag

see comment kokkos#5564 (comment)

* Nitpick prefer STATUS to WARNING in message

Co-authored-by: Damien L-G <[email protected]>
tcclevenger pushed a commit to tcclevenger/kokkos that referenced this pull request Dec 5, 2022
* remove RDC flags when using CMake language CUDA

When compiling with CUDA as a CMake language,
the RDC aspect is handled by CMake's
CUDA_SEPARABLE_COMPILATION property on targets and
the associated CMAKE_CUDA_SEPARABLE_COMPILATION
variable that sets the default value for that
property.
The arguments set by this part of Kokkos' CMake
actually conflict with the above.

* ensure both RDC options are consistent

the Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE
and CMAKE_CUDA_SEPARABLE_COMPILATION options
both control whether CUDA RDC is on when
we are building using CUDA as a CMake language.
This code makes sure that if either of those
options is on, the other one is also on.
This way, both older build scripts that used
the first option and "proper CMake" scripts
that use the latter will have the same effect
if building Kokkos with CUDA as a CMake
language is enabled.

* try to apply Daniel Arndt's suggestions

* don't set any compiler RDC flags when CMake lang

see comment kokkos#5564 (comment)

* add warning when changing CMake RDC flag

see comment kokkos#5564 (comment)

* Nitpick prefer STATUS to WARNING in message

Co-authored-by: Damien L-G <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants