Skip to content

Commit 4ef8441

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 8809587 commit 4ef8441

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
@@ -1589,6 +1589,9 @@ typedef enum ur_device_info_t {
15891589
///< this composite device.
15901590
UR_DEVICE_INFO_COMPOSITE_DEVICE = 117, ///< [::ur_device_handle_t] The composite device containing this component
15911591
///< device.
1592+
UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 118, ///< [::ur_bool_t] return true if the device supports the
1593+
///< `EnqueueDeviceGlobalVariableWrite` and
1594+
///< `EnqueueDeviceGlobalVariableRead` entry points.
15921595
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000, ///< [::ur_bool_t] Returns true if the device supports the use of
15931596
///< command-buffers.
15941597
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
@@ -2493,6 +2493,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
24932493
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
24942494
os << "UR_DEVICE_INFO_COMPOSITE_DEVICE";
24952495
break;
2496+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
2497+
os << "UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT";
2498+
break;
24962499
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
24972500
os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP";
24982501
break;
@@ -3968,6 +3971,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info
39683971

39693972
os << ")";
39703973
} break;
3974+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
3975+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
3976+
if (sizeof(ur_bool_t) > size) {
3977+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
3978+
return UR_RESULT_ERROR_INVALID_SIZE;
3979+
}
3980+
os << (const void *)(tptr) << " (";
3981+
3982+
os << *tptr;
3983+
3984+
os << ")";
3985+
} break;
39713986
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
39723987
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
39733988
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
@@ -1074,6 +1074,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10741074
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
10751075
// These two are exclusive of L0.
10761076
return ReturnValue(0);
1077+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
1078+
return ReturnValue(true);
10771079
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
10781080
case UR_DEVICE_INFO_GPU_EU_COUNT:
10791081
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
@@ -844,6 +844,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
844844
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
845845
return ReturnValue(false);
846846

847+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
848+
return ReturnValue(false);
847849
// TODO: Investigate if this information is available on HIP.
848850
case UR_DEVICE_INFO_GPU_EU_COUNT:
849851
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
@@ -967,6 +967,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
967967
case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP:
968968
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
969969
return ReturnValue(false);
970+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
971+
return ReturnValue(true);
972+
970973
default:
971974
logger::error("Unsupported ParamName in urGetDeviceInfo");
972975
logger::error("ParamNameParamName={}(0x{})", ParamName,

source/adapters/opencl/device.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
806806
{"cl_intel_program_scope_host_pipe"}, Supported));
807807
return ReturnValue(Supported);
808808
}
809+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
810+
bool Supported = false;
811+
CL_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
812+
cl_adapter::cast<cl_device_id>(hDevice),
813+
{"cl_intel_global_variable_access"}, Supported));
814+
return ReturnValue(Supported);
815+
}
809816
case UR_DEVICE_INFO_QUEUE_PROPERTIES:
810817
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES:
811818
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)