Skip to content

Commit 18ca120

Browse files
committed
Add DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT device info query.
This gates support for the EnqueueDeviceGlobalVariableRead and Write operations. The CTS tests for these now check for support before running, and all adapters report their support correctly.
1 parent feecd11 commit 18ca120

File tree

9 files changed

+42
-0
lines changed

9 files changed

+42
-0
lines changed

include/ur_api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,9 @@ typedef enum ur_device_info_t {
15341534
///< this composite device.
15351535
UR_DEVICE_INFO_COMPOSITE_DEVICE = 117, ///< [::ur_device_handle_t] The composite device containing this component
15361536
///< device.
1537+
UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 118, ///< [::ur_bool_t] return true if the device supports the
1538+
///< `EnqueueDeviceGlobalVariableWrite` and
1539+
///< `EnqueueDeviceGlobalVariableRead` entry points.
15371540
UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP = 0x2000, ///< [::ur_bool_t] returns true if the device supports the creation of
15381541
///< bindless images
15391542
UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP = 0x2001, ///< [::ur_bool_t] returns true if the device supports the creation of

include/ur_print.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,6 +2407,9 @@ inline std::ostream &operator<<(std::ostream &os, ur_device_info_t value) {
24072407
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
24082408
os << "UR_DEVICE_INFO_COMPOSITE_DEVICE";
24092409
break;
2410+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
2411+
os << "UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT";
2412+
break;
24102413
case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP:
24112414
os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP";
24122415
break;
@@ -3843,6 +3846,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info
38433846

38443847
os << ")";
38453848
} break;
3849+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
3850+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
3851+
if (sizeof(ur_bool_t) > size) {
3852+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
3853+
return UR_RESULT_ERROR_INVALID_SIZE;
3854+
}
3855+
os << (const void *)(tptr) << " (";
3856+
3857+
os << *tptr;
3858+
3859+
os << ")";
3860+
} break;
38463861
case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP: {
38473862
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
38483863
if (sizeof(ur_bool_t) > size) {

scripts/core/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ etors:
400400
desc: "[$x_device_handle_t[]] The set of component devices contained by this composite device."
401401
- name: COMPOSITE_DEVICE
402402
desc: "[$x_device_handle_t] The composite device containing this component device."
403+
- name: GLOBAL_VARIABLE_SUPPORT
404+
desc: "[$x_bool_t] return true if the device supports the `EnqueueDeviceGlobalVariableWrite` and `EnqueueDeviceGlobalVariableRead` entry points."
403405
--- #--------------------------------------------------------------------------
404406
type: function
405407
desc: "Retrieves various information about device"

source/adapters/cuda/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10261026
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
10271027
// These two are exclusive of L0.
10281028
return ReturnValue(0);
1029+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
1030+
return ReturnValue(true);
10291031
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
10301032
case UR_DEVICE_INFO_GPU_EU_COUNT:
10311033
case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH:

source/adapters/hip/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
830830
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
831831
return ReturnValue(false);
832832

833+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
834+
return ReturnValue(false);
833835
// TODO: Investigate if this information is available on HIP.
834836
case UR_DEVICE_INFO_GPU_EU_COUNT:
835837
case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH:

source/adapters/level_zero/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
917917
}
918918
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
919919
return ReturnValue(false);
920+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
921+
return ReturnValue(true);
920922

921923
default:
922924
urPrint("Unsupported ParamName in urGetDeviceInfo\n");

source/adapters/opencl/device.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
787787
{"cl_intel_program_scope_host_pipe"}, Supported));
788788
return ReturnValue(Supported);
789789
}
790+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
791+
bool Supported = false;
792+
CL_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
793+
cl_adapter::cast<cl_device_id>(hDevice),
794+
{"cl_intel_global_variable_access"}, Supported));
795+
return ReturnValue(Supported);
796+
}
790797
case UR_DEVICE_INFO_QUEUE_PROPERTIES:
791798
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES:
792799
case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES:

test/conformance/testing/include/uur/fixtures.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,13 @@ struct urGlobalVariableTest : uur::urKernelExecutionTest {
12711271
program_name = "device_global";
12721272
global_var = {"_Z7dev_var", 0};
12731273
UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp());
1274+
bool global_var_support = false;
1275+
ASSERT_SUCCESS(urDeviceGetInfo(
1276+
device, UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT,
1277+
sizeof(global_var_support), &global_var_support, nullptr));
1278+
if (!global_var_support) {
1279+
GTEST_SKIP() << "Global variable access is not supported";
1280+
}
12741281
}
12751282

12761283
GlobalVar<int> global_var;

tools/urinfo/urinfo.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ inline void printDeviceInfos(ur_device_handle_t hDevice,
329329
printDeviceInfo<ur_device_handle_t>(hDevice,
330330
UR_DEVICE_INFO_COMPOSITE_DEVICE);
331331
std::cout << prefix;
332+
printDeviceInfo<ur_bool_t>(hDevice, UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT);
333+
std::cout << prefix;
332334
printDeviceInfo<ur_bool_t>(hDevice,
333335
UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP);
334336
std::cout << prefix;

0 commit comments

Comments
 (0)