Skip to content

Commit 1be6ada

Browse files
author
Ewan Crawford
authored
[SYCL][Graphs] Implement device support query
Implement the device info `graph_support` query defined by spec PR #178 This only reports that graphs are supported on Level Zero devices.
1 parent 97d656f commit 1be6ada

File tree

5 files changed

+63
-2
lines changed

5 files changed

+63
-2
lines changed

sycl/include/sycl/info/ext_oneapi_device_traits.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ __SYCL_PARAM_TRAITS_SPEC(ext::oneapi::experimental,device, max_global_work_group
66
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(ext::oneapi::experimental,device, max_work_groups<1>, id<1>, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_1D)
77
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(ext::oneapi::experimental,device, max_work_groups<2>, id<2>, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_2D)
88
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(ext::oneapi::experimental,device, max_work_groups<3>, id<3>, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D)
9+
__SYCL_PARAM_TRAITS_SPEC(ext::oneapi::experimental,device, graph_support, ext::oneapi::experimental::info::device::graph_support_level, PI_EXT_ONEAPI_DEVICE_INFO_COMMAND_BUFFER_SUPPORT)
10+
911
#ifdef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF
1012
#undef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC
1113
#undef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF

sycl/include/sycl/info/info_desc.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ template <typename T, T param> struct compatibility_param_traits {};
186186

187187
namespace ext::oneapi::experimental::info::device {
188188
template <int Dimensions> struct max_work_groups;
189+
190+
enum class graph_support_level { unsupported = 0, native, emulated };
191+
189192
} // namespace ext::oneapi::experimental::info::device
190193
#include <sycl/info/ext_codeplay_device_traits.def>
191194
#include <sycl/info/ext_intel_device_traits.def>

sycl/source/detail/device_info.hpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,31 @@ struct get_device_info_impl<
804804
}
805805
};
806806

807+
// Specialization for graph extension support
808+
template <>
809+
struct get_device_info_impl<
810+
ext::oneapi::experimental::info::device::graph_support_level,
811+
ext::oneapi::experimental::info::device::graph_support> {
812+
static ext::oneapi::experimental::info::device::graph_support_level
813+
get(const DeviceImplPtr &Dev) {
814+
// Level zero is currently only supported backend
815+
if (Dev->getBackend() != backend::ext_oneapi_level_zero) {
816+
return ext::oneapi::experimental::info::device::graph_support_level::
817+
unsupported;
818+
}
819+
820+
pi_bool CmdBufSupport = false;
821+
Dev->getPlugin()->call<PiApiKind::piDeviceGetInfo>(
822+
Dev->getHandleRef(), PI_EXT_ONEAPI_DEVICE_INFO_COMMAND_BUFFER_SUPPORT,
823+
sizeof(pi_bool), &CmdBufSupport, nullptr);
824+
825+
return CmdBufSupport ? ext::oneapi::experimental::info::device::
826+
graph_support_level::native
827+
: ext::oneapi::experimental::info::device::
828+
graph_support_level::emulated;
829+
}
830+
};
831+
807832
template <typename Param>
808833
typename Param::return_type get_device_info(const DeviceImplPtr &Dev) {
809834
static_assert(is_device_info_desc<Param>::value,
@@ -1692,6 +1717,14 @@ inline uint32_t get_device_info_host<
16921717
PI_ERROR_INVALID_DEVICE);
16931718
}
16941719

1720+
template <>
1721+
inline ext::oneapi::experimental::info::device::graph_support_level
1722+
get_device_info_host<ext::oneapi::experimental::info::device::graph_support>() {
1723+
// No support for graphs on the host device.
1724+
return ext::oneapi::experimental::info::device::graph_support_level::
1725+
unsupported;
1726+
}
1727+
16951728
} // namespace detail
16961729
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
16971730
} // namespace sycl
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %{build} -o %t.out
2+
// RUN: %{run} %t.out
3+
4+
// Tests the using device query for graphs support, and that the return value
5+
// matches expectations.
6+
7+
#include "graph_common.hpp"
8+
9+
int main() {
10+
queue Queue;
11+
12+
auto Device = Queue.get_device();
13+
14+
exp_ext::info::device::graph_support_level SupportsGraphs =
15+
Device.get_info<exp_ext::info::device::graph_support>();
16+
auto Backend = Device.get_backend();
17+
18+
if (Backend == backend::ext_oneapi_level_zero) {
19+
assert(SupportsGraphs ==
20+
exp_ext::info::device::graph_support_level::native);
21+
} else {
22+
assert(SupportsGraphs ==
23+
exp_ext::info::device::graph_support_level::unsupported);
24+
}
25+
}

sycl/test-e2e/Graph/vendor_test_macro.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// REQUIRES: level_zero, gpu
2-
31
// RUN: %{build} -o %t.out
42
// RUN: %{run} %t.out
53

0 commit comments

Comments
 (0)