diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index ce491b24d1527..633495a625158 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -39,11 +39,11 @@ extern "C" { #endif // __cplusplus -typedef int32_t pi_int32; -typedef uint32_t pi_uint32; -typedef uint64_t pi_uint64; -typedef pi_uint32 pi_bool; -typedef pi_uint64 pi_bitfield; +using pi_int32 = int32_t; +using pi_uint32 = uint32_t; +using pi_uint64 = uint64_t; +using pi_bool = pi_uint32; +using pi_bitfield = pi_uint64; // // NOTE: prefer to map 1:1 to OpenCL so that no translation is needed @@ -86,16 +86,6 @@ typedef enum { PI_EVENT_QUEUED = CL_QUEUED } _pi_event_status; -typedef enum { - PI_COMMAND_KERNEL_LAUNCH = CL_COMMAND_NDRANGE_KERNEL, - PI_COMMAND_MEMBUFFER_WRITE = CL_COMMAND_WRITE_BUFFER, - PI_COMMAND_MEMBUFFER_READ = CL_COMMAND_READ_BUFFER, - PI_COMMAND_USER = CL_COMMAND_USER, - PI_COMMAND_EVENTS_WAIT = CL_COMMAND_MARKER, - PI_COMMAND_MEMBUFFER_COPY = CL_COMMAND_COPY_BUFFER, - PI_COMMAND_MEMBUFFER_FILL = CL_COMMAND_FILL_BUFFER -} _pi_command_type; - typedef enum { PI_PLATFORM_INFO_EXTENSIONS = CL_PLATFORM_EXTENSIONS, PI_PLATFORM_INFO_NAME = CL_PLATFORM_NAME, @@ -104,17 +94,6 @@ typedef enum { PI_PLATFORM_INFO_VERSION = CL_PLATFORM_VERSION, } _pi_platform_info; -typedef enum { - PI_PROGRAM_INFO_REFERENCE_COUNT = CL_PROGRAM_REFERENCE_COUNT, - PI_PROGRAM_INFO_CONTEXT = CL_PROGRAM_CONTEXT, - PI_PROGRAM_INFO_NUM_DEVICES = CL_PROGRAM_NUM_DEVICES, - PI_PROGRAM_INFO_DEVICES = CL_PROGRAM_DEVICES, - PI_PROGRAM_INFO_SOURCE = CL_PROGRAM_SOURCE, - PI_PROGRAM_INFO_BINARY_SIZES = CL_PROGRAM_BINARY_SIZES, - PI_PROGRAM_INFO_BINARIES = CL_PROGRAM_BINARIES, - PI_PROGRAM_INFO_KERNEL_NAMES = CL_PROGRAM_KERNEL_NAMES -} _pi_program_info; - typedef enum { PI_PROGRAM_BUILD_INFO_STATUS = CL_PROGRAM_BUILD_STATUS, PI_PROGRAM_BUILD_INFO_OPTIONS = CL_PROGRAM_BUILD_OPTIONS, @@ -137,6 +116,17 @@ typedef enum : pi_uint64 { PI_DEVICE_TYPE_ACC = CL_DEVICE_TYPE_ACCELERATOR } _pi_device_type; +typedef enum { + PI_DEVICE_MEM_CACHE_TYPE_NONE = CL_NONE, + PI_DEVICE_MEM_CACHE_TYPE_READ_ONLY_CACHE = CL_READ_ONLY_CACHE, + PI_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE = CL_READ_WRITE_CACHE +} _pi_device_mem_cache_type; + +typedef enum { + PI_DEVICE_LOCAL_MEM_TYPE_LOCAL = CL_LOCAL, + PI_DEVICE_LOCAL_MEM_TYPE_GLOBAL = CL_GLOBAL +} _pi_device_local_mem_type; + typedef enum { PI_DEVICE_INFO_TYPE = CL_DEVICE_TYPE, PI_DEVICE_INFO_VENDOR_ID = CL_DEVICE_VENDOR_ID, @@ -144,6 +134,10 @@ typedef enum { PI_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS = CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES = CL_DEVICE_MAX_WORK_ITEM_SIZES, PI_DEVICE_INFO_MAX_WORK_GROUP_SIZE = CL_DEVICE_MAX_WORK_GROUP_SIZE, + PI_DEVICE_INFO_SINGLE_FP_CONFIG = CL_DEVICE_SINGLE_FP_CONFIG, + PI_DEVICE_INFO_HALF_FP_CONFIG = CL_DEVICE_HALF_FP_CONFIG, + PI_DEVICE_INFO_DOUBLE_FP_CONFIG = CL_DEVICE_DOUBLE_FP_CONFIG, + PI_DEVICE_INFO_QUEUE_PROPERTIES = CL_DEVICE_QUEUE_PROPERTIES, PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR = CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT = @@ -174,23 +168,20 @@ typedef enum { PI_DEVICE_INFO_IMAGE_SUPPORT = CL_DEVICE_IMAGE_SUPPORT, PI_DEVICE_INFO_MAX_READ_IMAGE_ARGS = CL_DEVICE_MAX_READ_IMAGE_ARGS, PI_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS = CL_DEVICE_MAX_WRITE_IMAGE_ARGS, - PI_DEVICE_INFO_IMAGE2D_MAX_HEIGHT = CL_DEVICE_IMAGE2D_MAX_HEIGHT, PI_DEVICE_INFO_IMAGE2D_MAX_WIDTH = CL_DEVICE_IMAGE2D_MAX_WIDTH, - PI_DEVICE_INFO_IMAGE3D_MAX_HEIGHT = CL_DEVICE_IMAGE3D_MAX_HEIGHT, + PI_DEVICE_INFO_IMAGE2D_MAX_HEIGHT = CL_DEVICE_IMAGE2D_MAX_HEIGHT, PI_DEVICE_INFO_IMAGE3D_MAX_WIDTH = CL_DEVICE_IMAGE3D_MAX_WIDTH, + PI_DEVICE_INFO_IMAGE3D_MAX_HEIGHT = CL_DEVICE_IMAGE3D_MAX_HEIGHT, PI_DEVICE_INFO_IMAGE3D_MAX_DEPTH = CL_DEVICE_IMAGE3D_MAX_DEPTH, PI_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE = CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, PI_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE = CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, PI_DEVICE_INFO_MAX_SAMPLERS = CL_DEVICE_MAX_SAMPLERS, PI_DEVICE_INFO_MAX_PARAMETER_SIZE = CL_DEVICE_MAX_PARAMETER_SIZE, PI_DEVICE_INFO_MEM_BASE_ADDR_ALIGN = CL_DEVICE_MEM_BASE_ADDR_ALIGN, - PI_DEVICE_INFO_HALF_FP_CONFIG = CL_DEVICE_HALF_FP_CONFIG, - PI_DEVICE_INFO_SINGLE_FP_CONFIG = CL_DEVICE_SINGLE_FP_CONFIG, - PI_DEVICE_INFO_DOUBLE_FP_CONFIG = CL_DEVICE_DOUBLE_FP_CONFIG, PI_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE = CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, - PI_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE = CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, PI_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE = CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, + PI_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE = CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, PI_DEVICE_INFO_GLOBAL_MEM_SIZE = CL_DEVICE_GLOBAL_MEM_SIZE, PI_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE = CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, PI_DEVICE_INFO_MAX_CONSTANT_ARGS = CL_DEVICE_MAX_CONSTANT_ARGS, @@ -200,10 +191,10 @@ typedef enum { PI_DEVICE_INFO_HOST_UNIFIED_MEMORY = CL_DEVICE_HOST_UNIFIED_MEMORY, PI_DEVICE_INFO_PROFILING_TIMER_RESOLUTION = CL_DEVICE_PROFILING_TIMER_RESOLUTION, - PI_DEVICE_INFO_IS_ENDIAN_LITTLE = CL_DEVICE_ENDIAN_LITTLE, - PI_DEVICE_INFO_IS_AVAILABLE = CL_DEVICE_AVAILABLE, - PI_DEVICE_INFO_IS_COMPILER_AVAILABLE = CL_DEVICE_COMPILER_AVAILABLE, - PI_DEVICE_INFO_IS_LINKER_AVAILABLE = CL_DEVICE_LINKER_AVAILABLE, + PI_DEVICE_INFO_ENDIAN_LITTLE = CL_DEVICE_ENDIAN_LITTLE, + PI_DEVICE_INFO_AVAILABLE = CL_DEVICE_AVAILABLE, + PI_DEVICE_INFO_COMPILER_AVAILABLE = CL_DEVICE_COMPILER_AVAILABLE, + PI_DEVICE_INFO_LINKER_AVAILABLE = CL_DEVICE_LINKER_AVAILABLE, PI_DEVICE_INFO_EXECUTION_CAPABILITIES = CL_DEVICE_EXECUTION_CAPABILITIES, PI_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES = CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, @@ -222,34 +213,48 @@ typedef enum { PI_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC = CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, PI_DEVICE_INFO_PARENT_DEVICE = CL_DEVICE_PARENT_DEVICE, + PI_DEVICE_INFO_PARTITION_PROPERTIES = CL_DEVICE_PARTITION_PROPERTIES, PI_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES = CL_DEVICE_PARTITION_MAX_SUB_DEVICES, - PI_DEVICE_INFO_PARTITION_PROPERTIES = CL_DEVICE_PARTITION_PROPERTIES, PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN = CL_DEVICE_PARTITION_AFFINITY_DOMAIN, PI_DEVICE_INFO_PARTITION_TYPE = CL_DEVICE_PARTITION_TYPE, + PI_DEVICE_INFO_USM_HOST_SUPPORT = CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL, + PI_DEVICE_INFO_USM_DEVICE_SUPPORT = CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL, + PI_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT = + CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, + PI_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT = + CL_DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, + PI_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT = + CL_DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL } _pi_device_info; typedef enum { - PI_LOCAL_MEM_TYPE_LOCAL = CL_LOCAL, - PI_LOCAL_MEM_TYPE_GLOBAL = CL_GLOBAL -} _pi_local_mem_type; - -typedef intptr_t pi_context_properties; + PI_PROGRAM_INFO_REFERENCE_COUNT = CL_PROGRAM_REFERENCE_COUNT, + PI_PROGRAM_INFO_CONTEXT = CL_PROGRAM_CONTEXT, + PI_PROGRAM_INFO_NUM_DEVICES = CL_PROGRAM_NUM_DEVICES, + PI_PROGRAM_INFO_DEVICES = CL_PROGRAM_DEVICES, + PI_PROGRAM_INFO_SOURCE = CL_PROGRAM_SOURCE, + PI_PROGRAM_INFO_BINARY_SIZES = CL_PROGRAM_BINARY_SIZES, + PI_PROGRAM_INFO_BINARIES = CL_PROGRAM_BINARIES, + PI_PROGRAM_INFO_NUM_KERNELS = CL_PROGRAM_NUM_KERNELS, + PI_PROGRAM_INFO_KERNEL_NAMES = CL_PROGRAM_KERNEL_NAMES +} _pi_program_info; -// TODO: populate typedef enum { PI_CONTEXT_INFO_DEVICES = CL_CONTEXT_DEVICES, PI_CONTEXT_INFO_NUM_DEVICES = CL_CONTEXT_NUM_DEVICES, - PI_CONTEXT_INFO_REFERENCE_COUNT = CL_CONTEXT_REFERENCE_COUNT + PI_CONTEXT_INFO_PROPERTIES = CL_CONTEXT_PROPERTIES, + PI_CONTEXT_INFO_REFERENCE_COUNT = CL_CONTEXT_REFERENCE_COUNT, } _pi_context_info; -// TODO: populate typedef enum { + PI_QUEUE_INFO_CONTEXT = CL_QUEUE_CONTEXT, PI_QUEUE_INFO_DEVICE = CL_QUEUE_DEVICE, - PI_QUEUE_INFO_REFERENCE_COUNT = CL_QUEUE_REFERENCE_COUNT, + PI_QUEUE_INFO_DEVICE_DEFAULT = CL_QUEUE_DEVICE_DEFAULT, PI_QUEUE_INFO_PROPERTIES = CL_QUEUE_PROPERTIES, - PI_QUEUE_INFO_CONTEXT = CL_QUEUE_CONTEXT + PI_QUEUE_INFO_REFERENCE_COUNT = CL_QUEUE_REFERENCE_COUNT, + PI_QUEUE_INFO_SIZE = CL_QUEUE_SIZE } _pi_queue_info; typedef enum { @@ -262,12 +267,14 @@ typedef enum { } _pi_kernel_info; typedef enum { - PI_KERNEL_GROUP_INFO_SIZE = CL_KERNEL_WORK_GROUP_SIZE, - PI_KERNEL_COMPILE_GROUP_INFO_SIZE = CL_KERNEL_COMPILE_WORK_GROUP_SIZE, - PI_KERNEL_LOCAL_MEM_SIZE = CL_KERNEL_LOCAL_MEM_SIZE, - PI_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = + PI_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE = CL_KERNEL_GLOBAL_WORK_SIZE, + PI_KERNEL_GROUP_INFO_WORK_GROUP_SIZE = CL_KERNEL_WORK_GROUP_SIZE, + PI_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE = + CL_KERNEL_COMPILE_WORK_GROUP_SIZE, + PI_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE = CL_KERNEL_LOCAL_MEM_SIZE, + PI_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, - PI_KERNEL_PRIVATE_MEM_SIZE = CL_KERNEL_PRIVATE_MEM_SIZE + PI_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE = CL_KERNEL_PRIVATE_MEM_SIZE } _pi_kernel_group_info; typedef enum { @@ -280,6 +287,46 @@ typedef enum { PI_IMAGE_INFO_DEPTH = CL_IMAGE_DEPTH } _pi_image_info; +typedef enum { + PI_EVENT_INFO_COMMAND_QUEUE = CL_EVENT_COMMAND_QUEUE, + PI_EVENT_INFO_CONTEXT = CL_EVENT_CONTEXT, + PI_EVENT_INFO_COMMAND_TYPE = CL_EVENT_COMMAND_TYPE, + PI_EVENT_INFO_COMMAND_EXECUTION_STATUS = CL_EVENT_COMMAND_EXECUTION_STATUS, + PI_EVENT_INFO_REFERENCE_COUNT = CL_EVENT_REFERENCE_COUNT +} _pi_event_info; + +typedef enum { + PI_COMMAND_TYPE_NDRANGE_KERNEL = CL_COMMAND_NDRANGE_KERNEL, + PI_COMMAND_TYPE_MEM_BUFFER_READ = CL_COMMAND_READ_BUFFER, + PI_COMMAND_TYPE_MEM_BUFFER_WRITE = CL_COMMAND_WRITE_BUFFER, + PI_COMMAND_TYPE_MEM_BUFFER_COPY = CL_COMMAND_COPY_BUFFER, + PI_COMMAND_TYPE_MEM_BUFFER_MAP = CL_COMMAND_MAP_BUFFER, + PI_COMMAND_TYPE_MEM_BUFFER_UNMAP = CL_COMMAND_UNMAP_MEM_OBJECT, + PI_COMMAND_TYPE_MEM_BUFFER_READ_RECT = CL_COMMAND_READ_BUFFER_RECT, + PI_COMMAND_TYPE_MEM_BUFFER_WRITE_RECT = CL_COMMAND_WRITE_BUFFER_RECT, + PI_COMMAND_TYPE_MEM_BUFFER_COPY_RECT = CL_COMMAND_COPY_BUFFER_RECT, + PI_COMMAND_TYPE_USER = CL_COMMAND_USER, + PI_COMMAND_TYPE_MEM_BUFFER_FILL = CL_COMMAND_FILL_BUFFER, + PI_COMMAND_TYPE_IMAGE_READ = CL_COMMAND_READ_IMAGE, + PI_COMMAND_TYPE_IMAGE_WRITE = CL_COMMAND_WRITE_IMAGE, + PI_COMMAND_TYPE_IMAGE_COPY = CL_COMMAND_COPY_IMAGE, + PI_COMMAND_TYPE_NATIVE_KERNEL = CL_COMMAND_NATIVE_KERNEL, + PI_COMMAND_TYPE_COPY_BUFFER_TO_IMAGE = CL_COMMAND_COPY_BUFFER_TO_IMAGE, + PI_COMMAND_TYPE_COPY_IMAGE_TO_BUFFER = CL_COMMAND_COPY_IMAGE_TO_BUFFER, + PI_COMMAND_TYPE_MAP_IMAGE = CL_COMMAND_MAP_IMAGE, + PI_COMMAND_TYPE_MARKER = CL_COMMAND_MARKER, + PI_COMMAND_TYPE_ACQUIRE_GL_OBJECTS = CL_COMMAND_ACQUIRE_GL_OBJECTS, + PI_COMMAND_TYPE_RELEASE_GL_OBJECTS = CL_COMMAND_RELEASE_GL_OBJECTS, + PI_COMMAND_TYPE_BARRIER = CL_COMMAND_BARRIER, + PI_COMMAND_TYPE_MIGRATE_MEM_OBJECTS = CL_COMMAND_MIGRATE_MEM_OBJECTS, + PI_COMMAND_TYPE_FILL_IMAGE = CL_COMMAND_FILL_IMAGE, + PI_COMMAND_TYPE_SVM_FREE = CL_COMMAND_SVM_FREE, + PI_COMMAND_TYPE_SVM_MEMCPY = CL_COMMAND_SVM_MEMCPY, + PI_COMMAND_TYPE_SVM_MEMFILL = CL_COMMAND_SVM_MEMFILL, + PI_COMMAND_TYPE_SVM_MAP = CL_COMMAND_SVM_MAP, + PI_COMMAND_TYPE_SVM_UNMAP = CL_COMMAND_SVM_UNMAP +} _pi_command_type; + typedef enum { PI_MEM_TYPE_BUFFER = CL_MEM_OBJECT_BUFFER, PI_MEM_TYPE_IMAGE2D = CL_MEM_OBJECT_IMAGE2D, @@ -290,6 +337,27 @@ typedef enum { PI_MEM_TYPE_IMAGE1D_BUFFER = CL_MEM_OBJECT_IMAGE1D_BUFFER } _pi_mem_type; +typedef enum { + PI_MEM_ADVICE_SET_READ_MOSTLY = 0, ///< hints that memory will be read from + ///< frequently and written to rarely + PI_MEM_ADVICE_CLEAR_READ_MOSTLY, ///< removes the affect of + ///< PI_MEM_ADVICE_SET_READ_MOSTLY + PI_MEM_ADVICE_SET_PREFERRED_LOCATION, ///< hints that the preferred memory + ///< location is the specified device + PI_MEM_ADVICE_CLEAR_PREFERRED_LOCATION, ///< removes the affect of + ///< PI_MEM_ADVICE_SET_PREFERRED_LOCATION + PI_MEM_ADVICE_SET_ACCESSED_BY, ///< hints that memory will be accessed by the + ///< specified device + PI_MEM_ADVICE_CLEAR_ACCESSED_BY, ///< removes the affect of + ///< PI_MEM_ADVICE_SET_ACCESSED_BY + PI_MEM_ADVICE_SET_NON_ATOMIC_MOSTLY, ///< hints that memory will mostly be + ///< accessed non-atomically + PI_MEM_ADVICE_CLEAR_NON_ATOMIC_MOSTLY, ///< removes the affect of + ///< PI_MEM_ADVICE_SET_NON_ATOMIC_MOSTLY + PI_MEM_ADVICE_BIAS_CACHED, ///< hints that memory should be cached + PI_MEM_ADVICE_BIAS_UNCACHED ///< hints that memory should not be cached +} _pi_mem_advice; + typedef enum { PI_IMAGE_CHANNEL_ORDER_A = CL_A, PI_IMAGE_CHANNEL_ORDER_R = CL_R, @@ -329,7 +397,6 @@ typedef enum { PI_BUFFER_CREATE_TYPE_REGION = CL_BUFFER_CREATE_TYPE_REGION } _pi_buffer_create_type; -typedef pi_bitfield pi_sampler_properties; const pi_bool PI_TRUE = CL_TRUE; const pi_bool PI_FALSE = CL_FALSE; @@ -357,57 +424,86 @@ typedef enum { PI_SAMPLER_FILTER_MODE_LINEAR = CL_FILTER_LINEAR, } _pi_sampler_filter_mode; -typedef enum { - PI_EVENT_INFO_QUEUE = CL_EVENT_COMMAND_QUEUE, - PI_EVENT_INFO_COMMAND_TYPE = CL_EVENT_COMMAND_TYPE, - PI_EVENT_INFO_REFERENCE_COUNT = CL_EVENT_REFERENCE_COUNT, - PI_EVENT_INFO_COMMAND_EXECUTION_STATUS = CL_EVENT_COMMAND_EXECUTION_STATUS, - PI_EVENT_INFO_CONTEXT = CL_EVENT_CONTEXT -} _pi_event_info; +using pi_context_properties = intptr_t; + +using pi_device_exec_capabilities = pi_bitfield; +constexpr pi_device_exec_capabilities PI_DEVICE_EXEC_CAPABILITIES_KERNEL = + CL_EXEC_KERNEL; +constexpr pi_device_exec_capabilities + PI_DEVICE_EXEC_CAPABILITIES_NATIVE_KERNEL = CL_EXEC_NATIVE_KERNEL; + +using pi_sampler_properties = pi_bitfield; +constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_NORMALIZED_COORDS = + CL_SAMPLER_NORMALIZED_COORDS; +constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_ADDRESSING_MODE = + CL_SAMPLER_ADDRESSING_MODE; +constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_FILTER_MODE = + CL_SAMPLER_FILTER_MODE; // NOTE: this is made 64-bit to match the size of cl_mem_flags to // make the translation to OpenCL transparent. // TODO: populate // -typedef pi_bitfield pi_mem_flags; +using pi_mem_flags = pi_bitfield; // Access -const pi_mem_flags PI_MEM_FLAGS_ACCESS_RW = CL_MEM_READ_WRITE; +constexpr pi_mem_flags PI_MEM_FLAGS_ACCESS_RW = CL_MEM_READ_WRITE; // Host pointer -const pi_mem_flags PI_MEM_FLAGS_HOST_PTR_USE = CL_MEM_USE_HOST_PTR; -const pi_mem_flags PI_MEM_FLAGS_HOST_PTR_COPY = CL_MEM_COPY_HOST_PTR; +constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_USE = CL_MEM_USE_HOST_PTR; +constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_COPY = CL_MEM_COPY_HOST_PTR; // NOTE: queue properties are implemented this way to better support bit // manipulations -typedef pi_bitfield pi_queue_properties; -const pi_queue_properties PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = +using pi_queue_properties = pi_bitfield; +constexpr pi_queue_properties PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; -const pi_queue_properties PI_QUEUE_PROFILING_ENABLE = CL_QUEUE_PROFILING_ENABLE; -const pi_queue_properties PI_QUEUE_ON_DEVICE = CL_QUEUE_ON_DEVICE; -const pi_queue_properties PI_QUEUE_ON_DEVICE_DEFAULT = +constexpr pi_queue_properties PI_QUEUE_PROFILING_ENABLE = + CL_QUEUE_PROFILING_ENABLE; +constexpr pi_queue_properties PI_QUEUE_ON_DEVICE = CL_QUEUE_ON_DEVICE; +constexpr pi_queue_properties PI_QUEUE_ON_DEVICE_DEFAULT = CL_QUEUE_ON_DEVICE_DEFAULT; -typedef _pi_result pi_result; -typedef _pi_platform_info pi_platform_info; -typedef _pi_device_type pi_device_type; -typedef _pi_device_info pi_device_info; -typedef _pi_context_info pi_context_info; -typedef _pi_queue_info pi_queue_info; -typedef _pi_image_info pi_image_info; -typedef _pi_mem_type pi_mem_type; -typedef _pi_image_channel_order pi_image_channel_order; -typedef _pi_image_channel_type pi_image_channel_type; -typedef _pi_buffer_create_type pi_buffer_create_type; -typedef _pi_sampler_addressing_mode pi_sampler_addressing_mode; -typedef _pi_sampler_filter_mode pi_sampler_filter_mode; -typedef _pi_sampler_info pi_sampler_info; -typedef _pi_event_status pi_event_status; -typedef _pi_event_info pi_event_info; -typedef _pi_command_type pi_command_type; -typedef _pi_program_info pi_program_info; -typedef _pi_program_build_info pi_program_build_info; -typedef _pi_program_build_status pi_program_build_status; -typedef _pi_kernel_info pi_kernel_info; -typedef _pi_kernel_group_info pi_kernel_group_info; +using pi_result = _pi_result; +using pi_platform_info = _pi_platform_info; +using pi_device_type = _pi_device_type; +using pi_device_mem_cache_type = _pi_device_mem_cache_type; +using pi_device_local_mem_type = _pi_device_local_mem_type; +using pi_device_info = _pi_device_info; +using pi_program_info = _pi_program_info; +using pi_context_info = _pi_context_info; +using pi_queue_info = _pi_queue_info; +using pi_image_info = _pi_image_info; +using pi_kernel_info = _pi_kernel_info; +using pi_kernel_group_info = _pi_kernel_group_info; +using pi_event_info = _pi_event_info; +using pi_command_type = _pi_command_type; +using pi_mem_type = _pi_mem_type; +using pi_mem_advice = _pi_mem_advice; +using pi_image_channel_order = _pi_image_channel_order; +using pi_image_channel_type = _pi_image_channel_type; +using pi_buffer_create_type = _pi_buffer_create_type; +using pi_sampler_addressing_mode = _pi_sampler_addressing_mode; +using pi_sampler_filter_mode = _pi_sampler_filter_mode; +using pi_sampler_info = _pi_sampler_info; +using pi_event_status = _pi_event_status; +using pi_program_build_info = _pi_program_build_info; +using pi_program_build_status = _pi_program_build_status; +using pi_kernel_info = _pi_kernel_info; + +// For compatibility with OpenCL define this not as enum. +using pi_device_partition_property = intptr_t; +static constexpr pi_device_partition_property PI_DEVICE_PARTITION_EQUALLY = + CL_DEVICE_PARTITION_EQUALLY; +static constexpr pi_device_partition_property + PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN = + CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; + +// For compatibility with OpenCL define this not as enum. +using pi_device_affinity_domain = pi_bitfield; +static constexpr pi_device_affinity_domain PI_DEVICE_AFFINITY_DOMAIN_NUMA = + CL_DEVICE_AFFINITY_DOMAIN_NUMA; +static constexpr pi_device_affinity_domain + PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = + CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE; // Entry type, matches OpenMP for compatibility struct _pi_offload_entry_struct { @@ -418,19 +514,19 @@ struct _pi_offload_entry_struct { int32_t reserved; }; -typedef _pi_offload_entry_struct *_pi_offload_entry; +using _pi_offload_entry = _pi_offload_entry_struct *; /// Types of device binary. -typedef uint8_t pi_device_binary_type; +using pi_device_binary_type = uint8_t; // format is not determined -static const pi_device_binary_type PI_DEVICE_BINARY_TYPE_NONE = 0; +static constexpr pi_device_binary_type PI_DEVICE_BINARY_TYPE_NONE = 0; // specific to a device -static const pi_device_binary_type PI_DEVICE_BINARY_TYPE_NATIVE = 1; +static constexpr pi_device_binary_type PI_DEVICE_BINARY_TYPE_NATIVE = 1; // portable binary types go next // SPIR-V -static const pi_device_binary_type PI_DEVICE_BINARY_TYPE_SPIRV = 2; +static constexpr pi_device_binary_type PI_DEVICE_BINARY_TYPE_SPIRV = 2; // LLVM bitcode -static const pi_device_binary_type PI_DEVICE_BINARY_TYPE_LLVMIR_BITCODE = 3; +static constexpr pi_device_binary_type PI_DEVICE_BINARY_TYPE_LLVMIR_BITCODE = 3; // Device binary descriptor version supported by this library. static const uint16_t PI_DEVICE_BINARY_VERSION = 1; @@ -500,7 +596,7 @@ struct pi_device_binary_struct { _pi_offload_entry EntriesBegin; _pi_offload_entry EntriesEnd; }; -typedef pi_device_binary_struct *pi_device_binary; +using pi_device_binary = pi_device_binary_struct *; // Offload binaries descriptor version supported by this library. static const uint16_t PI_DEVICE_BINARIES_VERSION = 1; @@ -521,7 +617,7 @@ struct pi_device_binaries_struct { _pi_offload_entry *HostEntriesBegin; _pi_offload_entry *HostEntriesEnd; }; -typedef pi_device_binaries_struct *pi_device_binaries; +using pi_device_binaries = pi_device_binaries_struct *; // Opaque types that make reading build log errors easier. struct _pi_platform; @@ -534,15 +630,15 @@ struct _pi_kernel; struct _pi_event; struct _pi_sampler; -typedef _pi_platform *pi_platform; -typedef _pi_device *pi_device; -typedef _pi_context *pi_context; -typedef _pi_queue *pi_queue; -typedef _pi_mem *pi_mem; -typedef _pi_program *pi_program; -typedef _pi_kernel *pi_kernel; -typedef _pi_event *pi_event; -typedef _pi_sampler *pi_sampler; +using pi_platform = _pi_platform *; +using pi_device = _pi_device *; +using pi_context = _pi_context *; +using pi_queue = _pi_queue *; +using pi_mem = _pi_mem *; +using pi_program = _pi_program *; +using pi_kernel = _pi_kernel *; +using pi_event = _pi_event *; +using pi_sampler = _pi_sampler *; typedef struct { pi_image_channel_order image_channel_order; @@ -562,8 +658,8 @@ typedef struct { pi_mem buffer; } _pi_image_desc; -typedef _pi_image_format pi_image_format; -typedef _pi_image_desc pi_image_desc; +using pi_image_format = _pi_image_format; +using pi_image_desc = _pi_image_desc; // // Following section contains SYCL RT Plugin Interface (PI) functions. // They are 3 distinct categories: @@ -578,7 +674,7 @@ typedef _pi_image_desc pi_image_desc; // struct _pi_plugin; -typedef _pi_plugin pi_plugin; +using pi_plugin = _pi_plugin; // PI Plugin Initialise. // Plugin will check the PI version of Plugin Interface, @@ -612,10 +708,10 @@ pi_result piDeviceRetain(pi_device device); pi_result piDeviceRelease(pi_device device); -pi_result piDevicePartition( - pi_device device, - const cl_device_partition_property *properties, // TODO: untie from OpenCL - pi_uint32 num_devices, pi_device *out_devices, pi_uint32 *out_num_devices); +pi_result piDevicePartition(pi_device device, + const pi_device_partition_property *properties, + pi_uint32 num_devices, pi_device *out_devices, + pi_uint32 *out_num_devices); /// Selects the most appropriate device binary based on runtime information /// and the IR characteristics. @@ -758,7 +854,7 @@ typedef enum { PI_USM_PTRS = CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL } _pi_kernel_exec_info; -typedef _pi_kernel_exec_info pi_kernel_exec_info; +using pi_kernel_exec_info = _pi_kernel_exec_info; pi_result piKernelCreate(pi_program program, const char *kernel_name, pi_kernel *ret_kernel); @@ -1016,12 +1112,12 @@ typedef enum : pi_bitfield { PI_USM_MIGRATION_TBD0 = (1 << 0) } _pi_usm_migration_flags; -typedef _pi_usm_capability_query pi_usm_capability_query; -typedef _pi_usm_capabilities pi_usm_capabilities; -typedef _pi_mem_info pi_mem_info; -typedef _pi_usm_type pi_usm_type; -typedef _pi_usm_mem_properties pi_usm_mem_properties; -typedef _pi_usm_migration_flags pi_usm_migration_flags; +using pi_usm_capability_query = _pi_usm_capability_query; +using pi_usm_capabilities = _pi_usm_capabilities; +using pi_mem_info = _pi_mem_info; +using pi_usm_type = _pi_usm_type; +using pi_usm_mem_properties = _pi_usm_mem_properties; +using pi_usm_migration_flags = _pi_usm_migration_flags; /// Allocates host memory accessible by the device. /// diff --git a/sycl/include/CL/sycl/queue.hpp b/sycl/include/CL/sycl/queue.hpp index c315ccff3e960..2b0fae897fa88 100644 --- a/sycl/include/CL/sycl/queue.hpp +++ b/sycl/include/CL/sycl/queue.hpp @@ -290,7 +290,7 @@ class queue { /// \param Length is a number of bytes in the allocation. /// \param Advice is a device-defined advice for the specified allocation. /// \return an event representing advice operation. - event mem_advise(const void *Ptr, size_t Length, int Advice); + event mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice); /// Provides hints to the runtime library that data should be made available /// on a device earlier than Unified Shared Memory would normally require it diff --git a/sycl/source/detail/error_handling/enqueue_kernel.cpp b/sycl/source/detail/error_handling/enqueue_kernel.cpp index 3180cb5ef5364..ded4d1e6c8e71 100644 --- a/sycl/source/detail/error_handling/enqueue_kernel.cpp +++ b/sycl/source/detail/error_handling/enqueue_kernel.cpp @@ -40,8 +40,8 @@ bool oclHandleInvalidWorkGroupSize(const device_impl &DeviceImpl, size_t CompileWGSize[3] = {0}; Plugin.call( - Kernel, Device, PI_KERNEL_COMPILE_GROUP_INFO_SIZE, sizeof(size_t) * 3, - CompileWGSize, nullptr); + Kernel, Device, PI_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE, + sizeof(size_t) * 3, CompileWGSize, nullptr); if (CompileWGSize[0] != 0) { // OpenCL 1.x && 2.0: @@ -90,10 +90,11 @@ bool oclHandleInvalidWorkGroupSize(const device_impl &DeviceImpl, // PI_INVALID_WORK_GROUP_SIZE if local_work_size is specified and the // total number of work-items in the work-group computed as // local_work_size[0] * ... * local_work_size[work_dim – 1] is greater - // than the value specified by PI_KERNEL_GROUP_INFO_SIZE in table 5.21. + // than the value specified by PI_KERNEL_GROUP_INFO_WORK_GROUP_SIZE in + // table 5.21. size_t KernelWGSize = 0; Plugin.call( - Kernel, Device, PI_KERNEL_GROUP_INFO_SIZE, sizeof(size_t), + Kernel, Device, PI_KERNEL_GROUP_INFO_WORK_GROUP_SIZE, sizeof(size_t), &KernelWGSize, nullptr); const size_t TotalNumberOfWIs = NDRDesc.LocalSize[0] * NDRDesc.LocalSize[1] * NDRDesc.LocalSize[2]; diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 1adb3b85dd39c..b4678181df937 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -62,9 +62,7 @@ RT::PiEvent &event_impl::getHandleRef() { return MEvent; } const ContextImplPtr &event_impl::getContextImpl() { return MContext; } -const plugin &event_impl::getPlugin() const { - return MContext->getPlugin(); -} +const plugin &event_impl::getPlugin() const { return MContext->getPlugin(); } void event_impl::setContextImpl(const ContextImplPtr &Context) { MHostEvent = Context->is_host(); @@ -84,8 +82,9 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext) } RT::PiContext TempContext; - getPlugin().call( - MEvent, CL_EVENT_CONTEXT, sizeof(RT::PiContext), &TempContext, nullptr); + getPlugin().call(MEvent, PI_EVENT_INFO_CONTEXT, + sizeof(RT::PiContext), + &TempContext, nullptr); if (MContext->getHandleRef() != TempContext) { throw cl::sycl::invalid_parameter_error( "The syclContext must match the OpenCL context associated with the " diff --git a/sycl/source/detail/event_info.hpp b/sycl/source/detail/event_info.hpp index e2ba912cd6d70..e3f487f063ce7 100644 --- a/sycl/source/detail/event_info.hpp +++ b/sycl/source/detail/event_info.hpp @@ -36,7 +36,7 @@ template struct get_event_info { static RetType get(RT::PiEvent Event, const plugin &Plugin) { RetType Result = (RetType)0; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin.call(Event, cl_profiling_info(Param), + Plugin.call(Event, pi_event_info(Param), sizeof(Result), &Result, nullptr); return Result; } diff --git a/sycl/source/detail/program_impl.cpp b/sycl/source/detail/program_impl.cpp index 205c5da8c219c..6cd2f6b0380e8 100644 --- a/sycl/source/detail/program_impl.cpp +++ b/sycl/source/detail/program_impl.cpp @@ -84,10 +84,11 @@ program_impl::program_impl(ContextImplPtr Context, RT::PiProgram Program) : MProgram(Program), MContext(Context), MLinkable(true) { // TODO handle the case when cl_program build is in progress - cl_uint NumDevices; + pi_uint32 NumDevices; const detail::plugin &Plugin = getPlugin(); - Plugin.call( - Program, PI_PROGRAM_INFO_NUM_DEVICES, sizeof(cl_uint), &NumDevices, nullptr); + Plugin.call(Program, PI_PROGRAM_INFO_NUM_DEVICES, + sizeof(pi_uint32), &NumDevices, + nullptr); vector_class PiDevices(NumDevices); Plugin.call(Program, PI_PROGRAM_INFO_DEVICES, sizeof(RT::PiDevice) * NumDevices, @@ -267,8 +268,8 @@ vector_class> program_impl::get_binaries() const { if (!is_host()) { vector_class BinarySizes(MDevices.size()); Plugin.call( - MProgram, PI_PROGRAM_INFO_BINARY_SIZES, sizeof(size_t) * BinarySizes.size(), - BinarySizes.data(), nullptr); + MProgram, PI_PROGRAM_INFO_BINARY_SIZES, + sizeof(size_t) * BinarySizes.size(), BinarySizes.data(), nullptr); vector_class Pointers; for (size_t I = 0; I < BinarySizes.size(); ++I) { @@ -337,12 +338,12 @@ vector_class program_impl::get_pi_devices() const { bool program_impl::has_cl_kernel(const string_class &KernelName) const { size_t Size; const detail::plugin &Plugin = getPlugin(); - Plugin.call(MProgram, PI_PROGRAM_INFO_KERNEL_NAMES, 0, - nullptr, &Size); + Plugin.call( + MProgram, PI_PROGRAM_INFO_KERNEL_NAMES, 0, nullptr, &Size); string_class ClResult(Size, ' '); - Plugin.call(MProgram, PI_PROGRAM_INFO_KERNEL_NAMES, - ClResult.size(), &ClResult[0], - nullptr); + Plugin.call( + MProgram, PI_PROGRAM_INFO_KERNEL_NAMES, ClResult.size(), &ClResult[0], + nullptr); // Get rid of the null terminator ClResult.pop_back(); vector_class KernelNames(split_string(ClResult, ';')); @@ -411,10 +412,11 @@ cl_uint program_impl::get_info() const { throw invalid_object_error("This instance of program is a host instance", PI_INVALID_PROGRAM); } - cl_uint Result; + pi_uint32 Result; const detail::plugin &Plugin = getPlugin(); - Plugin.call(MProgram, PI_PROGRAM_INFO_REFERENCE_COUNT, - sizeof(cl_uint), &Result, nullptr); + Plugin.call(MProgram, + PI_PROGRAM_INFO_REFERENCE_COUNT, + sizeof(pi_uint32), &Result, nullptr); return Result; } diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 6b369bd0f9bb7..0d95d886b5061 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -70,7 +70,7 @@ static RT::PiProgram createBinaryProgram(const ContextImplPtr Context, // FIXME: we don't yet support multiple devices with a single binary. const detail::plugin &Plugin = Context->getPlugin(); #ifndef _NDEBUG - cl_uint NumDevices = 0; + pi_uint32 NumDevices = 0; Plugin.call(Context->getHandleRef(), PI_CONTEXT_INFO_NUM_DEVICES, sizeof(NumDevices), &NumDevices, @@ -438,7 +438,7 @@ ProgramManager::getClProgramFromClKernel(RT::PiKernel Kernel, RT::PiProgram Program; const detail::plugin &Plugin = Context->getPlugin(); Plugin.call( - Kernel, PI_KERNEL_INFO_PROGRAM, sizeof(cl_program), &Program, nullptr); + Kernel, PI_KERNEL_INFO_PROGRAM, sizeof(RT::PiProgram), &Program, nullptr); return Program; } @@ -449,8 +449,8 @@ string_class ProgramManager::getProgramBuildLog(const RT::PiProgram &Program, Plugin.call(Program, PI_PROGRAM_INFO_DEVICES, 0, nullptr, &Size); vector_class PIDevices(Size / sizeof(RT::PiDevice)); - Plugin.call(Program, PI_PROGRAM_INFO_DEVICES, Size, - PIDevices.data(), nullptr); + Plugin.call(Program, PI_PROGRAM_INFO_DEVICES, + Size, PIDevices.data(), nullptr); string_class Log = "The program was built for " + std::to_string(PIDevices.size()) + " devices"; for (RT::PiDevice &Device : PIDevices) { diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index ddc9883cb610e..317e6efde46a8 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -69,7 +69,8 @@ event queue_impl::memcpy(shared_ptr_class Impl, void *Dest, return ResEvent; } -event queue_impl::mem_advise(const void *Ptr, size_t Length, int Advice) { +event queue_impl::mem_advise(const void *Ptr, size_t Length, + pi_mem_advice Advice) { context Context = get_context(); if (Context.is_host()) { return event(); diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index ef94d73a086c6..faf58914f2354 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -336,7 +336,7 @@ class queue_impl { /// \param Ptr is a USM pointer to the allocation. /// \param Length is a number of bytes in the allocation. /// \param Advice is a device-defined advice for the specified allocation. - event mem_advise(const void *Ptr, size_t Length, int Advice); + event mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice); /// Puts exception to the list of asynchronous ecxeptions. /// diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index e9425a3e47783..a845e9362f7b2 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -1643,11 +1643,11 @@ cl_int ExecCGCommand::enqueueImp() { pi_mem MemArg = (pi_mem)AllocaCmd->getMemAllocation(); Plugin.call(Kernel, Arg.MIndex, &MemArg); #else - cl_mem MemArg = (cl_mem)AllocaCmd->getMemAllocation(); + RT::PiMem MemArg = (RT::PiMem)AllocaCmd->getMemAllocation(); Plugin.call(Kernel, Arg.MIndex, - sizeof(cl_mem), &MemArg); + sizeof(RT::PiMem), &MemArg); Plugin.call(Kernel, Arg.MIndex, - sizeof(cl_mem), &MemArg); + sizeof(RT::PiMem), &MemArg); #endif break; } diff --git a/sycl/source/queue.cpp b/sycl/source/queue.cpp index e20b8e6016725..7cf8e32733b80 100644 --- a/sycl/source/queue.cpp +++ b/sycl/source/queue.cpp @@ -99,7 +99,7 @@ event queue::memcpy(void *dest, const void *src, size_t count) { return impl->memcpy(impl, dest, src, count); } -event queue::mem_advise(const void *ptr, size_t length, int advice) { +event queue::mem_advise(const void *ptr, size_t length, pi_mem_advice advice) { return impl->mem_advise(ptr, length, advice); } diff --git a/sycl/test/usm/memadvise.cpp b/sycl/test/usm/memadvise.cpp index a7e152b02d946..111519169c7ac 100644 --- a/sycl/test/usm/memadvise.cpp +++ b/sycl/test/usm/memadvise.cpp @@ -37,7 +37,7 @@ int main() { if (s_head == nullptr) { return -1; } - q.mem_advise(s_head, sizeof(Node), 42); + q.mem_advise(s_head, sizeof(Node), PI_MEM_ADVICE_SET_READ_MOSTLY); Node *s_cur = s_head; for (int i = 0; i < numNodes; i++) { @@ -48,7 +48,7 @@ int main() { if (s_cur->pNext == nullptr) { return -1; } - q.mem_advise(s_cur->pNext, sizeof(Node), 42); + q.mem_advise(s_cur->pNext, sizeof(Node), PI_MEM_ADVICE_SET_READ_MOSTLY); } else { s_cur->pNext = nullptr; }