Skip to content

Commit 414f7b7

Browse files
authored
Add target device arch string in device properties (#5625)
Add the ability to query the target XPU architecture in Triton tests. --------- Signed-off-by: Ettore Tiotto <[email protected]>
1 parent 7814de9 commit 414f7b7

File tree

3 files changed

+90
-2
lines changed

3 files changed

+90
-2
lines changed

python/triton/_internal_testing.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,84 @@ def is_xpu():
106106
return False if target is None else target.backend == "xpu"
107107

108108

109+
def is_xpu_arl_h():
110+
target = get_current_target()
111+
return target is not None and target.backend == 'xpu' and 'arl_h' in target.arch
112+
113+
114+
def is_xpu_arl_s():
115+
target = get_current_target()
116+
return target is not None and target.backend == 'xpu' and 'arl_s' in target.arch
117+
118+
119+
def is_xpu_bmg():
120+
target = get_current_target()
121+
return target is not None and target.backend == 'xpu' and 'bmg' in target.arch
122+
123+
124+
def is_xpu_dg2():
125+
target = get_current_target()
126+
return target is not None and target.backend == 'xpu' and 'dg2' in target.arch
127+
128+
129+
def is_xpu_lnl():
130+
target = get_current_target()
131+
return target is not None and target.backend == 'xpu' and 'lnl' in target.arch
132+
133+
134+
def is_xpu_mtl():
135+
target = get_current_target()
136+
return target is not None and target.backend == 'xpu' and 'mtl' in target.arch
137+
138+
139+
def is_xpu_pvc():
140+
target = get_current_target()
141+
return target is not None and target.backend == 'xpu' and 'pvc' in target.arch
142+
143+
144+
def is_xpu_ptl_h():
145+
target = get_current_target()
146+
return target is not None and target.backend == 'xpu' and 'ptl_h' in target.arch
147+
148+
149+
def is_xpu_ptl_u():
150+
target = get_current_target()
151+
return target is not None and target.backend == 'xpu' and 'ptl_u' in target.arch
152+
153+
154+
def is_xpu_cri():
155+
target = get_current_target()
156+
return target is not None and target.backend == 'xpu' and 'cri' in target.arch
157+
158+
159+
def is_xpu_lpg():
160+
return is_xpu_arl_s()
161+
162+
163+
def is_xpu_lpgP():
164+
return is_xpu_arl_h()
165+
166+
167+
def is_xpu_hpg():
168+
return is_xpu_dg2()
169+
170+
171+
def is_xpu_hpc():
172+
return is_xpu_pvc()
173+
174+
175+
def is_xpu_xe2():
176+
return is_xpu_bmg()
177+
178+
179+
def is_xpu_xe3():
180+
return is_xpu_ptl_h() or is_xpu_ptl_u()
181+
182+
183+
def is_xpu_xe3P():
184+
return is_xpu_cri()
185+
186+
109187
def get_arch():
110188
target = get_current_target()
111189
return "" if target is None else str(target.arch)

third_party/intel/backend/arch_parser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ extern "C" EXPORT_FUNC const char *parse_device_arch(uint64_t dev_arch) {
5252
break;
5353
#endif
5454
case sycl::ext::oneapi::experimental::architecture::unknown:
55-
std::cerr << "unknown sycl_arch" << std::endl;
55+
arch = "unknown";
5656
break;
5757
default:
58-
std::cerr << "sycl_arch not recognized: " << (uint64_t)sycl_arch
58+
std::cerr << "device architecture not recognized: " << (uint64_t)sycl_arch
5959
<< std::endl;
6060
}
6161

third_party/intel/backend/driver.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,17 @@ def update_advanced_features(device, dev_property):
932932
dev_property["has_subgroup_2d_block_io"] = check(device, b"cl_intel_subgroup_2d_block_io")
933933
dev_property["has_bfloat16_conversions"] = check(device, b"cl_intel_bfloat16_conversions")
934934

935+
def update_device_arch(dev_property):
936+
if not (arch := knobs.intel.device_arch):
937+
dirname = os.path.dirname(os.path.realpath(__file__))
938+
parser = compile_module_from_src(src=Path(os.path.join(dirname, "arch_parser.c")).read_text(),
939+
name="arch_utils")
940+
arch = parser.parse_device_arch(dev_property["architecture"])
941+
dev_property["arch"] = arch
942+
935943
update_advanced_features(device, dev_property)
944+
update_device_arch(dev_property)
945+
936946
return GPUTarget("xpu", dev_property, warp_size=32)
937947

938948
def build_proton_help_lib(self):

0 commit comments

Comments
 (0)