diff --git a/include/ur_api.h b/include/ur_api.h index 3205fcb207..367113871d 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -1486,7 +1486,7 @@ urDeviceGetSelected( typedef enum ur_device_info_t { UR_DEVICE_INFO_TYPE = 0, ///< [::ur_device_type_t] type of the device UR_DEVICE_INFO_VENDOR_ID = 1, ///< [uint32_t] vendor Id of the device - UR_DEVICE_INFO_DEVICE_ID = 2, ///< [uint32_t] Id of the device + UR_DEVICE_INFO_DEVICE_ID = 2, ///< [uint32_t][optional-query] Id of the device UR_DEVICE_INFO_MAX_COMPUTE_UNITS = 3, ///< [uint32_t] the number of compute units UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS = 4, ///< [uint32_t] max work item dimensions UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES = 5, ///< [size_t[]] return an array of max work item sizes @@ -1513,7 +1513,7 @@ typedef enum ur_device_info_t { UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE = 23, ///< [uint32_t] native vector width for double UR_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF = 24, ///< [uint32_t] native vector width for half float UR_DEVICE_INFO_MAX_CLOCK_FREQUENCY = 25, ///< [uint32_t] max clock frequency in MHz - UR_DEVICE_INFO_MEMORY_CLOCK_RATE = 26, ///< [uint32_t] memory clock frequency in MHz + UR_DEVICE_INFO_MEMORY_CLOCK_RATE = 26, ///< [uint32_t][optional-query] memory clock frequency in MHz UR_DEVICE_INFO_ADDRESS_BITS = 27, ///< [uint32_t] address bits UR_DEVICE_INFO_MAX_MEM_ALLOC_SIZE = 28, ///< [uint64_t] max memory allocation size UR_DEVICE_INFO_IMAGE_SUPPORTED = 29, ///< [::ur_bool_t] images are supported @@ -1537,7 +1537,8 @@ typedef enum ur_device_info_t { UR_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE = 44, ///< [uint32_t] global memory cache line size in bytes UR_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE = 45, ///< [uint64_t] size of global memory cache in bytes UR_DEVICE_INFO_GLOBAL_MEM_SIZE = 46, ///< [uint64_t] size of global memory in bytes - UR_DEVICE_INFO_GLOBAL_MEM_FREE = 47, ///< [uint64_t] size of global memory which is free in bytes + UR_DEVICE_INFO_GLOBAL_MEM_FREE = 47, ///< [uint64_t][optional-query] size of global memory which is free in + ///< bytes UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE = 48, ///< [uint64_t] max constant buffer size in bytes UR_DEVICE_INFO_MAX_CONSTANT_ARGS = 49, ///< [uint32_t] max number of __const declared arguments in a kernel UR_DEVICE_INFO_LOCAL_MEM_TYPE = 50, ///< [::ur_device_local_mem_type_t] local memory type @@ -1594,15 +1595,16 @@ typedef enum ur_device_info_t { ///< shared memory access UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT = 87, ///< [::ur_device_usm_access_capability_flags_t] support USM system wide ///< shared memory access - UR_DEVICE_INFO_UUID = 88, ///< [uint8_t[]] return device UUID - UR_DEVICE_INFO_PCI_ADDRESS = 89, ///< [char[]] return device PCI address - UR_DEVICE_INFO_GPU_EU_COUNT = 90, ///< [uint32_t] return Intel GPU EU count - UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 91, ///< [uint32_t] return Intel GPU EU SIMD width - UR_DEVICE_INFO_GPU_EU_SLICES = 92, ///< [uint32_t] return Intel GPU number of slices - UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE = 93, ///< [uint32_t] return Intel GPU EU count per subslice - UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE = 94, ///< [uint32_t] return Intel GPU number of subslices per slice - UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 95, ///< [uint32_t] return Intel GPU number of threads per EU - UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96, ///< [uint32_t] return max memory bandwidth in Mb/s + UR_DEVICE_INFO_UUID = 88, ///< [uint8_t[]][optional-query] return device UUID + UR_DEVICE_INFO_PCI_ADDRESS = 89, ///< [char[]][optional-query] return device PCI address + UR_DEVICE_INFO_GPU_EU_COUNT = 90, ///< [uint32_t][optional-query] return Intel GPU EU count + UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH = 91, ///< [uint32_t][optional-query] return Intel GPU EU SIMD width + UR_DEVICE_INFO_GPU_EU_SLICES = 92, ///< [uint32_t][optional-query] return Intel GPU number of slices + UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE = 93, ///< [uint32_t][optional-query] return Intel GPU EU count per subslice + UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE = 94, ///< [uint32_t][optional-query] return Intel GPU number of subslices per + ///< slice + UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU = 95, ///< [uint32_t][optional-query] return Intel GPU number of threads per EU + UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH = 96, ///< [uint32_t][optional-query] return max memory bandwidth in Mb/s UR_DEVICE_INFO_IMAGE_SRGB = 97, ///< [::ur_bool_t] device supports sRGB images UR_DEVICE_INFO_BUILD_ON_SUBDEVICE = 98, ///< [::ur_bool_t] Return true if sub-device should do its own program ///< build @@ -1621,17 +1623,18 @@ typedef enum ur_device_info_t { ///< available for this device. UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS = 106, ///< [::ur_bool_t] support the ::urKernelSetSpecializationConstants entry ///< point - UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [uint32_t] return the width in bits of the memory bus interface of the - ///< device. + UR_DEVICE_INFO_MEMORY_BUS_WIDTH = 107, ///< [uint32_t][optional-query] return the width in bits of the memory bus + ///< interface of the device. UR_DEVICE_INFO_MAX_WORK_GROUPS_3D = 108, ///< [size_t[3]] return max 3D work groups UR_DEVICE_INFO_ASYNC_BARRIER = 109, ///< [::ur_bool_t] return true if Async Barrier is supported UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT = 110, ///< [::ur_bool_t] return true if specifying memory channels is supported UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED = 111, ///< [::ur_bool_t] Return true if the device supports enqueueing commands ///< to read and write pipes from the host. - UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 112, ///< [uint32_t] The maximum number of registers available per block. - UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t] The device IP version. The meaning of the device IP version - ///< is implementation-defined, but newer devices should have a higher - ///< version than older devices. + UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 112, ///< [uint32_t][optional-query] The maximum number of registers available + ///< per block. + UR_DEVICE_INFO_IP_VERSION = 113, ///< [uint32_t][optional-query] The device IP version. The meaning of the + ///< device IP version is implementation-defined, but newer devices should + ///< have a higher version than older devices. UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT = 114, ///< [::ur_bool_t] return true if the device supports virtual memory. UR_DEVICE_INFO_ESIMD_SUPPORT = 115, ///< [::ur_bool_t] return true if the device supports ESIMD. UR_DEVICE_INFO_COMPONENT_DEVICES = 116, ///< [::ur_device_handle_t[]] The set of component devices contained by @@ -2281,15 +2284,15 @@ typedef enum ur_context_info_t { ///< supported. UR_CONTEXT_INFO_USM_FILL2D_SUPPORT = 4, ///< [::ur_bool_t] to indicate if the ::urEnqueueUSMFill2D entrypoint is ///< supported. - UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 5, ///< [::ur_memory_order_capability_flags_t] return a bit-field of atomic - ///< memory order capabilities. - UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 6, ///< [::ur_memory_scope_capability_flags_t] return a bit-field of atomic - ///< memory scope capabilities. - UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES = 7, ///< [::ur_memory_order_capability_flags_t] return a bit-field of atomic - ///< memory fence order capabilities. + UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 5, ///< [::ur_memory_order_capability_flags_t][optional-query] return a + ///< bit-field of atomic memory order capabilities. + UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 6, ///< [::ur_memory_scope_capability_flags_t][optional-query] return a + ///< bit-field of atomic memory scope capabilities. + UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES = 7, ///< [::ur_memory_order_capability_flags_t][optional-query] return a + ///< bit-field of atomic memory fence order capabilities. ///< Zero is returned if the backend does not support context-level fences. - UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES = 8, ///< [::ur_memory_scope_capability_flags_t] return a bit-field of atomic - ///< memory fence scope capabilities. + UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES = 8, ///< [::ur_memory_scope_capability_flags_t][optional-query] return a + ///< bit-field of atomic memory fence scope capabilities. ///< Zero is returned if the backend does not support context-level fences. /// @cond UR_CONTEXT_INFO_FORCE_UINT32 = 0x7fffffff @@ -3386,7 +3389,7 @@ typedef enum ur_usm_alloc_info_t { UR_USM_ALLOC_INFO_BASE_PTR = 1, ///< [void *] Memory allocation base pointer info UR_USM_ALLOC_INFO_SIZE = 2, ///< [size_t] Memory allocation size info UR_USM_ALLOC_INFO_DEVICE = 3, ///< [::ur_device_handle_t] Memory allocation device info - UR_USM_ALLOC_INFO_POOL = 4, ///< [::ur_usm_pool_handle_t] Memory allocation pool info + UR_USM_ALLOC_INFO_POOL = 4, ///< [::ur_usm_pool_handle_t][optional-query] Memory allocation pool info /// @cond UR_USM_ALLOC_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -4527,9 +4530,10 @@ typedef enum ur_program_info_t { UR_PROGRAM_INFO_BINARY_SIZES = 5, ///< [size_t[]] Return program binary sizes for each device. UR_PROGRAM_INFO_BINARIES = 6, ///< [unsigned char[]] Return program binaries for all devices for this ///< Program. - UR_PROGRAM_INFO_NUM_KERNELS = 7, ///< [size_t] Number of kernels in Program, return type size_t. - UR_PROGRAM_INFO_KERNEL_NAMES = 8, ///< [char[]] Return a null-terminated, semi-colon separated list of kernel - ///< names in Program. + UR_PROGRAM_INFO_NUM_KERNELS = 7, ///< [size_t][optional-query] Number of kernels in Program, return type + ///< size_t. + UR_PROGRAM_INFO_KERNEL_NAMES = 8, ///< [char[]][optional-query] Return a null-terminated, semi-colon + ///< separated list of kernel names in Program. /// @cond UR_PROGRAM_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -4880,8 +4884,8 @@ typedef enum ur_kernel_info_t { UR_KERNEL_INFO_CONTEXT = 3, ///< [::ur_context_handle_t] Return Context object associated with Kernel. UR_KERNEL_INFO_PROGRAM = 4, ///< [::ur_program_handle_t] Return Program object associated with Kernel. UR_KERNEL_INFO_ATTRIBUTES = 5, ///< [char[]] Return null-terminated kernel attributes string. - UR_KERNEL_INFO_NUM_REGS = 6, ///< [uint32_t] Return the number of registers used by the compiled kernel - ///< (device specific). + UR_KERNEL_INFO_NUM_REGS = 6, ///< [uint32_t][optional-query] Return the number of registers used by the + ///< compiled kernel. /// @cond UR_KERNEL_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -4891,7 +4895,7 @@ typedef enum ur_kernel_info_t { /////////////////////////////////////////////////////////////////////////////// /// @brief Get Kernel Work Group information typedef enum ur_kernel_group_info_t { - UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE = 0, ///< [size_t[3]] Return Work Group maximum global size + UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE = 0, ///< [size_t[3]][optional-query] Return Work Group maximum global size UR_KERNEL_GROUP_INFO_WORK_GROUP_SIZE = 1, ///< [size_t] Return maximum Work Group size UR_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE = 2, ///< [size_t[3]] Return Work Group size required by the source code, such ///< as __attribute__((required_work_group_size(X,Y,Z)), or (0, 0, 0) if @@ -4900,10 +4904,10 @@ typedef enum ur_kernel_group_info_t { UR_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 4, ///< [size_t] Return preferred multiple of Work Group size for launch UR_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE = 5, ///< [size_t] Return minimum amount of private memory in bytes used by each ///< work item in the Kernel - UR_KERNEL_GROUP_INFO_COMPILE_MAX_WORK_GROUP_SIZE = 6, ///< [size_t[3]] Return the maximum Work Group size guaranteed by the - ///< source code, or (0, 0, 0) if unspecified - UR_KERNEL_GROUP_INFO_COMPILE_MAX_LINEAR_WORK_GROUP_SIZE = 7, ///< [size_t] Return the maximum linearized Work Group size (X * Y * Z) - ///< guaranteed by the source code, or 0 if unspecified + UR_KERNEL_GROUP_INFO_COMPILE_MAX_WORK_GROUP_SIZE = 6, ///< [size_t[3]][optional-query] Return the maximum Work Group size guaranteed + ///< by the source code, or (0, 0, 0) if unspecified + UR_KERNEL_GROUP_INFO_COMPILE_MAX_LINEAR_WORK_GROUP_SIZE = 7, ///< [size_t][optional-query] Return the maximum linearized Work Group size + ///< (X * Y * Z) guaranteed by the source code, or 0 if unspecified /// @cond UR_KERNEL_GROUP_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -5422,8 +5426,8 @@ typedef enum ur_queue_info_t { UR_QUEUE_INFO_SIZE = 5, ///< [uint32_t] The size of the queue on the device. Only a valid query ///< if the queue was created with the `ON_DEVICE` queue flag, otherwise ///< `::urQueueGetInfo` will return `::UR_RESULT_ERROR_INVALID_QUEUE`. - UR_QUEUE_INFO_EMPTY = 6, ///< [::ur_bool_t] return true if the queue was empty at the time of the - ///< query + UR_QUEUE_INFO_EMPTY = 6, ///< [::ur_bool_t][optional-query] return true if the queue was empty at + ///< the time of the query. /// @cond UR_QUEUE_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond diff --git a/scripts/YaML.md b/scripts/YaML.md index 2ab5dd80b2..3679bdec8e 100644 --- a/scripts/YaML.md +++ b/scripts/YaML.md @@ -336,6 +336,7 @@ plural form *enumerators* is abbreviated to `etors`. - An etor requires the following scalar fields: {`name`, `desc`} + `desc` will be used as the etors's description comment + If the enum has `typed_etors`, `desc` must begin with type identifier: {`"[type]"`} + + `desc` may contain the [optional-query] annotation. This denotes the etor as an info query which is optional for adapters to implement, and may legally result in a non-success error code. + `name` must be a unique ISO-C standard identifier, and be all caps - An etor may take the following optional scalar field: {`value`, `version`} + `value` must be an ISO-C standard identifier diff --git a/scripts/core/PROG.rst b/scripts/core/PROG.rst index ea0445cb60..54123bbc1f 100644 --- a/scripts/core/PROG.rst +++ b/scripts/core/PROG.rst @@ -183,6 +183,24 @@ explicitly created against a context. // Release the context handle ${x}ContextRelease(hContext); +Object Queries +============== + +Queries to get information from API objects follow a common pattern. The entry +points for this are generally of the form: + +.. code-block:: + + ObjectGetInfo(ur_object_handle_t hObject, ur_object_info_t propName, + size_t propSize, void *pPropValue, size_t *pPropSizeRet) + +where ``propName`` selects the information to query out. The object info enum +representing possible queries will generally be found in the enums section of +the relevant object. Some info queries would be difficult or impossible to +support for certain backends, these are denoted with [optional-query] in the +enum description. Using any enum marked optional in this way may result in +${X}_RESULT_ERROR_UNSUPPORTED_ENUMERATION if the adapter doesn't support it. + Programs and Kernels ==================== diff --git a/scripts/core/context.yml b/scripts/core/context.yml index e45c93010d..9b316a21a7 100644 --- a/scripts/core/context.yml +++ b/scripts/core/context.yml @@ -102,16 +102,16 @@ etors: - name: USM_FILL2D_SUPPORT desc: "[$x_bool_t] to indicate if the $xEnqueueUSMFill2D entrypoint is supported." - name: ATOMIC_MEMORY_ORDER_CAPABILITIES - desc: "[$x_memory_order_capability_flags_t] return a bit-field of atomic memory order capabilities." + desc: "[$x_memory_order_capability_flags_t][optional-query] return a bit-field of atomic memory order capabilities." - name: ATOMIC_MEMORY_SCOPE_CAPABILITIES - desc: "[$x_memory_scope_capability_flags_t] return a bit-field of atomic memory scope capabilities." + desc: "[$x_memory_scope_capability_flags_t][optional-query] return a bit-field of atomic memory scope capabilities." - name: ATOMIC_FENCE_ORDER_CAPABILITIES desc: | - [$x_memory_order_capability_flags_t] return a bit-field of atomic memory fence order capabilities. + [$x_memory_order_capability_flags_t][optional-query] return a bit-field of atomic memory fence order capabilities. Zero is returned if the backend does not support context-level fences. - name: ATOMIC_FENCE_SCOPE_CAPABILITIES desc: | - [$x_memory_scope_capability_flags_t] return a bit-field of atomic memory fence scope capabilities. + [$x_memory_scope_capability_flags_t][optional-query] return a bit-field of atomic memory fence scope capabilities. Zero is returned if the backend does not support context-level fences. --- #-------------------------------------------------------------------------- type: function diff --git a/scripts/core/device.yml b/scripts/core/device.yml index c430ff0b36..621b134939 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -200,7 +200,7 @@ etors: - name: VENDOR_ID desc: "[uint32_t] vendor Id of the device" - name: DEVICE_ID - desc: "[uint32_t] Id of the device" + desc: "[uint32_t][optional-query] Id of the device" - name: MAX_COMPUTE_UNITS desc: "[uint32_t] the number of compute units" - name: MAX_WORK_ITEM_DIMENSIONS @@ -248,7 +248,7 @@ etors: - name: MAX_CLOCK_FREQUENCY desc: "[uint32_t] max clock frequency in MHz" - name: MEMORY_CLOCK_RATE - desc: "[uint32_t] memory clock frequency in MHz" + desc: "[uint32_t][optional-query] memory clock frequency in MHz" - name: ADDRESS_BITS desc: "[uint32_t] address bits" - name: MAX_MEM_ALLOC_SIZE @@ -290,7 +290,7 @@ etors: - name: GLOBAL_MEM_SIZE desc: "[uint64_t] size of global memory in bytes" - name: GLOBAL_MEM_FREE - desc: "[uint64_t] size of global memory which is free in bytes" + desc: "[uint64_t][optional-query] size of global memory which is free in bytes" - name: MAX_CONSTANT_BUFFER_SIZE desc: "[uint64_t] max constant buffer size in bytes" - name: MAX_CONSTANT_ARGS @@ -377,23 +377,23 @@ etors: - name: USM_SYSTEM_SHARED_SUPPORT desc: "[$x_device_usm_access_capability_flags_t] support USM system wide shared memory access" - name: UUID - desc: "[uint8_t[]] return device UUID" + desc: "[uint8_t[]][optional-query] return device UUID" - name: PCI_ADDRESS - desc: "[char[]] return device PCI address" + desc: "[char[]][optional-query] return device PCI address" - name: GPU_EU_COUNT - desc: "[uint32_t] return Intel GPU EU count" + desc: "[uint32_t][optional-query] return Intel GPU EU count" - name: GPU_EU_SIMD_WIDTH - desc: "[uint32_t] return Intel GPU EU SIMD width" + desc: "[uint32_t][optional-query] return Intel GPU EU SIMD width" - name: GPU_EU_SLICES - desc: "[uint32_t] return Intel GPU number of slices" + desc: "[uint32_t][optional-query] return Intel GPU number of slices" - name: GPU_EU_COUNT_PER_SUBSLICE - desc: "[uint32_t] return Intel GPU EU count per subslice" + desc: "[uint32_t][optional-query] return Intel GPU EU count per subslice" - name: GPU_SUBSLICES_PER_SLICE - desc: "[uint32_t] return Intel GPU number of subslices per slice" + desc: "[uint32_t][optional-query] return Intel GPU number of subslices per slice" - name: GPU_HW_THREADS_PER_EU - desc: "[uint32_t] return Intel GPU number of threads per EU" + desc: "[uint32_t][optional-query] return Intel GPU number of threads per EU" - name: MAX_MEMORY_BANDWIDTH - desc: "[uint32_t] return max memory bandwidth in Mb/s" + desc: "[uint32_t][optional-query] return max memory bandwidth in Mb/s" - name: IMAGE_SRGB desc: "[$x_bool_t] device supports sRGB images" - name: BUILD_ON_SUBDEVICE @@ -418,7 +418,7 @@ etors: - name: KERNEL_SET_SPECIALIZATION_CONSTANTS desc: "[$x_bool_t] support the $xKernelSetSpecializationConstants entry point" - name: MEMORY_BUS_WIDTH - desc: "[uint32_t] return the width in bits of the memory bus interface of the device." + desc: "[uint32_t][optional-query] return the width in bits of the memory bus interface of the device." - name: MAX_WORK_GROUPS_3D desc: "[size_t[3]] return max 3D work groups" - name: ASYNC_BARRIER @@ -428,9 +428,9 @@ etors: - name: HOST_PIPE_READ_WRITE_SUPPORTED desc: "[$x_bool_t] Return true if the device supports enqueueing commands to read and write pipes from the host." - name: MAX_REGISTERS_PER_WORK_GROUP - desc: "[uint32_t] The maximum number of registers available per block." + desc: "[uint32_t][optional-query] The maximum number of registers available per block." - name: IP_VERSION - desc: "[uint32_t] The device IP version. The meaning of the device IP version is implementation-defined, but newer devices should have a higher version than older devices." + desc: "[uint32_t][optional-query] The device IP version. The meaning of the device IP version is implementation-defined, but newer devices should have a higher version than older devices." - name: VIRTUAL_MEMORY_SUPPORT desc: "[$x_bool_t] return true if the device supports virtual memory." - name: ESIMD_SUPPORT diff --git a/scripts/core/kernel.yml b/scripts/core/kernel.yml index 5bd95e1847..6ffa9ca5e0 100644 --- a/scripts/core/kernel.yml +++ b/scripts/core/kernel.yml @@ -124,7 +124,7 @@ etors: - name: ATTRIBUTES desc: "[char[]] Return null-terminated kernel attributes string." - name: NUM_REGS - desc: "[uint32_t] Return the number of registers used by the compiled kernel (device specific)." + desc: "[uint32_t][optional-query] Return the number of registers used by the compiled kernel." --- #-------------------------------------------------------------------------- type: enum desc: "Get Kernel Work Group information" @@ -133,7 +133,7 @@ name: $x_kernel_group_info_t typed_etors: True etors: - name: GLOBAL_WORK_SIZE - desc: "[size_t[3]] Return Work Group maximum global size" + desc: "[size_t[3]][optional-query] Return Work Group maximum global size" - name: WORK_GROUP_SIZE desc: "[size_t] Return maximum Work Group size" - name: COMPILE_WORK_GROUP_SIZE @@ -146,12 +146,12 @@ etors: desc: "[size_t] Return minimum amount of private memory in bytes used by each work item in the Kernel" - name: COMPILE_MAX_WORK_GROUP_SIZE desc: | - [size_t[3]] Return the maximum Work Group size guaranteed by the - source code, or (0, 0, 0) if unspecified + [size_t[3]][optional-query] Return the maximum Work Group size guaranteed + by the source code, or (0, 0, 0) if unspecified - name: COMPILE_MAX_LINEAR_WORK_GROUP_SIZE desc: | - [size_t] Return the maximum linearized Work Group size (X * Y * Z) - guaranteed by the source code, or 0 if unspecified + [size_t][optional-query] Return the maximum linearized Work Group size + (X * Y * Z) guaranteed by the source code, or 0 if unspecified --- #-------------------------------------------------------------------------- type: enum desc: "Get Kernel SubGroup information" diff --git a/scripts/core/program.yml b/scripts/core/program.yml index 769a312f1d..0449a58d6d 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -387,9 +387,9 @@ etors: - name: BINARIES desc: "[unsigned char[]] Return program binaries for all devices for this Program." - name: NUM_KERNELS - desc: "[size_t] Number of kernels in Program, return type size_t." + desc: "[size_t][optional-query] Number of kernels in Program, return type size_t." - name: KERNEL_NAMES - desc: "[char[]] Return a null-terminated, semi-colon separated list of kernel names in Program." + desc: "[char[]][optional-query] Return a null-terminated, semi-colon separated list of kernel names in Program." --- #-------------------------------------------------------------------------- type: function desc: "Query information about a Program object" diff --git a/scripts/core/queue.yml b/scripts/core/queue.yml index c8a6528fbd..cd8bd2668e 100644 --- a/scripts/core/queue.yml +++ b/scripts/core/queue.yml @@ -37,7 +37,7 @@ etors: if the queue was created with the `ON_DEVICE` queue flag, otherwise `$xQueueGetInfo` will return `$X_RESULT_ERROR_INVALID_QUEUE`. - name: EMPTY - desc: "[$x_bool_t] return true if the queue was empty at the time of the query" + desc: "[$x_bool_t][optional-query] return true if the queue was empty at the time of the query." --- #-------------------------------------------------------------------------- type: enum desc: "Queue property flags" diff --git a/scripts/core/usm.yml b/scripts/core/usm.yml index 77d5b7260a..c6b406918c 100644 --- a/scripts/core/usm.yml +++ b/scripts/core/usm.yml @@ -74,7 +74,7 @@ etors: - name: DEVICE desc: "[$x_device_handle_t] Memory allocation device info" - name: POOL - desc: "[$x_usm_pool_handle_t] Memory allocation pool info" + desc: "[$x_usm_pool_handle_t][optional-query] Memory allocation pool info" --- #-------------------------------------------------------------------------- type: enum desc: "USM memory advice" diff --git a/scripts/generate_code.py b/scripts/generate_code.py index 0c7476ab42..cdc3dfa229 100644 --- a/scripts/generate_code.py +++ b/scripts/generate_code.py @@ -548,3 +548,24 @@ def generate_level_zero_queue_api(path, section, namespace, tags, version, specs specs=specs, meta=meta) print("QUEUE Generated %s lines of code.\n" % loc) + +""" +Entry-point: + generates headers used by the CTS, for example containing meta-information + about info query enums +""" +def generate_cts_headers(path, section, namespace, tags, version, specs, meta): + template = "optional_queries.h.mako" + fin = os.path.join("templates", template) + name = "optional_queries" + filename = "optional_queries.h" + dstpath = os.path.join(path, "conformance", "testing", "include", "uur") + fout = os.path.join(dstpath, filename) + + print("Generating %s..." % fout) + + loc = util.makoWrite(fin, fout, + filename = name, namespace = namespace, + tags = tags, specs = specs, meta = meta) + + print("CTS Generated %s lines of code.\n" % loc) diff --git a/scripts/json2src.py b/scripts/json2src.py index df11f879ac..baff735d89 100755 --- a/scripts/json2src.py +++ b/scripts/json2src.py @@ -32,6 +32,7 @@ def add_argument(parser, name, help, default=False): add_argument(parser, "common", "generation of common files.", True) add_argument(parser, "tools", "generation of common files.", True) add_argument(parser, "l0_queue", "generation of l0 queue abstractions.", True) + add_argument(parser, "cts", "generation of cts headers", True) parser.add_argument("--debug", action='store_true', help="dump intermediate data to disk.") parser.add_argument("--sections", type=list, default=None, help="Optional list of sections for which to generate source, default is all") parser.add_argument("--ver", type=str, default="1.0", help="specification version to generate.") @@ -45,6 +46,7 @@ def add_argument(parser, name, help, default=False): srcpath = os.path.join(args.out_dir, "source") toolspath = os.path.join(args.out_dir, "tools") + testpath = os.path.join(args.out_dir, "test") for idx, specs in enumerate(input['specs']): config = input['configs'][idx] @@ -63,6 +65,8 @@ def add_argument(parser, name, help, default=False): generate_code.generate_tools(toolspath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta']) if args.l0_queue: generate_code.generate_level_zero_queue_api(srcpath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta']) + if args.cts: + generate_code.generate_cts_headers(testpath, config['name'], config['namespace'], config['tags'], args.ver, specs, input['meta']) if args.debug: util.makoFileListWrite("generated.json") diff --git a/scripts/templates/helper.py b/scripts/templates/helper.py index 9c08f8be11..b0f8ec13d1 100644 --- a/scripts/templates/helper.py +++ b/scripts/templates/helper.py @@ -541,6 +541,18 @@ def is_global(item, tags): except: return False +""" + Extracts traits from an enumerator +""" +class etor_traits: + RE_OPTIONAL_QUERY = r".*\[optional-query\].*" + + @classmethod + def is_optional_query(cls, item): + try: + return True if re.match(cls.RE_OPTIONAL_QUERY, item['desc']) else False + except: + return False """ Public: @@ -780,7 +792,7 @@ def make_etor_name(namespace, tags, enum, etor, meta=None): returns the associated type of an etor from a typed enum """ def etor_get_associated_type(namespace, tags, item): - match = re.match(r'^\[(.+)\]\s', item['desc']) + match = re.match(r'^\[([$A-Za-z0-9_*[\] ]+)\]', item['desc']) if match: associated_type = match.group(1) return subt(namespace, tags, associated_type) @@ -1692,3 +1704,24 @@ def transform_queue_related_function_name(namespace, tags, obj, format = ["name" params = params[1:] return "{}({})".format(function_name, ", ".join(params)) + +""" +Public: + Returns a dictionary mapping info enum types to the list of optional queries + within that enum. If an enum type doesn't have any optional queries it will + not appear in the dictionary as a key. +""" +def get_optional_queries(specs, namespace, tags): + optional_queries = {} + for s in specs: + for obj in s['objects']: + if obj['type'] == 'enum': + optional_etors = [] + for e in obj['etors']: + if etor_traits.is_optional_query(e): + name = make_enum_name(namespace, tags, e) + optional_etors.append(name) + if optional_etors: + type_name = make_type_name(namespace, tags, obj) + optional_queries[type_name] = optional_etors + return optional_queries diff --git a/scripts/templates/optional_queries.h.mako b/scripts/templates/optional_queries.h.mako new file mode 100644 index 0000000000..6dab60c884 --- /dev/null +++ b/scripts/templates/optional_queries.h.mako @@ -0,0 +1,45 @@ +<%! +import re +from templates import helper as th +%><% +optional_queries = th.get_optional_queries(specs, namespace, tags) +%>/* + * + * Copyright (C) 2024 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + * @file ${filename}.h + * + */ + + // Auto-generated file, do not edit. + +#pragma once + +#include +#include +#include + +namespace uur { + +template bool isQueryOptional(T) { return false; } + +%for type, names in optional_queries.items(): +constexpr std::array optional_${type} = { +%for name in names: + ${name}, +%endfor +}; + +template <> inline bool isQueryOptional(${type} query) { + return std::find(optional_${type}.begin(), + optional_${type}.end(), + query) != optional_${type}.end(); +} + +%endfor + +} diff --git a/scripts/templates/tools-info.hpp.mako b/scripts/templates/tools-info.hpp.mako index ed9d67bb34..cff5cb837f 100644 --- a/scripts/templates/tools-info.hpp.mako +++ b/scripts/templates/tools-info.hpp.mako @@ -32,8 +32,9 @@ namespace urinfo { inline void printLoaderConfigInfos(${x}_loader_config_handle_t hLoaderConfig, std::string_view prefix = " ") { %for etor in obj['etors']: %if 'REFERENCE_COUNT' not in etor['name']: - std::cout << prefix; - printLoaderConfigInfo<${etor['desc'][1:etor['desc'].find(' ')-1].replace('$x', x)}>(hLoaderConfig, ${etor['name'].replace('$X', X)}); + <%etype = th.etor_get_associated_type(n, tags, etor) + %>std::cout << prefix; + printLoaderConfigInfo<${etype}>(hLoaderConfig, ${etor['name'].replace('$X', X)}); %endif %endfor } @@ -42,8 +43,9 @@ inline void printLoaderConfigInfos(${x}_loader_config_handle_t hLoaderConfig, st inline void printAdapterInfos(${x}_adapter_handle_t hAdapter, std::string_view prefix = " ") { %for etor in obj['etors']: %if 'REFERENCE_COUNT' not in etor['name']: - std::cout << prefix; - printAdapterInfo<${etor['desc'][1:etor['desc'].find(' ')-1].replace('$x', x)}>(hAdapter, ${etor['name'].replace('$X', X)}); + <%etype = th.etor_get_associated_type(n, tags, etor) + %>std::cout << prefix; + printAdapterInfo<${etype}>(hAdapter, ${etor['name'].replace('$X', X)}); %endif %endfor } @@ -52,8 +54,9 @@ inline void printAdapterInfos(${x}_adapter_handle_t hAdapter, std::string_view p %if obj["name"] == '$x_platform_info_t': inline void printPlatformInfos(${x}_platform_handle_t hPlatform, std::string_view prefix = " ") { %for etor in obj['etors']: - std::cout << prefix; - printPlatformInfo<${etor['desc'][1:etor['desc'].find(' ')-1].replace('$x', x)}>(hPlatform, ${etor['name'].replace('$X', X)}); + <%etype = th.etor_get_associated_type(n, tags, etor) + %>std::cout << prefix; + printPlatformInfo<${etype}>(hPlatform, ${etor['name'].replace('$X', X)}); %endfor } @@ -61,11 +64,12 @@ inline void printPlatformInfos(${x}_platform_handle_t hPlatform, std::string_vie %if obj['name'] == '$x_device_info_t': inline void printDeviceInfos(${x}_device_handle_t hDevice, std::string_view prefix = " ") { %for etor in obj['etors']: - std::cout << prefix; + <%etype = th.etor_get_associated_type(n, tags, etor) + %>std::cout << prefix; %if etor['name'] == '$X_DEVICE_INFO_UUID': printDeviceUUID(hDevice, ${etor['name'].replace('$X', X)}); %else: - printDeviceInfo<${etor['desc'][1:etor['desc'].find(' ')-1].replace('$x', x)}>(hDevice, ${etor['name'].replace('$X', X)}); + printDeviceInfo<${etype}>(hDevice, ${etor['name'].replace('$X', X)}); %endif %endfor } diff --git a/source/adapters/cuda/device.cpp b/source/adapters/cuda/device.cpp index cb6b757dd3..2ce9d0d3d5 100644 --- a/source/adapters/cuda/device.cpp +++ b/source/adapters/cuda/device.cpp @@ -1087,6 +1087,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE: case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: + case UR_DEVICE_INFO_IP_VERSION: return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: diff --git a/source/adapters/cuda/program.cpp b/source/adapters/cuda/program.cpp index 4b963a737a..6773f06bf2 100644 --- a/source/adapters/cuda/program.cpp +++ b/source/adapters/cuda/program.cpp @@ -424,8 +424,14 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName, /* TODO: Add implementation for getKernelNames */ UR_ASSERT(getKernelNames(hProgram), UR_RESULT_ERROR_UNSUPPORTED_FEATURE); return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; - case UR_PROGRAM_INFO_NUM_KERNELS: case UR_PROGRAM_INFO_IL: + // Cuda only supports urProgramCreateWithBinary, so we can always return + // nothing for INFO_IL. + if (pPropSizeRet) { + *pPropSizeRet = 0; + } + return UR_RESULT_SUCCESS; + case UR_PROGRAM_INFO_NUM_KERNELS: return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; default: break; diff --git a/source/adapters/hip/device.cpp b/source/adapters/hip/device.cpp index 5271f73709..59f9c3946d 100644 --- a/source/adapters/hip/device.cpp +++ b/source/adapters/hip/device.cpp @@ -891,6 +891,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(ur_bool_t{false}); case UR_DEVICE_INFO_USM_POOL_SUPPORT: return ReturnValue(ur_bool_t{true}); + case UR_DEVICE_INFO_BFLOAT16: + return ReturnValue(true); + case UR_DEVICE_INFO_ASYNC_BARRIER: + return ReturnValue(false); + case UR_DEVICE_INFO_IL_VERSION: + return ReturnValue(""); + // TODO: Investigate if this information is available on HIP. case UR_DEVICE_INFO_COMPONENT_DEVICES: case UR_DEVICE_INFO_COMPOSITE_DEVICE: @@ -901,9 +908,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: - case UR_DEVICE_INFO_BFLOAT16: - case UR_DEVICE_INFO_IL_VERSION: - case UR_DEVICE_INFO_ASYNC_BARRIER: + case UR_DEVICE_INFO_IP_VERSION: return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: { int DriverVersion = 0; diff --git a/source/adapters/hip/program.cpp b/source/adapters/hip/program.cpp index 4c4f2b2766..ed2178d938 100644 --- a/source/adapters/hip/program.cpp +++ b/source/adapters/hip/program.cpp @@ -410,7 +410,12 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName, case UR_PROGRAM_INFO_KERNEL_NAMES: return getKernelNames(hProgram); case UR_PROGRAM_INFO_IL: - return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; + // Hip only supports urProgramCreateWithBinary, so we can always return + // nothing for INFO_IL. + if (pPropSizeRet) { + *pPropSizeRet = 0; + } + return UR_RESULT_SUCCESS; default: break; } diff --git a/source/adapters/level_zero/device.cpp b/source/adapters/level_zero/device.cpp index 865edebc08..32558f2493 100644 --- a/source/adapters/level_zero/device.cpp +++ b/source/adapters/level_zero/device.cpp @@ -875,9 +875,6 @@ ur_result_t urDeviceGetInfo( return ReturnValue(uint32_t{Device->ZeDeviceProperties->numEUsPerSubslice}); case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: return ReturnValue(uint32_t{Device->ZeDeviceProperties->numThreadsPerEU}); - case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: - // currently not supported in level zero runtime - return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; case UR_DEVICE_INFO_BFLOAT16: { // bfloat16 math functions are not yet supported on Intel GPUs. return ReturnValue(ur_bool_t{false}); @@ -1153,6 +1150,10 @@ ur_result_t urDeviceGetInfo( return ReturnValue(true); case UR_DEVICE_INFO_LOW_POWER_EVENTS_EXP: return ReturnValue(false); + case UR_DEVICE_INFO_ASYNC_BARRIER: + return ReturnValue(false); + case UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED: + return ReturnValue(false); default: logger::error("Unsupported ParamName in urGetDeviceInfo"); logger::error("ParamNameParamName={}(0x{})", ParamName, diff --git a/source/adapters/level_zero/event.cpp b/source/adapters/level_zero/event.cpp index 96da4be0fd..44d1cf1289 100644 --- a/source/adapters/level_zero/event.cpp +++ b/source/adapters/level_zero/event.cpp @@ -459,7 +459,7 @@ ur_result_t urEventGetInfo( } case UR_EVENT_INFO_COMMAND_TYPE: { std::shared_lock EventLock(Event->Mutex); - return ReturnValue(ur_cast(Event->CommandType)); + return ReturnValue(ur_cast(Event->CommandType)); } case UR_EVENT_INFO_COMMAND_EXECUTION_STATUS: { // Check to see if the event's Queue has an open command list due to diff --git a/source/adapters/level_zero/queue.cpp b/source/adapters/level_zero/queue.cpp index c4598f3472..655e956ff8 100644 --- a/source/adapters/level_zero/queue.cpp +++ b/source/adapters/level_zero/queue.cpp @@ -456,7 +456,7 @@ ur_result_t urQueueGetInfo( logger::error( "Unsupported ParamName in urQueueGetInfo: ParamName=ParamName={}(0x{})", ParamName, logger::toHex(ParamName)); - return UR_RESULT_ERROR_INVALID_VALUE; + return UR_RESULT_ERROR_INVALID_ENUMERATION; } return UR_RESULT_SUCCESS; diff --git a/source/adapters/native_cpu/device.cpp b/source/adapters/native_cpu/device.cpp index b7c454315f..60e0ab3d3e 100644 --- a/source/adapters/native_cpu/device.cpp +++ b/source/adapters/native_cpu/device.cpp @@ -365,7 +365,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_MAX_WORK_GROUPS_3D: case UR_DEVICE_INFO_MEMORY_CLOCK_RATE: case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: - return UR_RESULT_ERROR_INVALID_VALUE; + case UR_DEVICE_INFO_GLOBAL_MEM_FREE: + case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: + case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP: + case UR_DEVICE_INFO_IP_VERSION: + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; case UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: { // Currently for Native CPU fences are implemented using OCK // builtins, so we have different capabilities than atomic operations @@ -397,7 +401,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, // These two are exclusive of L0. return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; - CASE_UR_UNSUPPORTED(UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH); case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT: return ReturnValue(false); diff --git a/source/adapters/opencl/device.cpp b/source/adapters/opencl/device.cpp index 70559eb52e..1661aaf699 100644 --- a/source/adapters/opencl/device.cpp +++ b/source/adapters/opencl/device.cpp @@ -528,7 +528,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, cl_adapter::cast(hDevice), {"cl_khr_fp16"}, Supported)); if (!Supported) { - return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; + // If we don't support the extension then our capabilities are 0. + ur_device_fp_capability_flags_t halfCapabilities = 0; + return ReturnValue(halfCapabilities); } } @@ -771,9 +773,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(true); } - case UR_DEVICE_INFO_BFLOAT16: { - return ReturnValue(false); - } case UR_DEVICE_INFO_ATOMIC_64: { bool Supported = false; UR_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions( @@ -1066,7 +1065,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(UUID); } - case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: { + case UR_DEVICE_INFO_COMPONENT_DEVICES: + case UR_DEVICE_INFO_COMPOSITE_DEVICE: + // These two are exclusive to L0. + return ReturnValue(0); + // We can't query to check if these are supported, they will need to be + // manually updated if support is ever implemented. + case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: + case UR_DEVICE_INFO_BFLOAT16: + case UR_DEVICE_INFO_ASYNC_BARRIER: { return ReturnValue(false); } @@ -1078,8 +1085,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, * EU device-specific information extensions. Some of the queries are * enabled by cl_intel_device_attribute_query extension, but it's not yet in * the Registry. */ - case UR_DEVICE_INFO_COMPONENT_DEVICES: - case UR_DEVICE_INFO_COMPOSITE_DEVICE: case UR_DEVICE_INFO_PCI_ADDRESS: case UR_DEVICE_INFO_GPU_EU_COUNT: case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH: @@ -1092,8 +1097,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP: case UR_DEVICE_INFO_GLOBAL_MEM_FREE: case UR_DEVICE_INFO_MEMORY_CLOCK_RATE: - case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: - case UR_DEVICE_INFO_ASYNC_BARRIER: { + case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: { return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } diff --git a/source/adapters/opencl/usm.cpp b/source/adapters/opencl/usm.cpp index dfcc1dfafa..7961cb76ff 100644 --- a/source/adapters/opencl/usm.cpp +++ b/source/adapters/opencl/usm.cpp @@ -669,7 +669,7 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem, PropNameCL = CL_MEM_ALLOC_DEVICE_INTEL; break; default: - return UR_RESULT_ERROR_INVALID_VALUE; + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } size_t CheckPropSize = 0; diff --git a/test/conformance/adapter/urAdapterGetInfo.cpp b/test/conformance/adapter/urAdapterGetInfo.cpp index 4dff3ce4dc..b509aa4254 100644 --- a/test/conformance/adapter/urAdapterGetInfo.cpp +++ b/test/conformance/adapter/urAdapterGetInfo.cpp @@ -35,7 +35,8 @@ INSTANTIATE_TEST_SUITE_P( TEST_P(urAdapterGetInfoTest, Success) { size_t size = 0; ur_adapter_info_t info_type = GetParam(); - ASSERT_SUCCESS(urAdapterGetInfo(adapter, info_type, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urAdapterGetInfo(adapter, info_type, 0, nullptr, &size), info_type); ASSERT_NE(size, 0); if (const auto expected_size = adapter_info_size_map.find(info_type); diff --git a/test/conformance/context/urContextGetInfo.cpp b/test/conformance/context/urContextGetInfo.cpp index 46bc2cd179..bd6bdd3c3d 100644 --- a/test/conformance/context/urContextGetInfo.cpp +++ b/test/conformance/context/urContextGetInfo.cpp @@ -66,8 +66,8 @@ UUR_TEST_SUITE_P(urContextGetInfoTestWithInfoParam, TEST_P(urContextGetInfoTestWithInfoParam, Success) { ur_context_info_t info = getParam(); size_t info_size = 0; - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( - urContextGetInfo(context, info, 0, nullptr, &info_size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urContextGetInfo(context, info, 0, nullptr, &info_size), info); ASSERT_NE(info_size, 0); if (const auto expected_size = ctx_info_size_map.find(info); diff --git a/test/conformance/device/device_adapter_cuda.match b/test/conformance/device/device_adapter_cuda.match index 48e00debe4..e42f948b73 100644 --- a/test/conformance/device/device_adapter_cuda.match +++ b/test/conformance/device/device_adapter_cuda.match @@ -1 +1,2 @@ {{OPT}}urDeviceGetGlobalTimestampTest.SuccessSynchronizedTime +urDeviceGetInfoTest.Success/UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS diff --git a/test/conformance/device/device_adapter_level_zero.match b/test/conformance/device/device_adapter_level_zero.match index 48e00debe4..87140fb10c 100644 --- a/test/conformance/device/device_adapter_level_zero.match +++ b/test/conformance/device/device_adapter_level_zero.match @@ -1 +1,2 @@ {{OPT}}urDeviceGetGlobalTimestampTest.SuccessSynchronizedTime +{{OPT}}urDeviceGetInfoTest.Success/UR_DEVICE_INFO_GLOBAL_MEM_FREE diff --git a/test/conformance/device/device_adapter_native_cpu.match b/test/conformance/device/device_adapter_native_cpu.match index 00b3642e71..da07da18dc 100644 --- a/test/conformance/device/device_adapter_native_cpu.match +++ b/test/conformance/device/device_adapter_native_cpu.match @@ -3,27 +3,15 @@ urDeviceCreateWithNativeHandleTest.InvalidNullPointerDevice {{OPT}}urDeviceGetGlobalTimestampTest.SuccessSynchronizedTime urDeviceGetInfoSingleTest.MaxWorkGroupSizeIsNonzero {{OPT}}urDeviceSelectBinaryTest.Success -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_DEVICE_ID -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_MEMORY_CLOCK_RATE urDeviceGetInfoTest.Success/UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_GLOBAL_MEM_FREE urDeviceGetInfoTest.Success/UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES urDeviceGetInfoTest.Success/UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES urDeviceGetInfoTest.Success/UR_DEVICE_INFO_IL_VERSION urDeviceGetInfoTest.Success/UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_UUID -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_PCI_ADDRESS -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_GPU_EU_COUNT -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_GPU_EU_SLICES -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH urDeviceGetInfoTest.Success/UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_MEMORY_BUS_WIDTH urDeviceGetInfoTest.Success/UR_DEVICE_INFO_MAX_WORK_GROUPS_3D urDeviceGetInfoTest.Success/UR_DEVICE_INFO_ASYNC_BARRIER urDeviceGetInfoTest.Success/UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED -urDeviceGetInfoTest.Success/UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP +urDeviceGetInfoTest.Success/UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES +urDeviceGetInfoTest.Success/UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES urDeviceGetInfoTest.Success/UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS diff --git a/test/conformance/device/urDeviceGetInfo.cpp b/test/conformance/device/urDeviceGetInfo.cpp index e41cff97ed..da377ccd44 100644 --- a/test/conformance/device/urDeviceGetInfo.cpp +++ b/test/conformance/device/urDeviceGetInfo.cpp @@ -4,7 +4,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include -#include #include static std::unordered_map device_info_size_map = { @@ -115,7 +114,13 @@ static std::unordered_map device_info_size_map = { {UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, sizeof(uint32_t)}, {UR_DEVICE_INFO_COMPONENT_DEVICES, sizeof(uint32_t)}, {UR_DEVICE_INFO_COMPOSITE_DEVICE, sizeof(ur_device_handle_t)}, - {UR_DEVICE_INFO_USM_POOL_SUPPORT, sizeof(ur_bool_t)}}; + {UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES, + sizeof(ur_memory_order_capability_flags_t)}, + {UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES, + sizeof(ur_memory_scope_capability_flags_t)}, + {UR_DEVICE_INFO_ESIMD_SUPPORT, sizeof(ur_bool_t)}, + {UR_DEVICE_INFO_IP_VERSION, sizeof(uint32_t)}, + {UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, sizeof(ur_bool_t)}}; struct urDeviceGetInfoTest : uur::urAllDevicesTest, ::testing::WithParamInterface { @@ -236,8 +241,15 @@ INSTANTIATE_TEST_SUITE_P( UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED, // UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, // UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, // + UR_DEVICE_INFO_USM_POOL_SUPPORT, // + UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES, // + UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES, // + UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES, // + UR_DEVICE_INFO_IP_VERSION, // UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS, // - UR_DEVICE_INFO_USM_POOL_SUPPORT // + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE, // + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF, // + UR_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT // ), [](const ::testing::TestParamInfo &info) { std::stringstream ss; @@ -263,32 +275,27 @@ TEST_P(urDeviceGetInfoTest, Success) { ur_device_info_t info_type = GetParam(); for (auto device : devices) { size_t size = 0; - ur_result_t result = - urDeviceGetInfo(device, info_type, 0, nullptr, &size); - - if (result == UR_RESULT_SUCCESS) { - if (doesReturnArray(info_type) && size == 0) { - return; - } - ASSERT_NE(size, 0); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urDeviceGetInfo(device, info_type, 0, nullptr, &size), info_type); - if (const auto expected_size = device_info_size_map.find(info_type); - expected_size != device_info_size_map.end()) { - ASSERT_EQ(expected_size->second, size); - } + if (doesReturnArray(info_type) && size == 0) { + return; + } + ASSERT_NE(size, 0); - std::vector info_data(size); - ASSERT_SUCCESS(urDeviceGetInfo(device, info_type, size, - info_data.data(), nullptr)); + if (const auto expected_size = device_info_size_map.find(info_type); + expected_size != device_info_size_map.end()) { + ASSERT_EQ(expected_size->second, size); + } - if (info_type == UR_DEVICE_INFO_PLATFORM) { - auto returned_platform = - reinterpret_cast(info_data.data()); - ASSERT_EQ(*returned_platform, platform); - } + std::vector info_data(size); + ASSERT_SUCCESS(urDeviceGetInfo(device, info_type, size, + info_data.data(), nullptr)); - } else { - ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION); + if (info_type == UR_DEVICE_INFO_PLATFORM) { + auto returned_platform = + reinterpret_cast(info_data.data()); + ASSERT_EQ(*returned_platform, platform); } } } diff --git a/test/conformance/enqueue/enqueue_adapter_level_zero.match b/test/conformance/enqueue/enqueue_adapter_level_zero.match index 9394f1b0a0..1004cc9d88 100644 --- a/test/conformance/enqueue/enqueue_adapter_level_zero.match +++ b/test/conformance/enqueue/enqueue_adapter_level_zero.match @@ -51,19 +51,9 @@ {{OPT}}urEnqueueMemImageWriteTest.InvalidRegion2D/* {{OPT}}urEnqueueMemImageWriteTest.InvalidRegion3D/* {{OPT}}urEnqueueKernelLaunchMultiDeviceTest.KernelLaunchReadDifferentQueues/* -urEnqueueReadHostPipeTest.InvalidEventWaitList/* -urEnqueueReadHostPipeTest.InvalidNullHandleProgram/* -urEnqueueReadHostPipeTest.InvalidNullHandleQueue/* -urEnqueueReadHostPipeTest.InvalidNullPointerBuffer/* -urEnqueueReadHostPipeTest.InvalidNullPointerPipeSymbol/* urEnqueueUSMAdviseTest.InvalidSizeTooLarge/* urEnqueueUSMFill2DNegativeTest.OutOfBounds/* {{OPT}}urEnqueueUSMMemcpyTest.Blocking/* {{OPT}}urEnqueueUSMMemcpyTest.BlockingWithEvent/* {{OPT}}urEnqueueUSMMemcpyTest.WaitForDependencies/* urEnqueueUSMPrefetchTest.InvalidSizeTooLarge/* -urEnqueueWriteHostPipeTest.InvalidEventWaitList/* -urEnqueueWriteHostPipeTest.InvalidNullHandleProgram/* -urEnqueueWriteHostPipeTest.InvalidNullHandleQueue/* -urEnqueueWriteHostPipeTest.InvalidNullPointerBuffer/* -urEnqueueWriteHostPipeTest.InvalidNullPointerPipeSymbol/* diff --git a/test/conformance/enqueue/enqueue_adapter_level_zero_v2.match b/test/conformance/enqueue/enqueue_adapter_level_zero_v2.match index 44895d10fa..40aae01c7e 100644 --- a/test/conformance/enqueue/enqueue_adapter_level_zero_v2.match +++ b/test/conformance/enqueue/enqueue_adapter_level_zero_v2.match @@ -72,14 +72,4 @@ urEnqueueKernelLaunchWithVirtualMemory.Success/* urEnqueueUSMFill2DNegativeTest.OutOfBounds/* urEnqueueUSMAdviseTest.InvalidSizeTooLarge/* urEnqueueUSMPrefetchTest.InvalidSizeTooLarge/* -urEnqueueReadHostPipeTest.InvalidNullHandleQueue/* -urEnqueueReadHostPipeTest.InvalidNullHandleProgram/* -urEnqueueReadHostPipeTest.InvalidNullPointerPipeSymbol/* -urEnqueueReadHostPipeTest.InvalidNullPointerBuffer/* -urEnqueueReadHostPipeTest.InvalidEventWaitList/* -urEnqueueWriteHostPipeTest.InvalidNullHandleQueue/* -urEnqueueWriteHostPipeTest.InvalidNullHandleProgram/* -urEnqueueWriteHostPipeTest.InvalidNullPointerPipeSymbol/* -urEnqueueWriteHostPipeTest.InvalidNullPointerBuffer/* -urEnqueueWriteHostPipeTest.InvalidEventWaitList/* {{OPT}}urEnqueueTimestampRecordingExpTest.SuccessBlocking/* diff --git a/test/conformance/event/urEventGetInfo.cpp b/test/conformance/event/urEventGetInfo.cpp index 4cca805cd0..d2ff63657b 100644 --- a/test/conformance/event/urEventGetInfo.cpp +++ b/test/conformance/event/urEventGetInfo.cpp @@ -11,7 +11,8 @@ TEST_P(urEventGetInfoTest, Success) { ur_event_info_t info_type = getParam(); size_t size; - ASSERT_SUCCESS(urEventGetInfo(event, info_type, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urEventGetInfo(event, info_type, 0, nullptr, &size), info_type); ASSERT_NE(size, 0); std::vector data(size); ASSERT_SUCCESS( diff --git a/test/conformance/event/urEventGetProfilingInfo.cpp b/test/conformance/event/urEventGetProfilingInfo.cpp index 7b91679dad..ca5d1247f2 100644 --- a/test/conformance/event/urEventGetProfilingInfo.cpp +++ b/test/conformance/event/urEventGetProfilingInfo.cpp @@ -12,8 +12,9 @@ TEST_P(urEventGetProfilingInfoTest, Success) { ur_profiling_info_t info_type = getParam(); size_t size; - ASSERT_SUCCESS( - urEventGetProfilingInfo(event, info_type, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urEventGetProfilingInfo(event, info_type, 0, nullptr, &size), + info_type); ASSERT_EQ(size, 8); std::vector data(size); diff --git a/test/conformance/kernel/kernel_adapter_opencl.match b/test/conformance/kernel/kernel_adapter_opencl.match deleted file mode 100644 index 687d7be2e7..0000000000 --- a/test/conformance/kernel/kernel_adapter_opencl.match +++ /dev/null @@ -1 +0,0 @@ -urKernelGetInfoTest.Success/*_UR_KERNEL_INFO_NUM_REGS diff --git a/test/conformance/kernel/urKernelGetGroupInfo.cpp b/test/conformance/kernel/urKernelGetGroupInfo.cpp index 2b3c70c22e..35e837e97a 100644 --- a/test/conformance/kernel/urKernelGetGroupInfo.cpp +++ b/test/conformance/kernel/urKernelGetGroupInfo.cpp @@ -43,16 +43,14 @@ TEST_P(urKernelGetGroupInfoTest, Success) { auto property_name = getParam(); size_t property_size = 0; std::vector property_value; - auto result = urKernelGetGroupInfo(kernel, device, property_name, 0, - nullptr, &property_size); - if (result == UR_RESULT_SUCCESS) { - property_value.resize(property_size); - ASSERT_SUCCESS(urKernelGetGroupInfo(kernel, device, property_name, - property_size, - property_value.data(), nullptr)); - } else { - ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION); - } + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urKernelGetGroupInfo(kernel, device, property_name, 0, nullptr, + &property_size), + property_name); + property_value.resize(property_size); + ASSERT_SUCCESS(urKernelGetGroupInfo(kernel, device, property_name, + property_size, property_value.data(), + nullptr)); } TEST_P(urKernelGetGroupInfoTest, InvalidNullHandleKernel) { diff --git a/test/conformance/kernel/urKernelGetInfo.cpp b/test/conformance/kernel/urKernelGetInfo.cpp index e87ab1da13..4749abc367 100644 --- a/test/conformance/kernel/urKernelGetInfo.cpp +++ b/test/conformance/kernel/urKernelGetInfo.cpp @@ -22,8 +22,9 @@ TEST_P(urKernelGetInfoTest, Success) { auto property_name = getParam(); size_t property_size = 0; std::vector property_value; - ASSERT_SUCCESS( - urKernelGetInfo(kernel, property_name, 0, nullptr, &property_size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urKernelGetInfo(kernel, property_name, 0, nullptr, &property_size), + property_name); property_value.resize(property_size); ASSERT_SUCCESS(urKernelGetInfo(kernel, property_name, property_size, property_value.data(), nullptr)); diff --git a/test/conformance/kernel/urKernelGetSubGroupInfo.cpp b/test/conformance/kernel/urKernelGetSubGroupInfo.cpp index fa4e045483..f2fc8f0197 100644 --- a/test/conformance/kernel/urKernelGetSubGroupInfo.cpp +++ b/test/conformance/kernel/urKernelGetSubGroupInfo.cpp @@ -27,8 +27,10 @@ TEST_P(urKernelGetSubGroupInfoTest, Success) { auto property_name = getParam(); size_t property_size = 0; std::vector property_value; - ASSERT_SUCCESS(urKernelGetSubGroupInfo(kernel, device, property_name, 0, - nullptr, &property_size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urKernelGetSubGroupInfo(kernel, device, property_name, 0, nullptr, + &property_size), + property_name); property_value.resize(property_size); ASSERT_SUCCESS(urKernelGetSubGroupInfo(kernel, device, property_name, property_size, property_value.data(), diff --git a/test/conformance/memory/urMemGetInfo.cpp b/test/conformance/memory/urMemGetInfo.cpp index 3f933d39a9..ddcc2761d0 100644 --- a/test/conformance/memory/urMemGetInfo.cpp +++ b/test/conformance/memory/urMemGetInfo.cpp @@ -23,7 +23,8 @@ UUR_TEST_SUITE_P(urMemGetInfoTestWithParam, TEST_P(urMemGetInfoTestWithParam, Success) { ur_mem_info_t info = getParam(); size_t size; - ASSERT_SUCCESS(urMemGetInfo(buffer, info, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urMemGetInfo(buffer, info, 0, nullptr, &size), info); ASSERT_NE(size, 0); if (const auto expected_size = mem_info_size_map.find(info); diff --git a/test/conformance/memory/urMemImageGetInfo.cpp b/test/conformance/memory/urMemImageGetInfo.cpp index ae85720220..1a67e42fad 100644 --- a/test/conformance/memory/urMemImageGetInfo.cpp +++ b/test/conformance/memory/urMemImageGetInfo.cpp @@ -28,7 +28,8 @@ UUR_TEST_SUITE_P(urMemImageGetInfoTest, TEST_P(urMemImageGetInfoTest, Success) { ur_image_info_t info = getParam(); size_t size = 0; - ASSERT_SUCCESS(urMemImageGetInfo(image, info, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urMemImageGetInfo(image, info, 0, nullptr, &size), info); ASSERT_NE(size, 0); if (const auto expected_size = image_info_size_map.find(info); diff --git a/test/conformance/platform/urPlatformGetInfo.cpp b/test/conformance/platform/urPlatformGetInfo.cpp index 1dc92b26d7..0633e420f6 100644 --- a/test/conformance/platform/urPlatformGetInfo.cpp +++ b/test/conformance/platform/urPlatformGetInfo.cpp @@ -29,7 +29,8 @@ INSTANTIATE_TEST_SUITE_P( TEST_P(urPlatformGetInfoTest, Success) { size_t size = 0; ur_platform_info_t info_type = GetParam(); - ASSERT_SUCCESS(urPlatformGetInfo(platform, info_type, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urPlatformGetInfo(platform, info_type, 0, nullptr, &size), info_type); if (info_type == UR_PLATFORM_INFO_BACKEND) { ASSERT_EQ(size, sizeof(ur_platform_backend_t)); } else { diff --git a/test/conformance/program/program_adapter_level_zero.match b/test/conformance/program/program_adapter_level_zero.match index 97d6869b81..8cb53734bd 100644 --- a/test/conformance/program/program_adapter_level_zero.match +++ b/test/conformance/program/program_adapter_level_zero.match @@ -1,3 +1,4 @@ urProgramSetSpecializationConstantsTest.InvalidValueSize/* urProgramSetSpecializationConstantsTest.InvalidValueId/* urProgramSetSpecializationConstantsTest.InvalidValuePtr/* +urProgramGetBuildInfoTest.Success/*UR_PROGRAM_BUILD_INFO_STATUS diff --git a/test/conformance/program/program_adapter_level_zero_v2.match b/test/conformance/program/program_adapter_level_zero_v2.match index 97d6869b81..8cb53734bd 100644 --- a/test/conformance/program/program_adapter_level_zero_v2.match +++ b/test/conformance/program/program_adapter_level_zero_v2.match @@ -1,3 +1,4 @@ urProgramSetSpecializationConstantsTest.InvalidValueSize/* urProgramSetSpecializationConstantsTest.InvalidValueId/* urProgramSetSpecializationConstantsTest.InvalidValuePtr/* +urProgramGetBuildInfoTest.Success/*UR_PROGRAM_BUILD_INFO_STATUS diff --git a/test/conformance/program/urProgramGetBuildInfo.cpp b/test/conformance/program/urProgramGetBuildInfo.cpp index cf4e9b9217..df46467197 100644 --- a/test/conformance/program/urProgramGetBuildInfo.cpp +++ b/test/conformance/program/urProgramGetBuildInfo.cpp @@ -33,19 +33,10 @@ TEST_P(urProgramGetBuildInfoTest, Success) { auto property_name = getParam(); size_t property_size = 0; std::vector property_value; - ur_platform_backend_t backend; - ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND, - sizeof(backend), &backend, nullptr)); - auto result = urProgramGetBuildInfo(program, device, property_name, 0, - nullptr, &property_size); - - if (property_name == UR_PROGRAM_BUILD_INFO_STATUS && - backend == UR_PLATFORM_BACKEND_LEVEL_ZERO) { - ASSERT_EQ(UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION, result); - return; - } - - ASSERT_SUCCESS(result); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urProgramGetBuildInfo(program, device, property_name, 0, nullptr, + &property_size), + property_name); property_value.resize(property_size); ASSERT_SUCCESS(urProgramGetBuildInfo(program, device, property_name, property_size, property_value.data(), diff --git a/test/conformance/program/urProgramGetInfo.cpp b/test/conformance/program/urProgramGetInfo.cpp index 7b2e6f1873..176a278583 100644 --- a/test/conformance/program/urProgramGetInfo.cpp +++ b/test/conformance/program/urProgramGetInfo.cpp @@ -52,15 +52,18 @@ TEST_P(urProgramGetInfoTest, Success) { sizeof(binaries[0]), binaries, nullptr)); } else { - auto result = urProgramGetInfo(program, property_name, 0, nullptr, - &property_size); - if (result != UR_RESULT_SUCCESS) { - ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION); - return; + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urProgramGetInfo(program, property_name, 0, nullptr, + &property_size), + property_name); + if (property_size) { + property_value.resize(property_size); + ASSERT_SUCCESS(urProgramGetInfo(program, property_name, + property_size, + property_value.data(), nullptr)); + } else { + ASSERT_EQ(property_name, UR_PROGRAM_INFO_IL); } - property_value.resize(property_size); - ASSERT_SUCCESS(urProgramGetInfo(program, property_name, property_size, - property_value.data(), nullptr)); } switch (property_name) { case UR_PROGRAM_INFO_REFERENCE_COUNT: { @@ -108,7 +111,11 @@ TEST_P(urProgramGetInfoTest, Success) { break; } case UR_PROGRAM_INFO_IL: { - ASSERT_EQ(property_value, *il_binary.get()); + // Some adapters only support ProgramCreateWithBinary, in those cases we + // expect a return size of 0 and an empty return value for INFO_IL. + if (!property_value.empty()) { + ASSERT_EQ(property_value, *il_binary.get()); + } break; } default: diff --git a/test/conformance/queue/queue_adapter_native_cpu.match b/test/conformance/queue/queue_adapter_native_cpu.match index 1c48a80fed..8bac2b269e 100644 --- a/test/conformance/queue/queue_adapter_native_cpu.match +++ b/test/conformance/queue/queue_adapter_native_cpu.match @@ -8,6 +8,7 @@ urQueueGetInfoTest.Device/* urQueueGetInfoTest.Flags/* urQueueGetInfoTest.ReferenceCount/* urQueueGetInfoTest.InvalidSizeSmall/* +urQueueGetInfoTest.EmptyQueue/* urQueueGetInfoDeviceQueueTestWithInfoParam.DeviceDefault/* urQueueGetInfoDeviceQueueTestWithInfoParam.Size/* urQueueRetainTest.Success/* diff --git a/test/conformance/queue/urQueueGetInfo.cpp b/test/conformance/queue/urQueueGetInfo.cpp index e3330fef6f..57fdd954d1 100644 --- a/test/conformance/queue/urQueueGetInfo.cpp +++ b/test/conformance/queue/urQueueGetInfo.cpp @@ -2,7 +2,6 @@ // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include #include using urQueueGetInfoTest = uur::urQueueTest; @@ -11,7 +10,8 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urQueueGetInfoTest); TEST_P(urQueueGetInfoTest, Context) { size_t size = 0; auto infoType = UR_QUEUE_INFO_CONTEXT; - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_NE(size, 0); ASSERT_EQ(sizeof(ur_context_handle_t), size); @@ -26,7 +26,8 @@ TEST_P(urQueueGetInfoTest, Context) { TEST_P(urQueueGetInfoTest, Device) { size_t size = 0; auto infoType = UR_QUEUE_INFO_DEVICE; - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_NE(size, 0); ASSERT_EQ(sizeof(ur_device_handle_t), size); @@ -40,7 +41,8 @@ TEST_P(urQueueGetInfoTest, Device) { TEST_P(urQueueGetInfoTest, Flags) { size_t size = 0; auto infoType = UR_QUEUE_INFO_FLAGS; - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_NE(size, 0); ASSERT_EQ(sizeof(ur_queue_flags_t), size); @@ -54,7 +56,8 @@ TEST_P(urQueueGetInfoTest, Flags) { TEST_P(urQueueGetInfoTest, ReferenceCount) { size_t size = 0; auto infoType = UR_QUEUE_INFO_REFERENCE_COUNT; - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_NE(size, 0); ASSERT_EQ(sizeof(uint32_t), size); @@ -68,8 +71,8 @@ TEST_P(urQueueGetInfoTest, ReferenceCount) { TEST_P(urQueueGetInfoTest, EmptyQueue) { size_t size = 0; auto infoType = UR_QUEUE_INFO_EMPTY; - UUR_ASSERT_SUCCESS_OR_UNSUPPORTED( - urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_NE(size, 0); ASSERT_EQ(sizeof(ur_bool_t), size); @@ -159,7 +162,8 @@ TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, DeviceDefault) { size_t size = 0; auto infoType = UR_QUEUE_INFO_DEVICE_DEFAULT; - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_NE(size, 0); ASSERT_EQ(sizeof(ur_queue_handle_t), size); @@ -174,7 +178,8 @@ TEST_P(urQueueGetInfoDeviceQueueTestWithInfoParam, Size) { size_t size = 0; auto infoType = UR_QUEUE_INFO_SIZE; - ASSERT_SUCCESS(urQueueGetInfo(queue, infoType, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urQueueGetInfo(queue, infoType, 0, nullptr, &size), infoType); ASSERT_NE(size, 0); ASSERT_EQ(sizeof(uint32_t), size); diff --git a/test/conformance/sampler/urSamplerGetInfo.cpp b/test/conformance/sampler/urSamplerGetInfo.cpp index e1f9326df7..9cf1a3f7ec 100644 --- a/test/conformance/sampler/urSamplerGetInfo.cpp +++ b/test/conformance/sampler/urSamplerGetInfo.cpp @@ -18,7 +18,8 @@ UUR_TEST_SUITE_P(urSamplerGetInfoTestWithParam, TEST_P(urSamplerGetInfoTestWithParam, Success) { size_t size = 0; ur_sampler_info_t info = getParam(); - ASSERT_SUCCESS(urSamplerGetInfo(sampler, info, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urSamplerGetInfo(sampler, info, 0, nullptr, &size), info); ASSERT_NE(size, 0); std::vector infoData(size); ASSERT_SUCCESS( diff --git a/test/conformance/testing/include/uur/checks.h b/test/conformance/testing/include/uur/checks.h index 2ad3925842..c0adb12453 100644 --- a/test/conformance/testing/include/uur/checks.h +++ b/test/conformance/testing/include/uur/checks.h @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace uur { @@ -46,6 +47,21 @@ inline std::ostream &operator<<(std::ostream &out, const Result &result) { #define EXPECT_SUCCESS(ACTUAL) EXPECT_EQ_RESULT(UR_RESULT_SUCCESS, ACTUAL) #endif +// This macro is intended to be used for the first call to a GetInfo query, it +// gracefully handles cases where the adapter doesn't support a query marked +// [optional-query] in the spec by returning early. +#ifndef ASSERT_SUCCESS_OR_OPTIONAL_QUERY +#define ASSERT_SUCCESS_OR_OPTIONAL_QUERY(CALL, QUERY) \ + do { \ + auto result = CALL; \ + if (result != UR_RESULT_SUCCESS) { \ + ASSERT_EQ_RESULT(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION); \ + ASSERT_TRUE(uur::isQueryOptional(QUERY)); \ + return; \ + } \ + } while (0) +#endif + inline std::ostream &operator<<(std::ostream &out, const ur_device_handle_t &device) { out << uur::GetDeviceName(device); diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index 436e7821a9..a0bcd6dcc9 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -1074,6 +1074,12 @@ struct urUSMDeviceAllocTestWithParam : urQueueTestWithParam { GTEST_SKIP() << "Device USM in not supported"; } if (use_pool) { + ur_bool_t poolSupport = false; + ASSERT_SUCCESS( + uur::GetDeviceUSMPoolSupport(this->device, poolSupport)); + if (!poolSupport) { + GTEST_SKIP() << "USM pools are not supported."; + } ur_usm_pool_desc_t pool_desc = {}; ASSERT_SUCCESS(urUSMPoolCreate(this->context, &pool_desc, &pool)); } diff --git a/test/conformance/testing/include/uur/optional_queries.h b/test/conformance/testing/include/uur/optional_queries.h new file mode 100644 index 0000000000..732abfc301 --- /dev/null +++ b/test/conformance/testing/include/uur/optional_queries.h @@ -0,0 +1,115 @@ +/* + * + * Copyright (C) 2024 Intel Corporation + * + * Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. + * See LICENSE.TXT + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + * @file optional_queries.h + * + */ + +// Auto-generated file, do not edit. + +#pragma once + +#include +#include +#include + +namespace uur { + +template bool isQueryOptional(T) { return false; } + +constexpr std::array optional_ur_device_info_t = { + UR_DEVICE_INFO_DEVICE_ID, + UR_DEVICE_INFO_MEMORY_CLOCK_RATE, + UR_DEVICE_INFO_GLOBAL_MEM_FREE, + UR_DEVICE_INFO_UUID, + UR_DEVICE_INFO_PCI_ADDRESS, + UR_DEVICE_INFO_GPU_EU_COUNT, + UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH, + UR_DEVICE_INFO_GPU_EU_SLICES, + UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE, + UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE, + UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU, + UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH, + UR_DEVICE_INFO_MEMORY_BUS_WIDTH, + UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, + UR_DEVICE_INFO_IP_VERSION, +}; + +template <> inline bool isQueryOptional(ur_device_info_t query) { + return std::find(optional_ur_device_info_t.begin(), + optional_ur_device_info_t.end(), + query) != optional_ur_device_info_t.end(); +} + +constexpr std::array optional_ur_context_info_t = { + UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES, + UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES, + UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES, + UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES, +}; + +template <> inline bool isQueryOptional(ur_context_info_t query) { + return std::find(optional_ur_context_info_t.begin(), + optional_ur_context_info_t.end(), + query) != optional_ur_context_info_t.end(); +} + +constexpr std::array optional_ur_usm_alloc_info_t = { + UR_USM_ALLOC_INFO_POOL, +}; + +template <> inline bool isQueryOptional(ur_usm_alloc_info_t query) { + return std::find(optional_ur_usm_alloc_info_t.begin(), + optional_ur_usm_alloc_info_t.end(), + query) != optional_ur_usm_alloc_info_t.end(); +} + +constexpr std::array optional_ur_program_info_t = { + UR_PROGRAM_INFO_NUM_KERNELS, + UR_PROGRAM_INFO_KERNEL_NAMES, +}; + +template <> inline bool isQueryOptional(ur_program_info_t query) { + return std::find(optional_ur_program_info_t.begin(), + optional_ur_program_info_t.end(), + query) != optional_ur_program_info_t.end(); +} + +constexpr std::array optional_ur_kernel_info_t = { + UR_KERNEL_INFO_NUM_REGS, +}; + +template <> inline bool isQueryOptional(ur_kernel_info_t query) { + return std::find(optional_ur_kernel_info_t.begin(), + optional_ur_kernel_info_t.end(), + query) != optional_ur_kernel_info_t.end(); +} + +constexpr std::array optional_ur_kernel_group_info_t = { + UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE, + UR_KERNEL_GROUP_INFO_COMPILE_MAX_WORK_GROUP_SIZE, + UR_KERNEL_GROUP_INFO_COMPILE_MAX_LINEAR_WORK_GROUP_SIZE, +}; + +template <> inline bool isQueryOptional(ur_kernel_group_info_t query) { + return std::find(optional_ur_kernel_group_info_t.begin(), + optional_ur_kernel_group_info_t.end(), + query) != optional_ur_kernel_group_info_t.end(); +} + +constexpr std::array optional_ur_queue_info_t = { + UR_QUEUE_INFO_EMPTY, +}; + +template <> inline bool isQueryOptional(ur_queue_info_t query) { + return std::find(optional_ur_queue_info_t.begin(), + optional_ur_queue_info_t.end(), + query) != optional_ur_queue_info_t.end(); +} + +} // namespace uur diff --git a/test/conformance/usm/urUSMGetMemAllocInfo.cpp b/test/conformance/usm/urUSMGetMemAllocInfo.cpp index 181e1d08b3..38719379a9 100644 --- a/test/conformance/usm/urUSMGetMemAllocInfo.cpp +++ b/test/conformance/usm/urUSMGetMemAllocInfo.cpp @@ -33,8 +33,9 @@ static std::unordered_map usm_info_size_map = { TEST_P(urUSMGetMemAllocInfoTest, Success) { size_t size = 0; auto alloc_info = getParam(); - ASSERT_SUCCESS( - urUSMGetMemAllocInfo(context, ptr, alloc_info, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urUSMGetMemAllocInfo(context, ptr, alloc_info, 0, nullptr, &size), + alloc_info); ASSERT_NE(size, 0); if (const auto expected_size = usm_info_size_map.find(alloc_info); diff --git a/test/conformance/usm/urUSMPoolGetInfo.cpp b/test/conformance/usm/urUSMPoolGetInfo.cpp index 945ce1b0b2..e43bc3a77b 100644 --- a/test/conformance/usm/urUSMPoolGetInfo.cpp +++ b/test/conformance/usm/urUSMPoolGetInfo.cpp @@ -22,7 +22,8 @@ UUR_TEST_SUITE_P(urUSMPoolGetInfoTestWithInfoParam, TEST_P(urUSMPoolGetInfoTestWithInfoParam, Success) { ur_usm_pool_info_t info_type = getParam(); size_t size = 0; - ASSERT_SUCCESS(urUSMPoolGetInfo(pool, info_type, 0, nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urUSMPoolGetInfo(pool, info_type, 0, nullptr, &size), info_type); ASSERT_NE(size, 0); if (const auto expected_size = pool_info_size_map.find(info_type); diff --git a/test/conformance/usm/usm_adapter_native_cpu.match b/test/conformance/usm/usm_adapter_native_cpu.match index 6ef26e2bdf..732d9aa2bb 100644 --- a/test/conformance/usm/usm_adapter_native_cpu.match +++ b/test/conformance/usm/usm_adapter_native_cpu.match @@ -7,7 +7,6 @@ urUSMGetMemAllocInfoTest.Success/*__UR_USM_ALLOC_INFO_TYPE urUSMGetMemAllocInfoTest.Success/*__UR_USM_ALLOC_INFO_BASE_PTR urUSMGetMemAllocInfoTest.Success/*__UR_USM_ALLOC_INFO_SIZE urUSMGetMemAllocInfoTest.Success/*__UR_USM_ALLOC_INFO_DEVICE -urUSMGetMemAllocInfoTest.Success/*__UR_USM_ALLOC_INFO_POOL urUSMGetMemAllocInfoNegativeTest.InvalidNullHandleContext/* urUSMGetMemAllocInfoNegativeTest.InvalidNullPointerMem/* urUSMGetMemAllocInfoNegativeTest.InvalidEnumeration/* diff --git a/test/conformance/usm/usm_adapter_opencl.match b/test/conformance/usm/usm_adapter_opencl.match deleted file mode 100644 index 2fffa9b0ed..0000000000 --- a/test/conformance/usm/usm_adapter_opencl.match +++ /dev/null @@ -1 +0,0 @@ -urUSMGetMemAllocInfoTest.Success/*__UR_USM_ALLOC_INFO_POOL diff --git a/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp b/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp index 79579e9297..041a749b5b 100644 --- a/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp +++ b/test/conformance/virtual_memory/urVirtualMemGetInfo.cpp @@ -13,8 +13,10 @@ UUR_TEST_SUITE_P(urVirtualMemGetInfoTestWithParam, TEST_P(urVirtualMemGetInfoTestWithParam, Success) { size_t info_size = 0; ur_virtual_mem_info_t info = getParam(); - ASSERT_SUCCESS(urVirtualMemGetInfo(context, virtual_ptr, size, info, 0, - nullptr, &info_size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY(urVirtualMemGetInfo(context, virtual_ptr, + size, info, 0, nullptr, + &info_size), + info); ASSERT_NE(info_size, 0); std::vector data(info_size); diff --git a/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp b/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp index ddd1143a21..2fac7a1093 100644 --- a/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp +++ b/test/conformance/virtual_memory/urVirtualMemGranularityGetInfo.cpp @@ -28,8 +28,10 @@ UUR_TEST_SUITE_P( TEST_P(urVirtualMemGranularityGetInfoTest, Success) { size_t size = 0; ur_virtual_mem_granularity_info_t info = getParam(); - ASSERT_SUCCESS(urVirtualMemGranularityGetInfo(context, device, info, 0, - nullptr, &size)); + ASSERT_SUCCESS_OR_OPTIONAL_QUERY( + urVirtualMemGranularityGetInfo(context, device, info, 0, nullptr, + &size), + info); ASSERT_NE(size, 0); std::vector infoData(size);