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