Skip to content

Commit

Permalink
[HIP] Changes for device_globals and enable tests (intel#12165)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hdelan authored Jan 16, 2024
1 parent 1237051 commit d377464
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 34 deletions.
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10306,7 +10306,7 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
if (!(T.isAMDGCN()))
addArgs(CmdArgs, TCArgs, {"-emit-param-info"});
// Enable PI program metadata
if (T.isNVPTX())
if (T.isNVPTX() || T.isAMDGCN())
addArgs(CmdArgs, TCArgs, {"-emit-program-metadata"});
if (SYCLPostLink->getTrueType() == types::TY_LLVM_BC) {
// single file output requested - this means only perform necessary IR
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/HIPAMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ void HIPAMDToolChain::addClangTargetOptions(
// supported for the foreseeable future.
if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
options::OPT_fvisibility_ms_compat)) {
CC1Args.append({"-fvisibility=hidden"});
if (DeviceOffloadingKind != Action::OFK_SYCL)
CC1Args.append({"-fvisibility=hidden"});
CC1Args.push_back("-fapply-global-visibility-to-externs");
}

Expand Down
8 changes: 8 additions & 0 deletions clang/test/Driver/sycl-hip-driver-args.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Test that driver has the correct flags for SYCL HIP compilation

// 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 \
// RUN: | FileCheck %s

// CHECK: sycl-post-link{{.*}} "-emit-program-metadata" {{.*}}
// CHECK-NOT: "-cc1"{{.*}}"-fvisibility=hidden"

15 changes: 7 additions & 8 deletions sycl/plugins/unified_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,13 @@ if(SYCL_PI_UR_USE_FETCH_CONTENT)
include(FetchContent)

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

if(SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO)
set(UNIFIED_RUNTIME_REPO "${SYCL_PI_UR_OVERRIDE_FETCH_CONTENT_REPO}")
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/DeviceGlobal/device_global_arrow.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
//
// The HIP and OpenCL GPU backends do not currently support device_global
// backend calls.
// UNSUPPORTED: hip || (opencl && gpu)
// The OpenCL GPU backends do not currently support device_global backend
// calls.
// UNSUPPORTED: opencl && gpu
//
// Tests operator-> on device_global.

Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/DeviceGlobal/device_global_arrow_dis.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %{build} -fsycl-device-code-split=per_source -DUSE_DEVICE_IMAGE_SCOPE -o %t.out
// RUN: %{run} %t.out
//
// The HIP and OpenCL GPU backends do not currently support device_global
// backend calls.
// UNSUPPORTED: hip || (opencl && gpu)
// The OpenCL GPU backends do not currently support device_global backend
// calls.
// UNSUPPORTED: opencl && gpu
//
// Tests operator-> on device_global with device_image_scope.
// NOTE: USE_DEVICE_IMAGE_SCOPE needs both kernels to be in the same image so
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/DeviceGlobal/device_global_device_only.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
//
// The HIP and OpenCL GPU backends do not currently support device_global
// backend calls.
// UNSUPPORTED: hip || (opencl && gpu)
// The OpenCL GPU backends do not currently support device_global backend
// calls.
// UNSUPPORTED: opencl && gpu
//
// Tests basic device_global access through device kernels.

Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/DeviceGlobal/device_global_device_only_dis.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %{build} -fsycl-device-code-split=per_source -DUSE_DEVICE_IMAGE_SCOPE -o %t.out
// RUN: %{run} %t.out
//
// The HIP and OpenCL GPU backends do not currently support device_global
// backend calls.
// UNSUPPORTED: hip || (opencl && gpu)
// The OpenCL GPU backends do not currently support device_global backend
// calls.
// UNSUPPORTED: opencl && gpu
//
// Tests basic device_global with device_image_scope access through device
// kernels.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
//
// The HIP and OpenCL GPU backends do not currently support device_global
// backend calls.
// UNSUPPORTED: hip || (opencl && gpu)
// The OpenCL GPU backends do not currently support device_global backend
// calls.
// UNSUPPORTED: opencl && gpu
//
// Tests the passthrough of operators on device_global.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %{build} -fsycl-device-code-split=per_source -DUSE_DEVICE_IMAGE_SCOPE -o %t.out
// RUN: %{run} %t.out
//
// The HIP and OpenCL GPU backends do not currently support device_global
// backend calls.
// UNSUPPORTED: hip || (opencl && gpu)
// The OpenCL GPU backends do not currently support device_global backend
// calls.
// UNSUPPORTED: opencl && gpu
//
// Tests the passthrough of operators on device_global with device_image_scope.
// NOTE: USE_DEVICE_IMAGE_SCOPE needs both kernels to be in the same image so
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/DeviceGlobal/device_global_subscript.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
//
// The HIP and OpenCL GPU backends do not currently support device_global
// backend calls.
// UNSUPPORTED: hip || (opencl && gpu)
// The OpenCL GPU backends do not currently support device_global backend
// calls.
// UNSUPPORTED: opencl && gpu
//
// Tests operator[] on device_global.

Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/DeviceGlobal/device_global_subscript_dis.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %{build} -fsycl-device-code-split=per_source -DUSE_DEVICE_IMAGE_SCOPE -o %t.out
// RUN: %{run} %t.out
//
// The HIP and OpenCL GPU backends do not currently support device_global
// backend calls.
// UNSUPPORTED: hip || (opencl && gpu)
// The OpenCL GPU backends do not currently support device_global backend
// calls.
// UNSUPPORTED: opencl && gpu
//
// Tests operator[] on device_global with device_image_scope.
// NOTE: USE_DEVICE_IMAGE_SCOPE needs both kernels to be in the same image so
Expand Down

0 comments on commit d377464

Please sign in to comment.