Skip to content

Commit d377464

Browse files
authored
[HIP] Changes for device_globals and enable tests (#12165)
Enable `device_global` for AMDGPU. Related to oneapi-src/unified-runtime#1186 . In order for `hipModuleGetGlobal` to see a global symbol we need to not make the visibility of the symbol hidden. Perhaps changing this as a default is not always a good idea. Could also do this in the SYCL headers using an attribute to specify the visibility of the `device_global` var
1 parent 1237051 commit d377464

12 files changed

+42
-34
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10306,7 +10306,7 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
1030610306
if (!(T.isAMDGCN()))
1030710307
addArgs(CmdArgs, TCArgs, {"-emit-param-info"});
1030810308
// Enable PI program metadata
10309-
if (T.isNVPTX())
10309+
if (T.isNVPTX() || T.isAMDGCN())
1031010310
addArgs(CmdArgs, TCArgs, {"-emit-program-metadata"});
1031110311
if (SYCLPostLink->getTrueType() == types::TY_LLVM_BC) {
1031210312
// single file output requested - this means only perform necessary IR

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ void HIPAMDToolChain::addClangTargetOptions(
269269
// supported for the foreseeable future.
270270
if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
271271
options::OPT_fvisibility_ms_compat)) {
272-
CC1Args.append({"-fvisibility=hidden"});
272+
if (DeviceOffloadingKind != Action::OFK_SYCL)
273+
CC1Args.append({"-fvisibility=hidden"});
273274
CC1Args.push_back("-fapply-global-visibility-to-externs");
274275
}
275276

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Test that driver has the correct flags for SYCL HIP compilation
2+
3+
// RUN: %clangxx -### %s -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx1031 -fno-sycl-libspirv -nogpulib --sysroot=%S/Inputs/SYCL %s 2>&1 \
4+
// RUN: | FileCheck %s
5+
6+
// CHECK: sycl-post-link{{.*}} "-emit-program-metadata" {{.*}}
7+
// CHECK-NOT: "-cc1"{{.*}}"-fvisibility=hidden"
8+

sycl/plugins/unified_runtime/CMakeLists.txt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,13 @@ if(SYCL_PI_UR_USE_FETCH_CONTENT)
5757
include(FetchContent)
5858

5959
set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
60-
# commit d06ba9d9c539dc712444c6db95dfe1629bd5f7d8
61-
# Merge: e1414e1 35b6a5e
62-
# Author: Kenneth Benzie (Benie) <[email protected]>
63-
# Date: Thu Jan 11 15:09:01 2024 +0000
64-
# Merge pull request #1035 from Bensuo/cmd-buffer-profiling-l0
65-
# [EXP][CMDBUF] Add support for recovering CommandBuffer profiling
66-
# information
67-
set(UNIFIED_RUNTIME_TAG d06ba9d9c539dc712444c6db95dfe1629bd5f7d8)
60+
# commit 79c28d0f0713f58358d5080653d95803fd131749
61+
# Merge: 25e0b603 45d76b78
62+
# Author: aarongreig <[email protected]>
63+
# Date: Fri Jan 12 16:14:44 2024 +0000
64+
# Merge pull request #1186 from hdelan/device-global-hip
65+
# [HIP] Add support for global variable read write
66+
set(UNIFIED_RUNTIME_TAG 79c28d0f0713f58358d5080653d95803fd131749)
6867

6968
if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO)
7069
set(UNIFIED_RUNTIME_REPO "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO}")

sycl/test-e2e/DeviceGlobal/device_global_arrow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %{build} -o %t.out
22
// RUN: %{run} %t.out
33
//
4-
// The HIP and OpenCL GPU backends do not currently support device_global
5-
// backend calls.
6-
// UNSUPPORTED: hip || (opencl && gpu)
4+
// The OpenCL GPU backends do not currently support device_global backend
5+
// calls.
6+
// UNSUPPORTED: opencl && gpu
77
//
88
// Tests operator-> on device_global.
99

