Skip to content

Commit cf245f6

Browse files
authored
[SYCL][Fusion] Add fusion device info descriptor (#8254)
Implement the `sycl::ext::codeplay::experimental::info::device::supports_fusion` device descriptor defined by the [kernel fusion extension proposal](https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_codeplay_kernel_fusion.asciidoc). Kernel fusion is currently limited to SPIR-V based backends, so support can be determined based on the device's backend. --------- Signed-off-by: Lukas Sommer <[email protected]>
1 parent f770508 commit cf245f6

File tree

8 files changed

+42
-0
lines changed

8 files changed

+42
-0
lines changed

sycl/include/sycl/detail/info_desc_helpers.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct IsSubGroupInfo<info::kernel_device_specific::compile_sub_group_size>
113113
: std::true_type { \
114114
using return_type = Namespace::info::DescType::Desc::return_type; \
115115
};
116+
#include <sycl/info/ext_codeplay_device_traits.def>
116117
#include <sycl/info/ext_intel_device_traits.def>
117118
#include <sycl/info/ext_oneapi_device_traits.def>
118119
#undef __SYCL_PARAM_TRAITS_SPEC

sycl/include/sycl/detail/pi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ typedef enum {
322322
PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_2D = 0x20002,
323323
PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D = 0x20003,
324324
PI_EXT_ONEAPI_DEVICE_INFO_CUDA_ASYNC_BARRIER = 0x20004,
325+
PI_EXT_CODEPLAY_DEVICE_INFO_SUPPORTS_FUSION = 0x20005,
325326
} _pi_device_info;
326327

327328
typedef enum {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC
2+
#define __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF
3+
#define __SYCL_PARAM_TRAITS_TEMPLATE_SPEC __SYCL_PARAM_TRAITS_SPEC
4+
#endif
5+
__SYCL_PARAM_TRAITS_SPEC(ext::codeplay::experimental,device, supports_fusion, bool, PI_EXT_CODEPLAY_DEVICE_INFO_SUPPORTS_FUSION)
6+
#ifdef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF
7+
#undef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC
8+
#undef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF
9+
#endif

sycl/include/sycl/info/info_desc.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ template <typename T, T param> struct compatibility_param_traits {};
184184
namespace ext::oneapi::experimental::info::device {
185185
template <int Dimensions> struct max_work_groups;
186186
} // namespace ext::oneapi::experimental::info::device
187+
#include <sycl/info/ext_codeplay_device_traits.def>
187188
#include <sycl/info/ext_intel_device_traits.def>
188189
#include <sycl/info/ext_oneapi_device_traits.def>
189190
#undef __SYCL_PARAM_TRAITS_SPEC

sycl/source/detail/device_info.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <sycl/detail/os_util.hpp>
1818
#include <sycl/detail/pi.hpp>
1919
#include <sycl/device.hpp>
20+
#include <sycl/feature_test.hpp>
2021
#include <sycl/info/info_desc.hpp>
2122
#include <sycl/memory_enums.hpp>
2223
#include <sycl/platform.hpp>
@@ -751,6 +752,25 @@ struct get_device_info_impl<bool, info::device::ext_intel_mem_channel> {
751752
}
752753
};
753754

755+
// Specialization for kernel fusion support
756+
template <>
757+
struct get_device_info_impl<
758+
bool, ext::codeplay::experimental::info::device::supports_fusion> {
759+
static bool get(RT::PiDevice dev, const plugin &Plugin) {
760+
#if SYCL_EXT_CODEPLAY_KERNEL_FUSION
761+
// Currently fusion is only supported for SPIR-V based backends, i.e. OpenCL
762+
// and LevelZero.
763+
(void)dev;
764+
return (Plugin.getBackend() == backend::ext_oneapi_level_zero) ||
765+
(Plugin.getBackend() == backend::opencl);
766+
#else // SYCL_EXT_CODEPLAY_KERNEL_FUSION
767+
(void)dev;
768+
(void)Plugin;
769+
return false;
770+
#endif // SYCL_EXT_CODEPLAY_KERNEL_FUSION
771+
}
772+
};
773+
754774
template <typename Param>
755775
typename Param::return_type get_device_info(RT::PiDevice dev,
756776
const plugin &Plugin) {
@@ -1609,6 +1629,13 @@ get_device_info_host<ext::intel::info::device::max_compute_queue_indices>() {
16091629
PI_ERROR_INVALID_DEVICE);
16101630
}
16111631

1632+
template <>
1633+
inline bool get_device_info_host<
1634+
ext::codeplay::experimental::info::device::supports_fusion>() {
1635+
// No support for fusion on the host device.
1636+
return false;
1637+
}
1638+
16121639
} // namespace detail
16131640
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
16141641
} // namespace sycl

sycl/source/device.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ device::get_info<info::device::aspects>() const {
190190
template __SYCL_EXPORT ReturnT \
191191
device::get_info<Namespace::info::DescType::Desc>() const;
192192

193+
#include <sycl/info/ext_codeplay_device_traits.def>
193194
#include <sycl/info/ext_intel_device_traits.def>
194195
#include <sycl/info/ext_oneapi_device_traits.def>
195196
#undef __SYCL_PARAM_TRAITS_SPEC

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4242,6 +4242,7 @@ _ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_wor
42424242
_ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi2EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv
42434243
_ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device15max_work_groupsILi3EEEEENS0_6detail19is_device_info_descIT_E11return_typeEv
42444244
_ZNK4sycl3_V16device8get_infoINS0_3ext6oneapi12experimental4info6device22max_global_work_groupsEEENS0_6detail19is_device_info_descIT_E11return_typeEv
4245+
_ZNK4sycl3_V16device8get_infoINS0_3ext8codeplay12experimental4info6device15supports_fusionEEENS0_6detail19is_device_info_descIT_E11return_typeEv
42454246
_ZNK4sycl3_V16device8get_infoINS0_4info6device10extensionsEEENS0_6detail19is_device_info_descIT_E11return_typeEv
42464247
_ZNK4sycl3_V16device8get_infoINS0_4info6device11device_typeEEENS0_6detail19is_device_info_descIT_E11return_typeEv
42474248
_ZNK4sycl3_V16device8get_infoINS0_4info6device12address_bitsEEENS0_6detail19is_device_info_descIT_E11return_typeEv

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
??$get_info@Usingle_fp_config@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA?AV?$vector@W4fp_config@info@_V1@sycl@@V?$allocator@W4fp_config@info@_V1@sycl@@@std@@@std@@XZ
163163
??$get_info@Usub_group_independent_forward_progress@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA_NXZ
164164
??$get_info@Usub_group_sizes@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA?AV?$vector@_KV?$allocator@_K@std@@@std@@XZ
165+
??$get_info@Usupports_fusion@device@info@experimental@codeplay@ext@_V1@sycl@@@device@_V1@sycl@@QEBA_NXZ
165166
??$get_info@Uusm_device_allocations@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA_NXZ
166167
??$get_info@Uusm_host_allocations@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA_NXZ
167168
??$get_info@Uusm_restricted_shared_allocations@device@info@_V1@sycl@@@device@_V1@sycl@@QEBA_NXZ

0 commit comments

Comments
 (0)