From 9d4cc72f8f93221d0ef4900ee26dd3c3634d5c10 Mon Sep 17 00:00:00 2001 From: Sriranjani Sitaraman Date: Mon, 29 Apr 2024 20:51:20 +0000 Subject: [PATCH 1/3] Add support for hipstdpar --- src/std-data/model.cmake | 24 ++++++++++++++++++++++++ src/std-indices/model.cmake | 25 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/std-data/model.cmake b/src/std-data/model.cmake index e9e70998..8ccbfb7c 100644 --- a/src/std-data/model.cmake +++ b/src/std-data/model.cmake @@ -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) @@ -50,4 +65,13 @@ macro(setup) register_definitions(USE_ONEDPL) register_link_library(oneDPL) endif () + if (CLANG_OFFLOAD) + set(CLANG_FLAGS --hipstdpar --hipstdpar-path=${CLANG_STDPAR_PATH} --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() diff --git a/src/std-indices/model.cmake b/src/std-indices/model.cmake index 60ef575f..a0138f08 100644 --- a/src/std-indices/model.cmake +++ b/src/std-indices/model.cmake @@ -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) @@ -50,4 +66,13 @@ macro(setup) register_definitions(USE_ONEDPL) register_link_library(oneDPL) endif () + if (CLANG_OFFLOAD) + set(CLANG_FLAGS --hipstdpar --hipstdpar-path=${CLANG_STDPAR_PATH} --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() From 9f67c5f0ca38cbeca701fa82d4c2ab6acef31431 Mon Sep 17 00:00:00 2001 From: Sriranjani Sitaraman Date: Tue, 30 Apr 2024 14:20:18 -0700 Subject: [PATCH 2/3] Remove --hipstdpar-path as it is not needed with ROCm 6.1 onwards --- src/std-data/model.cmake | 2 +- src/std-indices/model.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/std-data/model.cmake b/src/std-data/model.cmake index 8ccbfb7c..a2679c50 100644 --- a/src/std-data/model.cmake +++ b/src/std-data/model.cmake @@ -66,7 +66,7 @@ macro(setup) register_link_library(oneDPL) endif () if (CLANG_OFFLOAD) - set(CLANG_FLAGS --hipstdpar --hipstdpar-path=${CLANG_STDPAR_PATH} --offload-arch=${CLANG_OFFLOAD}) + set(CLANG_FLAGS --hipstdpar --offload-arch=${CLANG_OFFLOAD}) if (NOT CLANG_OFFLOAD MATCHES "^gfx9") list(APPEND CLANG_FLAGS --hipstdpar-interpose-alloc) endif () diff --git a/src/std-indices/model.cmake b/src/std-indices/model.cmake index a0138f08..2ad3d703 100644 --- a/src/std-indices/model.cmake +++ b/src/std-indices/model.cmake @@ -67,7 +67,7 @@ macro(setup) register_link_library(oneDPL) endif () if (CLANG_OFFLOAD) - set(CLANG_FLAGS --hipstdpar --hipstdpar-path=${CLANG_STDPAR_PATH} --offload-arch=${CLANG_OFFLOAD}) + set(CLANG_FLAGS --hipstdpar --offload-arch=${CLANG_OFFLOAD}) if (NOT CLANG_OFFLOAD MATCHES "^gfx9") list(APPEND CLANG_FLAGS --hipstdpar-interpose-alloc) endif () From 7e5c410a51ba8b710e4ef0dbebef34056f7f7d98 Mon Sep 17 00:00:00 2001 From: Sriranjani Sitaraman Date: Thu, 13 Jun 2024 12:27:29 -0700 Subject: [PATCH 3/3] Change definition names to be more specific to AMD GPUs --- src/std-data/model.cmake | 12 ++++++------ src/std-indices/model.cmake | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/std-data/model.cmake b/src/std-data/model.cmake index a2679c50..0bee0af4 100644 --- a/src/std-data/model.cmake +++ b/src/std-data/model.cmake @@ -35,7 +35,7 @@ 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 +register_flag_optional(AMDGPU_TARGET_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. @@ -65,13 +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) + if (AMDGPU_TARGET_OFFLOAD) + set(AMDGPU_TARGET_OFFLOAD_FLAGS --hipstdpar --offload-arch=${AMDGPU_TARGET_OFFLOAD}) + if (NOT AMDGPU_TARGET_OFFLOAD MATCHES "^gfx9") + list(APPEND AMDGPU_TARGET_OFFLOAD_FLAGS --hipstdpar-interpose-alloc) endif () - register_append_cxx_flags(ANY ${CLANG_FLAGS}) + register_append_cxx_flags(ANY ${AMDGPU_TARGET_OFFLOAD_FLAGS}) register_append_link_flags(--hipstdpar) endif () endmacro() diff --git a/src/std-indices/model.cmake b/src/std-indices/model.cmake index 2ad3d703..94eaf7c7 100644 --- a/src/std-indices/model.cmake +++ b/src/std-indices/model.cmake @@ -35,7 +35,7 @@ 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 +register_flag_optional(AMDGPU_TARGET_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. @@ -66,13 +66,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) + if (AMDGPU_TARGET_OFFLOAD) + set(AMDGPU_TARGET_OFFLOAD_FLAGS --hipstdpar --offload-arch=${AMDGPU_TARGET_OFFLOAD}) + if (NOT AMDGPU_TARGET_OFFLOAD MATCHES "^gfx9") + list(APPEND AMDGPU_TARGET_OFFLOAD_FLAGS --hipstdpar-interpose-alloc) endif () - register_append_cxx_flags(ANY ${CLANG_FLAGS}) + register_append_cxx_flags(ANY ${AMDGPU_TARGET_OFFLOAD_FLAGS}) register_append_link_flags(--hipstdpar) endif () endmacro()