sycl/test-e2e/DeviceGlobal/device_global_arrow_dis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %{build} -fsycl-device-code-split=per_source -DUSE_DEVICE_IMAGE_SCOPE -o %t.out
22
// RUN: %{run} %t.out
33
//
4-
// The HIP and OpenCL GPU backends do not currently support device_global
5-
// backend calls.
6-
// UNSUPPORTED: hip || (opencl && gpu)
4+
// The OpenCL GPU backends do not currently support device_global backend
5+
// calls.
6+
// UNSUPPORTED: opencl && gpu
77
//
88
// Tests operator-> on device_global with device_image_scope.
99
// NOTE: USE_DEVICE_IMAGE_SCOPE needs both kernels to be in the same image so

sycl/test-e2e/DeviceGlobal/device_global_device_only.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %{build} -o %t.out
22
// RUN: %{run} %t.out
33
//
4-
// The HIP and OpenCL GPU backends do not currently support device_global
5-
// backend calls.
6-
// UNSUPPORTED: hip || (opencl && gpu)
4+
// The OpenCL GPU backends do not currently support device_global backend
5+
// calls.
6+
// UNSUPPORTED: opencl && gpu
77
//
88
// Tests basic device_global access through device kernels.
99

sycl/test-e2e/DeviceGlobal/device_global_device_only_dis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %{build} -fsycl-device-code-split=per_source -DUSE_DEVICE_IMAGE_SCOPE -o %t.out
22
// RUN: %{run} %t.out
33
//
4-
// The HIP and OpenCL GPU backends do not currently support device_global
5-
// backend calls.
6-
// UNSUPPORTED: hip || (opencl && gpu)
4+
// The OpenCL GPU backends do not currently support device_global backend
5+
// calls.
6+
// UNSUPPORTED: opencl && gpu
77
//
88
// Tests basic device_global with device_image_scope access through device
99
// kernels.

sycl/test-e2e/DeviceGlobal/device_global_operator_passthrough.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %{build} -o %t.out
22
// RUN: %{run} %t.out
33
//
4-
// The HIP and OpenCL GPU backends do not currently support device_global
5-
// backend calls.
6-
// UNSUPPORTED: hip || (opencl && gpu)
4+
// The OpenCL GPU backends do not currently support device_global backend
5+
// calls.
6+
// UNSUPPORTED: opencl && gpu
77
//
88
// Tests the passthrough of operators on device_global.
99

sycl/test-e2e/DeviceGlobal/device_global_operator_passthrough_dis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %{build} -fsycl-device-code-split=per_source -DUSE_DEVICE_IMAGE_SCOPE -o %t.out
22
// RUN: %{run} %t.out
33
//
4-
// The HIP and OpenCL GPU backends do not currently support device_global
5-
// backend calls.
6-
// UNSUPPORTED: hip || (opencl && gpu)
4+
// The OpenCL GPU backends do not currently support device_global backend
5+
// calls.
6+
// UNSUPPORTED: opencl && gpu
77
//
88
// Tests the passthrough of operators on device_global with device_image_scope.
99
// NOTE: USE_DEVICE_IMAGE_SCOPE needs both kernels to be in the same image so

sycl/test-e2e/DeviceGlobal/device_global_subscript.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %{build} -o %t.out
22
// RUN: %{run} %t.out
33
//
4-
// The HIP and OpenCL GPU backends do not currently support device_global
5-
// backend calls.
6-
// UNSUPPORTED: hip || (opencl && gpu)
4+
// The OpenCL GPU backends do not currently support device_global backend
5+
// calls.
6+
// UNSUPPORTED: opencl && gpu
77
//
88
// Tests operator[] on device_global.
99

sycl/test-e2e/DeviceGlobal/device_global_subscript_dis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %{build} -fsycl-device-code-split=per_source -DUSE_DEVICE_IMAGE_SCOPE -o %t.out
22
// RUN: %{run} %t.out
33
//
4-
// The HIP and OpenCL GPU backends do not currently support device_global
5-
// backend calls.
6-
// UNSUPPORTED: hip || (opencl && gpu)
4+
// The OpenCL GPU backends do not currently support device_global backend
5+
// calls.
6+
// UNSUPPORTED: opencl && gpu
77
//
88
// Tests operator[] on device_global with device_image_scope.
99
// NOTE: USE_DEVICE_IMAGE_SCOPE needs both kernels to be in the same image so

0 commit comments

Comments
 (0)