Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/std-data/model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ register_flag_optional(USE_ONEDPL
This requires the DPC++ compiler (other SYCL compilers are untested), required SYCL flags are added automatically."
"OFF")

register_flag_optional(CLANG_OFFLOAD
"Enable offloading support (via the non-standard `-stdpar`) for
Clang/LLVM. The values are AMDGPU processors (https://www.llvm.org/docs/AMDGPUUsage.html#processors)
which will be passed in via `--offload-arch=` argument.

Example values are:
gfx906 - Compile for Vega20 GPUs
gfx908 - Compile for CDNA1 GPUs
gfx90a - Compile for CDNA2 GPUs
gfx942 - Compile for CDNA3 GPUs
gfx1030 - Compile for RDNA2 NV21 GPUs
gfx1100 - Compile for RDNA3 NV31 GPUs"
"")


macro(setup)
set(CMAKE_CXX_STANDARD 17)
if (NVHPC_OFFLOAD)
Expand All @@ -50,4 +65,13 @@ macro(setup)
register_definitions(USE_ONEDPL)
register_link_library(oneDPL)
endif ()
if (CLANG_OFFLOAD)
set(CLANG_FLAGS --hipstdpar --offload-arch=${CLANG_OFFLOAD})
if (NOT CLANG_OFFLOAD MATCHES "^gfx9")
list(APPEND CLANG_FLAGS --hipstdpar-interpose-alloc)
endif ()

register_append_cxx_flags(ANY ${CLANG_FLAGS})
register_append_link_flags(--hipstdpar)
endif ()
endmacro()
25 changes: 25 additions & 0 deletions src/std-indices/model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ register_flag_optional(USE_ONEDPL
This requires the DPC++ compiler (other SYCL compilers are untested), required SYCL flags are added automatically."
"OFF")

register_flag_optional(CLANG_OFFLOAD
"Enable offloading support (via the non-standard `-stdpar`) for
Clang/LLVM. The values are AMDGPU processors (https://www.llvm.org/docs/AMDGPUUsage.html#processors)
which will be passed in via `--offload-arch=` argument.

Example values are:
gfx906 - Compile for Vega20 GPUs
gfx908 - Compile for CDNA1 GPUs
gfx90a - Compile for CDNA2 GPUs
gfx942 - Compile for CDNA3 GPUs
gfx1030 - Compile for RDNA2 NV21 GPUs
gfx1100 - Compile for RDNA3 NV31 GPUs"
"")



macro(setup)
set(CMAKE_CXX_STANDARD 17)
if (NVHPC_OFFLOAD)
Expand All @@ -50,4 +66,13 @@ macro(setup)
register_definitions(USE_ONEDPL)
register_link_library(oneDPL)
endif ()
if (CLANG_OFFLOAD)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not totally sold on the name of this definition as CLANG is not specific to AMD, but the CLANG_FLAGS set below are definitely specific. Can we rename this please to something appropriate?

@gsitaram gsitaram May 13, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would replacing CLANG_OFFLOAD with AMDGPU_TARGET_OFFLOAD and CLANG_FLAGS with AMDGPU_TARGET_OFFLOAD_FLAGS be acceptable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @tomdeakin, please confirm if the above suggestion would work or recommend something better. I can make the changes accordingly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

set(CLANG_FLAGS --hipstdpar --offload-arch=${CLANG_OFFLOAD})
if (NOT CLANG_OFFLOAD MATCHES "^gfx9")
list(APPEND CLANG_FLAGS --hipstdpar-interpose-alloc)
endif ()

register_append_cxx_flags(ANY ${CLANG_FLAGS})
register_append_link_flags(--hipstdpar)
endif ()
endmacro()