Skip to content

Commit 062a500

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 e357abf commit 062a500

File tree

9 files changed

+43
-0
lines changed

9 files changed

+43
-0
lines changed

include/ur_api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,9 @@ typedef enum ur_device_info_t {
15901590
///< this composite device.
15911591
UR_DEVICE_INFO_COMPOSITE_DEVICE = 117, ///< [::ur_device_handle_t] The composite device containing this component
15921592
///< device.
1593+
UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 118, ///< [::ur_bool_t] return true if the device supports the
1594+
///< `EnqueueDeviceGlobalVariableWrite` and
1595+
///< `EnqueueDeviceGlobalVariableRead` entry points.
15931596
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000, ///< [::ur_bool_t] Returns true if the device supports the use of
15941597
///< command-buffers.
15951598
UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP = 0x1001, ///< [::ur_bool_t] Returns true if the device supports updating the kernel

include/ur_print.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,6 +2496,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
24962496
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
24972497
os << "UR_DEVICE_INFO_COMPOSITE_DEVICE";
24982498
break;
2499+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
2500+
os << "UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT";
2501+
break;
24992502
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
25002503
os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP";
25012504
break;
@@ -3974,6 +3977,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info
39743977

39753978
os << ")";
39763979
} break;
3980+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
3981+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
3982+
if (sizeof(ur_bool_t) > size) {
3983+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
3984+
return UR_RESULT_ERROR_INVALID_SIZE;
3985+
}
3986+
os << (const void *)(tptr) << " (";
3987+
3988+
os << *tptr;
3989+
3990+
os << ")";
3991+
} break;
39773992
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
39783993
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
39793994
if (sizeof(ur_bool_t) > size) {

scripts/core/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ etors:
439439
desc: "[$x_device_handle_t[]] The set of component devices contained by this composite device."
440440
- name: COMPOSITE_DEVICE
441441
desc: "[$x_device_handle_t] The composite device containing this component device."
442+
- name: GLOBAL_VARIABLE_SUPPORT
443+
desc: "[$x_bool_t] return true if the device supports the `EnqueueDeviceGlobalVariableWrite` and `EnqueueDeviceGlobalVariableRead` entry points."
442444
--- #--------------------------------------------------------------------------
443445
type: function
444446
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
@@ -1078,6 +1078,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10781078
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
10791079
// These two are exclusive of L0.
10801080
return ReturnValue(0);
1081+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
1082+
return ReturnValue(true);
10811083
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
10821084
case UR_DEVICE_INFO_GPU_EU_COUNT:
10831085
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
@@ -846,6 +846,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
846846
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
847847
return ReturnValue(false);
848848

849+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
850+
return ReturnValue(false);
849851
// TODO: Investigate if this information is available on HIP.
850852
case UR_DEVICE_INFO_GPU_EU_COUNT:
851853
case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH:

source/adapters/level_zero/device.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
970970
case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP:
971971
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
972972
return ReturnValue(false);
973+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
974+
return ReturnValue(true);
975+
973976
default:
974977
logger::error("Unsupported ParamName in urGetDeviceInfo");
975978
logger::error("ParamNameParamName={}(0x{})", ParamName,

source/adapters/opencl/device.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
809809
{"cl_intel_program_scope_host_pipe"}, Supported));
810810
return ReturnValue(Supported);
811811
}
812+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
813+
bool Supported = false;
814+
CL_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
815+
cl_adapter::cast<cl_device_id>(hDevice),
816+
{"cl_intel_global_variable_access"}, Supported));
817+
return ReturnValue(Supported);
818+
}
812819
case UR_DEVICE_INFO_QUEUE_PROPERTIES:
813820
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES:
814821
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
@@ -1481,6 +1481,13 @@ struct urGlobalVariableTest : uur::urKernelExecutionTest {
14811481
UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY,
14821482
metadataData.size(), metadata_value});
14831483
UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp());
1484+
bool global_var_support = false;
1485+
ASSERT_SUCCESS(urDeviceGetInfo(
1486+
device, UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT,
1487+
sizeof(global_var_support), &global_var_support, nullptr));
1488+
if (!global_var_support) {
1489+
GTEST_SKIP() << "Global variable access is not supported";
1490+
}
14841491
}
14851492

14861493
/* We pad the first 8 bytes of the metadata since they are ignored */

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_COMMAND_BUFFER_SUPPORT_EXP);
334336
std::cout << prefix;

0 commit comments

Comments
 (0)