Skip to content

Commit 30d4f17

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 815ea0a commit 30d4f17

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
@@ -1595,6 +1595,9 @@ typedef enum ur_device_info_t {
15951595
///< this composite device.
15961596
UR_DEVICE_INFO_COMPOSITE_DEVICE = 117, ///< [::ur_device_handle_t] The composite device containing this component
15971597
///< device.
1598+
UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 118, ///< [::ur_bool_t] return true if the device supports the
1599+
///< `EnqueueDeviceGlobalVariableWrite` and
1600+
///< `EnqueueDeviceGlobalVariableRead` entry points.
15981601
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000, ///< [::ur_bool_t] Returns true if the device supports the use of
15991602
///< command-buffers.
16001603
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
@@ -2508,6 +2508,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
25082508
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
25092509
os << "UR_DEVICE_INFO_COMPOSITE_DEVICE";
25102510
break;
2511+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
2512+
os << "UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT";
2513+
break;
25112514
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
25122515
os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP";
25132516
break;
@@ -3986,6 +3989,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info
39863989

39873990
os << ")";
39883991
} break;
3992+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
3993+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
3994+
if (sizeof(ur_bool_t) > size) {
3995+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
3996+
return UR_RESULT_ERROR_INVALID_SIZE;
3997+
}
3998+
os << (const void *)(tptr) << " (";
3999+
4000+
os << *tptr;
4001+
4002+
os << ")";
4003+
} break;
39894004
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
39904005
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
39914006
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
@@ -1071,6 +1071,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10711071
return ReturnValue(true);
10721072
case UR_DEVICE_INFO_ESIMD_SUPPORT:
10731073
return ReturnValue(false);
1074+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
1075+
return ReturnValue(true);
10741076
case UR_DEVICE_INFO_COMPONENT_DEVICES:
10751077
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
10761078
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:

source/adapters/hip/device.cpp

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

887+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
888+
return ReturnValue(false);
887889
// TODO: Investigate if this information is available on HIP.
888890
case UR_DEVICE_INFO_COMPONENT_DEVICES:
889891
case UR_DEVICE_INFO_COMPOSITE_DEVICE:

source/adapters/level_zero/device.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
985985
case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP:
986986
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
987987
return ReturnValue(false);
988+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
989+
return ReturnValue(true);
990+
988991
default:
989992
logger::error("Unsupported ParamName in urGetDeviceInfo");
990993
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
@@ -1486,6 +1486,13 @@ struct urGlobalVariableTest : uur::urKernelExecutionTest {
14861486
UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY,
14871487
metadataData.size(), metadata_value});
14881488
UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp());
1489+
bool global_var_support = false;
1490+
ASSERT_SUCCESS(urDeviceGetInfo(
1491+
device, UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT,
1492+
sizeof(global_var_support), &global_var_support, nullptr));
1493+
if (!global_var_support) {
1494+
GTEST_SKIP() << "Global variable access is not supported";
1495+
}
14891496
}
14901497

14911498
/* 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)