Skip to content

Commit 40cd6fa

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 646cc9c commit 40cd6fa

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
@@ -1597,6 +1597,9 @@ typedef enum ur_device_info_t {
15971597
///< this composite device.
15981598
UR_DEVICE_INFO_COMPOSITE_DEVICE = 117, ///< [::ur_device_handle_t] The composite device containing this component
15991599
///< device.
1600+
UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 118, ///< [::ur_bool_t] return true if the device supports the
1601+
///< `EnqueueDeviceGlobalVariableWrite` and
1602+
///< `EnqueueDeviceGlobalVariableRead` entry points.
16001603
UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000, ///< [::ur_bool_t] Returns true if the device supports the use of
16011604
///< command-buffers.
16021605
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
@@ -2524,6 +2524,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) {
25242524
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
25252525
os << "UR_DEVICE_INFO_COMPOSITE_DEVICE";
25262526
break;
2527+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
2528+
os << "UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT";
2529+
break;
25272530
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP:
25282531
os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP";
25292532
break;
@@ -4008,6 +4011,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info
40084011

40094012
os << ")";
40104013
} break;
4014+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
4015+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
4016+
if (sizeof(ur_bool_t) > size) {
4017+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
4018+
return UR_RESULT_ERROR_INVALID_SIZE;
4019+
}
4020+
os << (const void *)(tptr) << " (";
4021+
4022+
os << *tptr;
4023+
4024+
os << ")";
4025+
} break;
40114026
case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: {
40124027
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
40134028
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
@@ -1075,6 +1075,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10751075
return ReturnValue(true);
10761076
case UR_DEVICE_INFO_ESIMD_SUPPORT:
10771077
return ReturnValue(false);
1078+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
1079+
return ReturnValue(true);
10781080
case UR_DEVICE_INFO_COMPONENT_DEVICES:
10791081
case UR_DEVICE_INFO_COMPOSITE_DEVICE:
10801082
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
@@ -886,6 +886,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
886886
return ReturnValue(true);
887887
}
888888

889+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
890+
return ReturnValue(false);
889891
// TODO: Investigate if this information is available on HIP.
890892
case UR_DEVICE_INFO_COMPONENT_DEVICES:
891893
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
@@ -989,6 +989,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
989989
case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP:
990990
case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS:
991991
return ReturnValue(false);
992+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
993+
return ReturnValue(true);
994+
992995
default:
993996
logger::error("Unsupported ParamName in urGetDeviceInfo");
994997
logger::error("ParamNameParamName={}(0x{})", ParamName,

source/adapters/opencl/device.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
812812
{"cl_intel_program_scope_host_pipe"}, Supported));
813813
return ReturnValue(Supported);
814814
}
815+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
816+
bool Supported = false;
817+
CL_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
818+
cl_adapter::cast<cl_device_id>(hDevice),
819+
{"cl_intel_global_variable_access"}, Supported));
820+
return ReturnValue(Supported);
821+
}
815822
case UR_DEVICE_INFO_QUEUE_PROPERTIES:
816823
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES:
817824
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)