XPUDeviceProp.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. #pragma once
  2. #include <c10/xpu/XPUMacros.h>
  3. #include <sycl/sycl.hpp>
  4. namespace c10::xpu {
  5. #define AT_FORALL_XPU_DEVICE_PROPERTIES(_) \
  6. /* the device name of this SYCL device. */ \
  7. _(name) \
  8. \
  9. /* the device type associated with the device. */ \
  10. _(device_type) \
  11. \
  12. /* the vendor of this SYCL device. */ \
  13. _(vendor) \
  14. \
  15. /* a backend-defined driver version as a std::string. */ \
  16. _(driver_version) \
  17. \
  18. /* the SYCL version as a std::string in the form <major>.<minor> */ \
  19. _(version) \
  20. \
  21. /* true if the SYCL device is available. Otherwise, return false. */ \
  22. _(is_available) \
  23. \
  24. /* the maximum size in bytes of the arguments that can be passed to a \
  25. * kernel. */ \
  26. _(max_parameter_size) \
  27. \
  28. /* the number of parallel compute units available to the device. */ \
  29. _(max_compute_units) \
  30. \
  31. /* the maximum dimensions that specify the global and local work-item IDs \
  32. * used by the data parallel execution model. */ \
  33. _(max_work_item_dimensions) \
  34. \
  35. /* the maximum number of workitems that are permitted in a work-group \
  36. * executing a kernel on a single compute unit. */ \
  37. _(max_work_group_size) \
  38. \
  39. /* the maximum number of subgroups in a work-group for any kernel executed \
  40. * on the device. */ \
  41. _(max_num_sub_groups) \
  42. \
  43. /* a std::vector of size_t containing the set of sub-group sizes supported \
  44. * by the device. */ \
  45. _(sub_group_sizes) \
  46. \
  47. /* the maximum configured clock frequency of this SYCL device in MHz. */ \
  48. _(max_clock_frequency) \
  49. \
  50. /* the default compute device address space size specified as an unsigned \
  51. * integer value in bits. Must return either 32 or 64. */ \
  52. _(address_bits) \
  53. \
  54. /* the maximum size of memory object allocation in bytes. */ \
  55. _(max_mem_alloc_size) \
  56. \
  57. /* the minimum value in bits of the largest supported SYCL built-in data \
  58. * type if this SYCL device is not of device type \
  59. * sycl::info::device_type::custom. */ \
  60. _(mem_base_addr_align) \
  61. \
  62. /* a std::vector of info::fp_config describing the half/single/double \
  63. * precision floating-point capability of this SYCL device. */ \
  64. _(half_fp_config) \
  65. _(single_fp_config) \
  66. _(double_fp_config) \
  67. \
  68. /* the size of global device memory in bytes. */ \
  69. _(global_mem_size) \
  70. \
  71. /* the type of global memory cache supported. */ \
  72. _(global_mem_cache_type) \
  73. \
  74. /* the size of global memory cache in bytes. */ \
  75. _(global_mem_cache_size) \
  76. \
  77. /* the size of global memory cache line in bytes. */ \
  78. _(global_mem_cache_line_size) \
  79. \
  80. /* the type of local memory supported. */ \
  81. _(local_mem_type) \
  82. \
  83. /* the size of local memory arena in bytes. */ \
  84. _(local_mem_size) \
  85. \
  86. /* the maximum number of sub-devices that can be created when this device is \
  87. * partitioned. */ \
  88. _(partition_max_sub_devices) \
  89. \
  90. /* the resolution of device timer in nanoseconds. */ \
  91. _(profiling_timer_resolution) \
  92. \
  93. /* the preferred native vector width size for built-in scalar types that can \
  94. * be put into vectors. */ \
  95. _(preferred_vector_width_char) \
  96. _(preferred_vector_width_short) \
  97. _(preferred_vector_width_int) \
  98. _(preferred_vector_width_long) \
  99. _(preferred_vector_width_float) \
  100. _(preferred_vector_width_double) \
  101. _(preferred_vector_width_half) \
  102. \
  103. /* the native ISA vector width. The vector width is defined as the number of \
  104. * scalar elements that can be stored in the vector. */ \
  105. _(native_vector_width_char) \
  106. _(native_vector_width_short) \
  107. _(native_vector_width_int) \
  108. _(native_vector_width_long) \
  109. _(native_vector_width_float) \
  110. _(native_vector_width_double) \
  111. _(native_vector_width_half)
  112. #define AT_FORALL_XPU_EXT_DEVICE_PROPERTIES(_) \
  113. /* the number of EUs associated with the Intel GPU. */ \
  114. _(gpu_eu_count, gpu_eu_count, 512) \
  115. \
  116. /* the number of EUs in a subslice. */ \
  117. _(gpu_eu_count_per_subslice, gpu_eu_count_per_subslice, 8) \
  118. \
  119. /* the simd width of EU of GPU. */ \
  120. _(gpu_eu_simd_width, gpu_eu_simd_width, 8) \
  121. \
  122. /* the number of hardware threads per EU of GPU. */ \
  123. _(gpu_hw_threads_per_eu, gpu_hw_threads_per_eu, 8) \
  124. \
  125. /* the device identifier of the Intel GPU, also known as the product ID. */ \
  126. _(device_id, device_id, 0) \
  127. \
  128. /* the device descriptor for device Universal Unique ID, 16 bytes*/ \
  129. _(uuid, device_info_uuid, (std::array<unsigned char, 16>{}))
  130. #define AT_FORALL_XPU_DEVICE_ASPECT(_) \
  131. /* sycl::half is supported on device. */ \
  132. _(fp16) \
  133. \
  134. /* double is supported on device. */ \
  135. _(fp64) \
  136. \
  137. /* 64-bit atomic operation is supported on device. */ \
  138. _(atomic64)
  139. #define AT_FORALL_XPU_EXP_CL_ASPECT(_) \
  140. /* conversion between single-precision 32-bit floating-point values and \
  141. * 16-bit bfloat16 values is supported on device. */ \
  142. _(bfloat16_conversions) \
  143. \
  144. /* specialized hardware to compute MMA is supported on device. */ \
  145. _(subgroup_matrix_multiply_accumulate) \
  146. \
  147. /* specialized hardware to compute MMA for 32-bit floating-point is \
  148. * supported on device. */ \
  149. _(subgroup_matrix_multiply_accumulate_tensor_float32) \
  150. \
  151. /* block read operations for efficient matrix multiplication is supported on \
  152. * device. */ \
  153. _(subgroup_2d_block_io)
  154. #define AT_FORALL_XPU_EXP_DEVICE_PROPERTIES(_) \
  155. /* the device architecture of this SYCL device. */ \
  156. _(architecture)
  157. #define _DEFINE_SYCL_PROP(ns, property, member) \
  158. ns::property::return_type member;
  159. #define DEFINE_DEVICE_PROP(property) \
  160. _DEFINE_SYCL_PROP(sycl::info::device, property, property)
  161. #define DEFINE_PLATFORM_PROP(property, member) \
  162. _DEFINE_SYCL_PROP(sycl::info::platform, property, member)
  163. #define DEFINE_EXT_DEVICE_PROP(property, ...) \
  164. _DEFINE_SYCL_PROP(sycl::ext::intel::info::device, property, property)
  165. #define DEFINE_DEVICE_ASPECT(member) bool has_##member;
  166. #define DEFINE_EXP_DEVICE_PROP(property) \
  167. _DEFINE_SYCL_PROP( \
  168. sycl::ext::oneapi::experimental::info::device, property, property)
  169. struct C10_XPU_API DeviceProp {
  170. AT_FORALL_XPU_DEVICE_PROPERTIES(DEFINE_DEVICE_PROP);
  171. // the platform name.
  172. DEFINE_PLATFORM_PROP(name, platform_name);
  173. AT_FORALL_XPU_EXT_DEVICE_PROPERTIES(DEFINE_EXT_DEVICE_PROP);
  174. AT_FORALL_XPU_DEVICE_ASPECT(DEFINE_DEVICE_ASPECT);
  175. AT_FORALL_XPU_EXP_CL_ASPECT(DEFINE_DEVICE_ASPECT);
  176. #if SYCL_COMPILER_VERSION >= 20250000
  177. AT_FORALL_XPU_EXP_DEVICE_PROPERTIES(DEFINE_EXP_DEVICE_PROP);
  178. #endif
  179. };
  180. #undef _DEFINE_SYCL_PROP
  181. #undef DEFINE_DEVICE_PROP
  182. #undef DEFINE_PLATFORM_PROP
  183. #undef DEFINE_EXT_DEVICE_PROP
  184. #undef DEFINE_DEVICE_ASPECT
  185. #undef DEFINE_EXP_DEVICE_PROP
  186. } // namespace c10::xpu