Skip to content

Commit 25323c8

Browse files
authored
[SYCL][Offload] Enable Offload backend in E2E tests (#19417)
Enable the Offload backend in the E2E tests. The Offload UR adapter is still experimental and a WIP, the purpose of E2E testing now is purely to help develop the adapter and liboffload itself. The Offload adapter is not built by default.
1 parent 0084ac5 commit 25323c8

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3794,6 +3794,24 @@ bool doesImageTargetMatchDevice(const RTDeviceBinaryImage &Img,
37943794
if (PropIt == PropRange.end()) {
37953795
sycl::backend BE = DevImpl.getBackend();
37963796
const char *Target = Img.getRawData().DeviceTargetSpec;
3797+
// On Offload, the image format depends on the platform. As with the UR CTS,
3798+
// the easiest way to check this is the platform name which corresponds with
3799+
// the Offload plugin name. In the future the true backend type will be
3800+
// transparently passed through instead.
3801+
if (BE == sycl::backend::ext_oneapi_offload) {
3802+
std::string PlatformName =
3803+
DevImpl.getPlatformImpl().get_info<info::platform::name>();
3804+
if (PlatformName == "CUDA") {
3805+
return (strcmp(Target, __SYCL_DEVICE_BINARY_TARGET_NVPTX64) == 0 ||
3806+
strcmp(Target, __SYCL_DEVICE_BINARY_TARGET_LLVM_NVPTX64) == 0);
3807+
}
3808+
if (PlatformName == "AMDGPU") {
3809+
return (strcmp(Target, __SYCL_DEVICE_BINARY_TARGET_AMDGCN) == 0 ||
3810+
strcmp(Target, __SYCL_DEVICE_BINARY_TARGET_LLVM_AMDGCN) == 0);
3811+
}
3812+
assert(false && "Unhandled liboffload platform");
3813+
return false;
3814+
}
37973815
if (strcmp(Target, __SYCL_DEVICE_BINARY_TARGET_SPIRV64) == 0) {
37983816
return (BE == sycl::backend::opencl ||
37993817
BE == sycl::backend::ext_oneapi_level_zero);

sycl/test-e2e/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ or via the ***LIT_OPTS*** environment variable.
210210
compilation command line for GPU device. If not specified "-device *" value is
211211
used.
212212
213+
***OFFLOAD_BUILD_TARGET*** - when testing the Offload backend, this must be set
214+
to specify the correct build target type for the available Offload device.
215+
Valid values are `target-nvidia` and `target-amd`.
216+
213217
## Special test categories
214218
215219
There are two special directories for extended testing. See documentation at:

sycl/test-e2e/lit.cfg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"cuda": "target-nvidia",
2323
"hip": "target-amd",
2424
"native_cpu": "target-native_cpu",
25+
"offload": config.offload_build_target,
2526
}
2627
config.target_to_triple = {
2728
"target-spir": "spir64",
@@ -683,6 +684,7 @@ def remove_level_zero_suffix(devices):
683684
"level_zero": "gpu",
684685
"hip": "gpu",
685686
"native_cpu": "cpu",
687+
"offload": "gpu",
686688
}
687689
for d in remove_level_zero_suffix(config.sycl_devices):
688690
be, dev = d.split(":")

sycl/test-e2e/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ config.cuda_libs_dir = "@CUDA_LIBS_DIR@"
3434
config.cuda_include = "@CUDA_INCLUDE@"
3535
config.hip_libs_dir = "@HIP_LIBS_DIR@"
3636
config.hip_include = "@HIP_INCLUDE@"
37+
config.offload_build_target = "@OFFLOAD_BUILD_TARGET@"
3738

3839
config.opencl_include_dir = os.path.join(config.sycl_include, 'sycl')
3940

unified-runtime/source/adapters/offload/device.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
6767
case UR_DEVICE_INFO_PLATFORM:
6868
return ReturnValue(hDevice->Platform);
6969
break;
70+
case UR_DEVICE_INFO_USM_DEVICE_SUPPORT:
71+
case UR_DEVICE_INFO_USM_HOST_SUPPORT:
7072
case UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT:
7173
return ReturnValue(UR_DEVICE_USM_ACCESS_CAPABILITY_FLAG_ACCESS);
7274
case UR_DEVICE_INFO_BUILD_ON_SUBDEVICE:
@@ -78,19 +80,35 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
7880
return ReturnValue(uint32_t{3});
7981
case UR_DEVICE_INFO_COMPILER_AVAILABLE:
8082
return ReturnValue(true);
83+
case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL:
84+
// TODO: Implement subgroups in Offload
85+
return ReturnValue(1);
8186
// Unimplemented features
8287
case UR_DEVICE_INFO_PROGRAM_SET_SPECIALIZATION_CONSTANTS:
8388
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
8489
case UR_DEVICE_INFO_USM_POOL_SUPPORT:
8590
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
8691
case UR_DEVICE_INFO_IMAGE_SUPPORT:
8792
case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT:
93+
case UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT:
94+
// TODO: Atomic queries in Offload
95+
case UR_DEVICE_INFO_ATOMIC_64:
96+
case UR_DEVICE_INFO_IMAGE_SRGB:
97+
case UR_DEVICE_INFO_HOST_UNIFIED_MEMORY:
98+
case UR_DEVICE_INFO_LINKER_AVAILABLE:
8899
return ReturnValue(false);
89100
case UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT:
90-
case UR_DEVICE_INFO_USM_DEVICE_SUPPORT:
91-
case UR_DEVICE_INFO_USM_HOST_SUPPORT:
92101
case UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT:
93102
return ReturnValue(uint32_t{0});
103+
case UR_DEVICE_INFO_QUEUE_PROPERTIES:
104+
case UR_DEVICE_INFO_KERNEL_LAUNCH_CAPABILITIES:
105+
return ReturnValue(0);
106+
case UR_DEVICE_INFO_SUPPORTED_PARTITIONS: {
107+
if (pPropSizeRet) {
108+
*pPropSizeRet = 0;
109+
}
110+
return UR_RESULT_SUCCESS;
111+
}
94112
default:
95113
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
96114
}

0 commit comments

Comments
 (0)