32 std::vector<info::fp_config> result;
34 result.push_back(info::fp_config::denorm);
36 result.push_back(info::fp_config::inf_nan);
38 result.push_back(info::fp_config::round_to_nearest);
40 result.push_back(info::fp_config::round_to_zero);
42 result.push_back(info::fp_config::round_to_inf);
46 result.push_back(info::fp_config::soft_float);
48 result.push_back(info::fp_config::correctly_rounded_divide_sqrt);
52 inline std::vector<info::partition_affinity_domain>
54 std::vector<info::partition_affinity_domain> result;
56 result.push_back(info::partition_affinity_domain::numa);
58 result.push_back(info::partition_affinity_domain::L4_cache);
60 result.push_back(info::partition_affinity_domain::L3_cache);
62 result.push_back(info::partition_affinity_domain::L2_cache);
64 result.push_back(info::partition_affinity_domain::L1_cache);
66 result.push_back(info::partition_affinity_domain::next_partitionable);
70 inline std::vector<info::execution_capability>
72 std::vector<info::execution_capability> result;
74 result.push_back(info::execution_capability::exec_kernel);
76 result.push_back(info::execution_capability::exec_native_kernel);
90 static const info::device value = info::device::native_vector_width_half;
94 static const info::device value = info::device::native_vector_width_double;
105 pi::cast<RT::PiDeviceInfo>(param),
106 sizeof(result), &result,
nullptr);
116 pi::cast<RT::PiDeviceInfo>(param),
117 sizeof(result), &result,
nullptr);
121 return createSyclObjFromImpl<platform>(
122 platform_impl::getOrMakePlatformImpl(result, Plugin));
130 size_t resultSize = 0;
132 dev, pi::cast<RT::PiDeviceInfo>(param), 0,
nullptr, &resultSize);
133 if (resultSize == 0) {
134 return std::string();
136 std::unique_ptr<char[]> result(
new char[resultSize]);
138 pi::cast<RT::PiDeviceInfo>(param),
139 resultSize, result.get(),
nullptr);
141 return std::string(result.get());
162 pi::cast<RT::PiDeviceInfo>(param),
163 sizeof(result), &result,
nullptr);
164 return id<3>(result[0], result[1], result[2]);
169 template <info::device param>
180 cl_device_fp_config result;
182 pi::cast<RT::PiDeviceInfo>(param),
183 sizeof(result), &result,
nullptr);
197 auto dotPos = result.find(
'.');
198 if (dotPos == std::string::npos)
201 auto leftPos = result.rfind(
' ', dotPos);
202 if (leftPos == std::string::npos)
207 auto rightPos = result.find(
' ', dotPos);
208 return result.substr(leftPos, rightPos - leftPos);
215 info::device::single_fp_config> {
220 dev, pi::cast<RT::PiDeviceInfo>(info::device::single_fp_config),
221 sizeof(result), &result,
nullptr);
229 cl_command_queue_properties result;
231 dev, pi::cast<RT::PiDeviceInfo>(info::device::queue_profiling),
232 sizeof(result), &result,
nullptr);
233 return (result & CL_QUEUE_PROFILING_ENABLE);
240 info::device::atomic_memory_order_capabilities> {
245 pi::cast<RT::PiDeviceInfo>(
246 info::device::atomic_memory_order_capabilities),
255 info::device::atomic_memory_scope_capabilities> {
260 pi::cast<RT::PiDeviceInfo>(
261 info::device::atomic_memory_scope_capabilities),
274 dev, pi::cast<RT::PiDeviceInfo>(info::device::ext_oneapi_bfloat16),
275 sizeof(result), &result,
nullptr);
276 if (Err != PI_SUCCESS) {
286 info::device::execution_capabilities> {
291 dev, pi::cast<RT::PiDeviceInfo>(info::device::execution_capabilities),
292 sizeof(result), &result,
nullptr);
300 info::device::built_in_kernel_ids> {
307 std::vector<kernel_id> ids;
308 ids.reserve(names.size());
309 for (
const auto &name : names) {
310 ids.push_back(ProgramManager::getInstance().getBuiltInKernelID(name));
319 info::device::built_in_kernels> {
341 case info::partition_property::no_partition:
342 case info::partition_property::partition_equally:
343 case info::partition_property::partition_by_counts:
344 case info::partition_property::partition_by_affinity_domain:
353 info::device::partition_properties> {
356 auto info_partition =
357 pi::cast<RT::PiDeviceInfo>(info::device::partition_properties);
363 size_t arrayLength = resultSize /
sizeof(cl_device_partition_property);
364 if (arrayLength == 0) {
367 std::unique_ptr<cl_device_partition_property[]> arrayResult(
368 new cl_device_partition_property[arrayLength]);
370 arrayResult.get(),
nullptr);
372 std::vector<info::partition_property> result;
373 for (
size_t i = 0; i < arrayLength; ++i) {
379 result.push_back(pp);
388 info::device::partition_affinity_domains> {
389 static std::vector<info::partition_affinity_domain>
394 pi::cast<RT::PiDeviceInfo>(info::device::partition_affinity_domains),
395 sizeof(result), &result,
nullptr);
404 info::device::partition_type_affinity_domain> {
410 pi::cast<RT::PiDeviceInfo>(
411 info::device::partition_type_affinity_domain),
412 0,
nullptr, &resultSize);
413 if (resultSize != 1) {
414 return info::partition_affinity_domain::not_applicable;
416 cl_device_partition_property result;
419 pi::cast<RT::PiDeviceInfo>(
420 info::device::partition_type_affinity_domain),
421 sizeof(result), &result,
nullptr);
430 return info::partition_affinity_domain::not_applicable;
437 info::device::partition_type_property> {
441 0,
nullptr, &resultSize);
443 return info::partition_property::no_partition;
445 size_t arrayLength = resultSize /
sizeof(cl_device_partition_property);
447 std::unique_ptr<cl_device_partition_property[]> arrayResult(
448 new cl_device_partition_property[arrayLength]);
450 resultSize, arrayResult.get(),
453 return info::partition_property::no_partition;
461 size_t resultSize = 0;
463 dev, pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes), 0,
464 nullptr, &resultSize);
466 std::vector<size_t> result(resultSize /
sizeof(
size_t));
468 dev, pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
469 resultSize, result.data(),
nullptr);
484 std::string platform_name = plt.
get_info<info::platform::name>();
485 if (platform_name ==
"Intel(R) FPGA Emulation Platform for OpenCL(TM)" ||
486 platform_name ==
"Intel(R) FPGA SDK for OpenCL(TM)")
504 dev, pi::cast<RT::PiDeviceInfo>(info::device::max_work_item_sizes),
505 sizeof(result), &result,
nullptr);
506 return id<3>(result[2], result[1], result[0]);
512 info::device::ext_oneapi_max_global_work_groups> {
525 size_t, info::device::ext_oneapi_max_global_work_groups>
::get(dev,
529 pi::cast<RT::PiDeviceInfo>(info::device::ext_oneapi_max_work_groups_3d),
530 sizeof(result), &result,
nullptr);
531 return id<1>(std::min(Limit, result[0]));
540 size_t, info::device::ext_oneapi_max_global_work_groups>
::get(dev,
544 pi::cast<RT::PiDeviceInfo>(info::device::ext_oneapi_max_work_groups_3d),
545 sizeof(result), &result,
nullptr);
546 return id<2>(std::min(Limit, result[1]), std::min(Limit, result[0]));
555 size_t, info::device::ext_oneapi_max_global_work_groups>
::get(dev,
559 pi::cast<RT::PiDeviceInfo>(info::device::ext_oneapi_max_work_groups_3d),
560 sizeof(result), &result,
nullptr);
561 return id<3>(std::min(Limit, result[2]), std::min(Limit, result[1]),
562 std::min(Limit, result[0]));
571 dev, pi::cast<RT::PiDeviceInfo>(info::device::parent_device),
572 sizeof(result), &result,
nullptr);
573 if (result ==
nullptr)
574 throw invalid_object_error(
575 "No parent for device because it is not a subdevice",
576 PI_ERROR_INVALID_DEVICE);
579 std::shared_ptr<detail::platform_impl> Platform =
580 platform_impl::getPlatformFromPiDevice(dev, Plugin);
581 return createSyclObjFromImpl<device>(
582 Platform->getOrMakeDeviceImpl(result, Platform));
590 template <info::device param>
596 return info::device_type::host;
599 template <>
inline uint32_t get_device_info_host<info::device::vendor_id>() {
604 inline uint32_t get_device_info_host<info::device::max_compute_units>() {
605 return std::thread::hardware_concurrency();
609 inline uint32_t get_device_info_host<info::device::max_work_item_dimensions>() {
614 inline id<3> get_device_info_host<info::device::max_work_item_sizes>() {
620 inline constexpr
size_t
621 get_device_info_host<info::device::ext_oneapi_max_global_work_groups>() {
628 get_device_info_host<info::device::ext_oneapi_max_work_groups_1d>() {
630 static constexpr
size_t Limit =
631 get_device_info_host<info::device::ext_oneapi_max_global_work_groups>();
637 get_device_info_host<info::device::ext_oneapi_max_work_groups_2d>() {
639 static constexpr
size_t Limit =
640 get_device_info_host<info::device::ext_oneapi_max_global_work_groups>();
641 return {Limit, Limit};
646 get_device_info_host<info::device::ext_oneapi_max_work_groups_3d>() {
648 static constexpr
size_t Limit =
649 get_device_info_host<info::device::ext_oneapi_max_global_work_groups>();
650 return {Limit, Limit, Limit};
654 inline size_t get_device_info_host<info::device::max_work_group_size>() {
661 get_device_info_host<info::device::preferred_vector_width_char>() {
668 get_device_info_host<info::device::preferred_vector_width_short>() {
675 get_device_info_host<info::device::preferred_vector_width_int>() {
682 get_device_info_host<info::device::preferred_vector_width_long>() {
689 get_device_info_host<info::device::preferred_vector_width_float>() {
696 get_device_info_host<info::device::preferred_vector_width_double>() {
703 get_device_info_host<info::device::preferred_vector_width_half>() {
709 inline uint32_t get_device_info_host<info::device::native_vector_width_char>() {
710 return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Char);
715 get_device_info_host<info::device::native_vector_width_short>() {
716 return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Short);
720 inline uint32_t get_device_info_host<info::device::native_vector_width_int>() {
721 return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Int);
725 inline uint32_t get_device_info_host<info::device::native_vector_width_long>() {
726 return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Long);
731 get_device_info_host<info::device::native_vector_width_float>() {
732 return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Float);
737 get_device_info_host<info::device::native_vector_width_double>() {
738 return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Double);
742 inline uint32_t get_device_info_host<info::device::native_vector_width_half>() {
743 return PlatformUtil::getNativeVectorWidth(PlatformUtil::TypeIndex::Half);
747 inline uint32_t get_device_info_host<info::device::max_clock_frequency>() {
748 return PlatformUtil::getMaxClockFrequency();
751 template <>
inline uint32_t get_device_info_host<info::device::address_bits>() {
752 return sizeof(
void *) * 8;
756 inline uint64_t get_device_info_host<info::device::global_mem_size>() {
757 return static_cast<uint64_t
>(OSUtil::getOSMemSize());
761 inline uint64_t get_device_info_host<info::device::max_mem_alloc_size>() {
763 const uint64_t
a = get_device_info_host<info::device::global_mem_size>() / 4;
764 const uint64_t b = 128ul * 1024 * 1024;
765 return (
a > b) ?
a : b;
768 template <>
inline bool get_device_info_host<info::device::image_support>() {
772 template <>
inline bool get_device_info_host<info::device::atomic64>() {
777 inline std::vector<memory_order>
778 get_device_info_host<info::device::atomic_memory_order_capabilities>() {
779 return {memory_order::relaxed, memory_order::acquire, memory_order::release,
780 memory_order::acq_rel, memory_order::seq_cst};
784 inline std::vector<memory_scope>
785 get_device_info_host<info::device::atomic_memory_scope_capabilities>() {
786 return {memory_scope::work_item, memory_scope::sub_group,
791 inline bool get_device_info_host<info::device::ext_oneapi_bfloat16>() {
796 inline uint32_t get_device_info_host<info::device::max_read_image_args>() {
802 inline uint32_t get_device_info_host<info::device::max_write_image_args>() {
808 inline size_t get_device_info_host<info::device::image2d_max_width>() {
824 inline size_t get_device_info_host<info::device::image2d_max_height>() {
840 inline size_t get_device_info_host<info::device::image3d_max_width>() {
856 inline size_t get_device_info_host<info::device::image3d_max_height>() {
872 inline size_t get_device_info_host<info::device::image3d_max_depth>() {
888 inline size_t get_device_info_host<info::device::image_max_buffer_size>() {
894 inline size_t get_device_info_host<info::device::image_max_array_size>() {
899 template <>
inline uint32_t get_device_info_host<info::device::max_samplers>() {
905 inline size_t get_device_info_host<info::device::max_parameter_size>() {
911 inline uint32_t get_device_info_host<info::device::mem_base_addr_align>() {
916 inline std::vector<info::fp_config>
917 get_device_info_host<info::device::half_fp_config>() {
923 inline std::vector<info::fp_config>
924 get_device_info_host<info::device::single_fp_config>() {
926 return {info::fp_config::round_to_nearest, info::fp_config::inf_nan};
930 inline std::vector<info::fp_config>
931 get_device_info_host<info::device::double_fp_config>() {
934 info::fp_config::round_to_zero, info::fp_config::round_to_inf,
935 info::fp_config::inf_nan, info::fp_config::denorm};
940 get_device_info_host<info::device::global_mem_cache_type>() {
941 return info::global_mem_cache_type::read_write;
946 get_device_info_host<info::device::global_mem_cache_line_size>() {
947 return PlatformUtil::getMemCacheLineSize();
951 inline uint64_t get_device_info_host<info::device::global_mem_cache_size>() {
952 return PlatformUtil::getMemCacheSize();
956 inline uint64_t get_device_info_host<info::device::max_constant_buffer_size>() {
962 inline uint32_t get_device_info_host<info::device::max_constant_args>() {
969 get_device_info_host<info::device::local_mem_type>() {
970 return info::local_mem_type::global;
974 inline uint64_t get_device_info_host<info::device::local_mem_size>() {
980 inline bool get_device_info_host<info::device::error_correction_support>() {
985 inline bool get_device_info_host<info::device::host_unified_memory>() {
990 inline size_t get_device_info_host<info::device::profiling_timer_resolution>() {
991 typedef std::ratio_divide<std::chrono::high_resolution_clock::period,
994 return ns_period::num / ns_period::den;
997 template <>
inline bool get_device_info_host<info::device::is_endian_little>() {
1006 template <>
inline bool get_device_info_host<info::device::is_available>() {
1011 inline bool get_device_info_host<info::device::is_compiler_available>() {
1016 inline bool get_device_info_host<info::device::is_linker_available>() {
1021 inline std::vector<info::execution_capability>
1022 get_device_info_host<info::device::execution_capabilities>() {
1023 return {info::execution_capability::exec_kernel};
1026 template <>
inline bool get_device_info_host<info::device::queue_profiling>() {
1031 inline std::vector<kernel_id>
1032 get_device_info_host<info::device::built_in_kernel_ids>() {
1037 inline std::vector<std::string>
1038 get_device_info_host<info::device::built_in_kernels>() {
1042 template <>
inline platform get_device_info_host<info::device::platform>() {
1046 template <>
inline std::string get_device_info_host<info::device::name>() {
1047 return "SYCL host device";
1050 template <>
inline std::string get_device_info_host<info::device::vendor>() {
1055 inline std::string get_device_info_host<info::device::driver_version>() {
1059 template <>
inline std::string get_device_info_host<info::device::profile>() {
1060 return "FULL PROFILE";
1063 template <>
inline std::string get_device_info_host<info::device::version>() {
1068 inline std::string get_device_info_host<info::device::opencl_c_version>() {
1069 return "not applicable";
1073 inline std::vector<std::string>
1074 get_device_info_host<info::device::extensions>() {
1080 inline size_t get_device_info_host<info::device::printf_buffer_size>() {
1086 inline bool get_device_info_host<info::device::preferred_interop_user_sync>() {
1090 template <>
inline device get_device_info_host<info::device::parent_device>() {
1092 throw invalid_object_error(
1093 "Partitioning to subdevices of the host device is not implemented yet",
1094 PI_ERROR_INVALID_DEVICE);
1099 get_device_info_host<info::device::partition_max_sub_devices>() {
1105 inline std::vector<info::partition_property>
1106 get_device_info_host<info::device::partition_properties>() {
1112 inline std::vector<info::partition_affinity_domain>
1113 get_device_info_host<info::device::partition_affinity_domains>() {
1120 get_device_info_host<info::device::partition_type_property>() {
1121 return info::partition_property::no_partition;
1126 get_device_info_host<info::device::partition_type_affinity_domain>() {
1128 return info::partition_affinity_domain::not_applicable;
1132 inline uint32_t get_device_info_host<info::device::reference_count>() {
1138 inline uint32_t get_device_info_host<info::device::max_num_sub_groups>() {
1140 throw runtime_error(
"Sub-group feature is not supported on HOST device.",
1141 PI_ERROR_INVALID_DEVICE);
1145 inline std::vector<size_t>
1146 get_device_info_host<info::device::sub_group_sizes>() {
1148 throw runtime_error(
"Sub-group feature is not supported on HOST device.",
1149 PI_ERROR_INVALID_DEVICE);
1154 get_device_info_host<info::device::sub_group_independent_forward_progress>() {
1156 throw runtime_error(
"Sub-group feature is not supported on HOST device.",
1157 PI_ERROR_INVALID_DEVICE);
1161 inline bool get_device_info_host<info::device::kernel_kernel_pipe_support>() {
1166 inline std::string get_device_info_host<info::device::backend_version>() {
1167 throw runtime_error(
1168 "Backend version feature is not supported on HOST device.",
1169 PI_ERROR_INVALID_DEVICE);
1173 inline bool get_device_info_host<info::device::usm_device_allocations>() {
1178 inline bool get_device_info_host<info::device::usm_host_allocations>() {
1183 inline bool get_device_info_host<info::device::usm_shared_allocations>() {
1189 get_device_info_host<info::device::usm_restricted_shared_allocations>() {
1194 inline bool get_device_info_host<info::device::usm_system_allocations>() {
1199 inline bool get_device_info_host<info::device::ext_intel_mem_channel>() {
1212 dev, pi::cast<RT::PiDeviceInfo>(info::device::usm_device_allocations),
1215 return (Err != PI_SUCCESS) ? false : (caps &
PI_USM_ACCESS);
1224 dev, pi::cast<RT::PiDeviceInfo>(info::device::usm_host_allocations),
1227 return (Err != PI_SUCCESS) ? false : (caps &
PI_USM_ACCESS);
1236 dev, pi::cast<RT::PiDeviceInfo>(info::device::usm_shared_allocations),
1238 return (Err != PI_SUCCESS) ? false : (caps &
PI_USM_ACCESS);
1249 pi::cast<RT::PiDeviceInfo>(
1250 info::device::usm_restricted_shared_allocations),
1253 return (Err != PI_SUCCESS)
1264 dev, pi::cast<RT::PiDeviceInfo>(info::device::usm_system_allocations),
1266 return (Err != PI_SUCCESS) ? false : (caps &
PI_USM_ACCESS);
1275 dev, pi::cast<RT::PiDeviceInfo>(info::device::ext_intel_mem_channel),
1284 inline std::string get_device_info_host<info::device::ext_intel_pci_address>() {
1285 throw runtime_error(
1286 "Obtaining the PCI address is not supported on HOST device",
1287 PI_ERROR_INVALID_DEVICE);
1290 inline uint32_t get_device_info_host<info::device::ext_intel_gpu_eu_count>() {
1291 throw runtime_error(
"Obtaining the EU count is not supported on HOST device",
1292 PI_ERROR_INVALID_DEVICE);
1296 get_device_info_host<info::device::ext_intel_gpu_eu_simd_width>() {
1297 throw runtime_error(
1298 "Obtaining the EU SIMD width is not supported on HOST device",
1299 PI_ERROR_INVALID_DEVICE);
1302 inline uint32_t get_device_info_host<info::device::ext_intel_gpu_slices>() {
1303 throw runtime_error(
1304 "Obtaining the number of slices is not supported on HOST device",
1305 PI_ERROR_INVALID_DEVICE);
1309 get_device_info_host<info::device::ext_intel_gpu_subslices_per_slice>() {
1310 throw runtime_error(
"Obtaining the number of subslices per slice is not "
1311 "supported on HOST device",
1312 PI_ERROR_INVALID_DEVICE);
1316 get_device_info_host<info::device::ext_intel_gpu_eu_count_per_subslice>() {
1317 throw runtime_error(
1318 "Obtaining the EU count per subslice is not supported on HOST device",
1319 PI_ERROR_INVALID_DEVICE);
1323 get_device_info_host<info::device::ext_intel_gpu_hw_threads_per_eu>() {
1324 throw runtime_error(
1325 "Obtaining the HW threads count per EU is not supported on HOST device",
1326 PI_ERROR_INVALID_DEVICE);
1330 get_device_info_host<info::device::ext_intel_max_mem_bandwidth>() {
1331 throw runtime_error(
1332 "Obtaining the maximum memory bandwidth is not supported on HOST device",
1333 PI_ERROR_INVALID_DEVICE);
1335 template <>
inline bool get_device_info_host<info::device::ext_oneapi_srgb>() {
1341 get_device_info_host<info::device::ext_intel_device_info_uuid>() {
1342 throw runtime_error(
1343 "Obtaining the device uuid is not supported on HOST device",
1344 PI_ERROR_INVALID_DEVICE);