-
Notifications
You must be signed in to change notification settings - Fork 407
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
OpenMPTarget: Enable Cray compiler for the OpenMPTarget backend. #5889
Conversation
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.
Some small changes needed (comments and indentation)
@@ -93,13 +93,16 @@ void OpenMPTargetInternal::impl_initialize() { | |||
|
|||
// FIXME_OPENMPTARGET: Only fix the number of teams for NVIDIA architectures | |||
// from Pascal and upwards. | |||
// Cray compiler did not yet implement omp_set_num_teams. |
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.
sigh
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.
Add a FIXME for Cray
core/unit_test/CMakeLists.txt
Outdated
@@ -353,6 +353,12 @@ if(Kokkos_ENABLE_OPENMPTARGET) | |||
${CMAKE_CURRENT_BINARY_DIR}/openmptarget/TestOpenMPTarget_Other.cpp | |||
${CMAKE_CURRENT_BINARY_DIR}/openmptarget/TestOpenMPTarget_TeamReductionScan.cpp | |||
${CMAKE_CURRENT_BINARY_DIR}/openmptarget/TestOpenMPTarget_WorkGraph.cpp | |||
# The following tests fail at compile time when the OpenMPTarget backend is enabled with the Cray compiler. |
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.
Add a FIXME comment also this is all kinds of atomic stuff - this could be a real issue. As if compare/exchange doesn't work properly.
if (std::is_same_v<TEST_EXECSPACE, Kokkos::Experimental::OpenMPTarget>) | ||
GTEST_SKIP() << "Cray compiler fails correctness at runtime with the " | ||
"OpenMPTarget backend."; | ||
#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.
Add a FIXME comment
if (std::is_same_v<TEST_EXECSPACE, Kokkos::Experimental::OpenMPTarget>) | ||
GTEST_SKIP() << "Cray compiler fails correctness at runtime with the " | ||
"OpenMPTarget backend."; | ||
#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.
Add a FIXME comment something with "Cray" in the same line too.
cmake/kokkos_arch.cmake
Outdated
@@ -680,12 +680,18 @@ ENDIF() | |||
IF (KOKKOS_ENABLE_OPENMPTARGET) | |||
SET(CLANG_CUDA_ARCH ${KOKKOS_CUDA_ARCH_FLAG}) | |||
IF (CLANG_CUDA_ARCH) | |||
IF(KOKKOS_CLANG_IS_CRAY) |
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.
fix identation.
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.
Can you comment about the choice to distinguish between the legacy and the Clang-based Cray compilers?
Also with Intel we do not define KOKKOS_COMPILER_CLANG
kokkos/core/src/Kokkos_Macros.hpp
Lines 151 to 152 in 948c6c6
#if defined(__clang__) && !defined(KOKKOS_COMPILER_INTEL) | |
#define KOKKOS_COMPILER_CLANG \ |
Did you mean to define both
KOKKOS_COMPILER_CRAYCLANG
and KOKKOS_COMPILER_CLANG
?
The With respect to Intel compiler, I assume the same |
Look at the code snippet I referenced. We define |
I am asking about clarifying why we want to distinguish them in the first place. I am not necessary suggesting we should not distinguish them. I just observing we don't do it for Intel and I am wondering whether you thought about it and why you decided to do it this way. |
Makefile.kokkos
Outdated
# Cray compiler only needs fopenmp flag for target offload. | ||
ifeq ($(KOKKOS_INTERNAL_COMPILER_CRAY_CLANG), 1) | ||
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -DKOKKOS_WORKAROUND_OPENMPTARGET_CLANG -fopenmp | ||
else | ||
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -DKOKKOS_WORKAROUND_OPENMPTARGET_CLANG -fopenmp -fopenmp=libomp -Wno-openmp-mapping | ||
KOKKOS_INTERNAL_OPENMPTARGET_LIB := -lomptarget | ||
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.
# Cray compiler only needs fopenmp flag for target offload. | |
ifeq ($(KOKKOS_INTERNAL_COMPILER_CRAY_CLANG), 1) | |
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -DKOKKOS_WORKAROUND_OPENMPTARGET_CLANG -fopenmp | |
else | |
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -DKOKKOS_WORKAROUND_OPENMPTARGET_CLANG -fopenmp -fopenmp=libomp -Wno-openmp-mapping | |
KOKKOS_INTERNAL_OPENMPTARGET_LIB := -lomptarget | |
endif | |
# Cray compiler only needs fopenmp flag for target offload. | |
ifeq ($(KOKKOS_INTERNAL_COMPILER_CRAY_CLANG), 1) | |
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -DKOKKOS_WORKAROUND_OPENMPTARGET_CLANG -fopenmp | |
else | |
KOKKOS_INTERNAL_OPENMPTARGET_FLAG := -DKOKKOS_WORKAROUND_OPENMPTARGET_CLANG -fopenmp -fopenmp=libomp -Wno-openmp-mapping | |
KOKKOS_INTERNAL_OPENMPTARGET_LIB := -lomptarget | |
endif |
Makefile.kokkos
Outdated
# Not necessary for the Cray compiler. | ||
ifeq ($(KOKKOS_INTERNAL_COMPILER_CRAY_CLANG), 0) | ||
ifeq ($(KOKKOS_INTERNAL_COMPILER_CLANG), 1) | ||
KOKKOS_INTERNAL_CUDA_ARCH_FLAG=-fopenmp-targets=nvptx64 -Xopenmp-target -march | ||
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.
# Not necessary for the Cray compiler. | |
ifeq ($(KOKKOS_INTERNAL_COMPILER_CRAY_CLANG), 0) | |
ifeq ($(KOKKOS_INTERNAL_COMPILER_CLANG), 1) | |
KOKKOS_INTERNAL_CUDA_ARCH_FLAG=-fopenmp-targets=nvptx64 -Xopenmp-target -march | |
endif | |
endif | |
# Not necessary for the Cray compiler. | |
ifeq ($(KOKKOS_INTERNAL_COMPILER_CRAY_CLANG), 0) | |
ifeq ($(KOKKOS_INTERNAL_COMPILER_CLANG), 1) | |
KOKKOS_INTERNAL_CUDA_ARCH_FLAG=-fopenmp-targets=nvptx64 -Xopenmp-target -march | |
endif | |
endif |
# Do not add this flag it its the cray compiler. | ||
ifeq ($(KOKKOS_INTERNAL_COMPILER_CRAY_CLANG), 0) |
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.
Please also indent accordingly.
So the Cray compiler doesn't take any architecture flags at all?!
Does this also apply if compiling for the Cuda
backend?
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.
No Cray compiler does not take any architecture flags. I was also surprised by that update. Why would we compile Cuda
backend with Cray compiler, do you mean using Cray Wrappers? Cuda
backend points to nvcc_wrapper
anyways right?
core/src/Kokkos_Macros.hpp
Outdated
@@ -153,6 +153,13 @@ | |||
__clang_major__ * 100 + __clang_minor__ * 10 + __clang_patchlevel__ | |||
#endif | |||
|
|||
// Macro for the Cray compiler based on clang. | |||
// Different from classical Cray wihch is defined above. |
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.
// Different from classical Cray wihch is defined above. | |
// Different from classical Cray which is defined above. |
Is it a problem that the compiler now identifies as both CLANG
and CRAYCLANG
?
Ah yes thanks. I missed the 2nd condition on that line. |
Added a comment on the need for a new macro since the newer Clang based Cray compilers have a mature OpenMP offload implementation but we still want the older Classical Cray macro for the host if that is being used somewhere. |
@masterleinad has a good point which even @dalg24 is referring to, that now we define both |
@rgayatri23 This needs rebasing. |
8fc7f7f
to
3b26a93
Compare
cmake/kokkos_arch.cmake
Outdated
IF(KOKKOS_CLANG_IS_CRAY) | ||
COMPILER_SPECIFIC_FLAGS( | ||
Cray -fopenmp | ||
) | ||
ELSE() | ||
STRING(REPLACE "sm_" "cc" NVHPC_CUDA_ARCH ${CLANG_CUDA_ARCH}) | ||
COMPILER_SPECIFIC_FLAGS( | ||
Clang -Xopenmp-target -march=${CLANG_CUDA_ARCH} -fopenmp-targets=nvptx64 | ||
NVHPC -gpu=${NVHPC_CUDA_ARCH} | ||
) | ||
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.
I know that most of it pre-existed but could you fix the indentation here in a sensible way?
Like that the closing ")" is at least as indented as the opening one.
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.
Getting the closing bracket in the same level as the opening one looks weird, I tried to put the opening one in the next line but that does not match the style in the rest of the file. I indented the lines inside the brackets to make the nesting look obvious. Let me know if thats acceptable.
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.
Otherwise, this looks Ok to me.
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.
Thanks for bearing with me! 🙂
Requested changes have been addressed.
…kos#5889) * OpenMPTarget: Enable Cray compiler for the OpenMPTarget backend. * OpenMPTarget: Adding a fixme for Cray compiler. * OpenMPTarget: Add fixme for cray compiler. * OpenMPTarget: fix indentation. --------- Co-authored-by: Rahulkumar Gayatri <rgayatri@lbl.gov>
The PR does the following :
KOKKOS_COMPILER_CRAY_CLANG