Skip to content

Commit 530354f

Browse files
authored
[SYCL] Avoid a short-lived heap allocation (#16195)
A C-style array with unspecified bounds allows the array to grow as new members are added, while avoiding the heap allocation of `std::vector` that is immediately freed.
1 parent e758793 commit 530354f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sycl/source/detail/device_impl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,15 +672,16 @@ bool device_impl::has(aspect Aspect) const {
672672
}
673673
case aspect::ext_intel_matrix: {
674674
using arch = sycl::ext::oneapi::experimental::architecture;
675-
const std::vector<arch> supported_archs = {
675+
const arch supported_archs[] = {
676676
arch::intel_cpu_spr, arch::intel_cpu_gnr,
677677
arch::intel_gpu_pvc, arch::intel_gpu_dg2_g10,
678678
arch::intel_gpu_dg2_g11, arch::intel_gpu_dg2_g12,
679679
arch::intel_gpu_bmg_g21, arch::intel_gpu_lnl_m,
680-
arch::intel_gpu_arl_h};
680+
arch::intel_gpu_arl_h,
681+
};
681682
try {
682683
return std::any_of(
683-
supported_archs.begin(), supported_archs.end(),
684+
std::begin(supported_archs), std::end(supported_archs),
684685
[=](const arch a) { return this->extOneapiArchitectureIs(a); });
685686
} catch (const sycl::exception &) {
686687
// If we're here it means the device does not support architecture

0 commit comments

Comments
 (0)