Skip to content
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
91f0ce6
Add def based check for queue
KseniyaTikhomirova Sep 2, 2024
ae0b1d4
add test for queue
KseniyaTikhomirova Aug 29, 2024
6e673ac
fix code-review comments
KseniyaTikhomirova Sep 2, 2024
34d65d9
fix format
KseniyaTikhomirova Sep 2, 2024
05b7398
add check to buffer & image
KseniyaTikhomirova Sep 2, 2024
10bd181
fix format
KseniyaTikhomirova Sep 2, 2024
87a1691
fix build & format
KseniyaTikhomirova Sep 3, 2024
f3b6e39
add check to context
KseniyaTikhomirova Sep 3, 2024
db53824
add test for context
KseniyaTikhomirova Aug 29, 2024
c5a4eff
fix build
KseniyaTikhomirova Sep 3, 2024
d88c3f2
add check to sampler
KseniyaTikhomirova Sep 3, 2024
d83f367
add test for sampler
KseniyaTikhomirova Aug 30, 2024
8edf0c1
add check to stream
KseniyaTikhomirova Sep 3, 2024
a9c8c39
add test for stream
KseniyaTikhomirova Aug 29, 2024
0587a71
update tests
KseniyaTikhomirova Sep 3, 2024
f02ca36
add check to reduction
KseniyaTikhomirova Sep 3, 2024
72fc90d
add test for reduction
KseniyaTikhomirova Aug 30, 2024
4e5f586
add check to usm_allocator
KseniyaTikhomirova Sep 3, 2024
2d99591
add test for usm_allocator
KseniyaTikhomirova Aug 30, 2024
0973de0
update linux symbols
KseniyaTikhomirova Sep 3, 2024
e76b4ae
fix stream test
KseniyaTikhomirova Sep 3, 2024
4f25430
fix format
KseniyaTikhomirova Sep 3, 2024
80acde2
add check to accessor
KseniyaTikhomirova Sep 4, 2024
05cf71d
add test for sampled/unsampled_image
KseniyaTikhomirova Sep 4, 2024
24120ff
Merge branch 'sycl' into defbased_property
KseniyaTikhomirova Sep 17, 2024
f16372f
fix tests
KseniyaTikhomirova Sep 17, 2024
6fa9b2b
add a few accessor tests
KseniyaTikhomirova Oct 7, 2024
95ea264
Merge branch 'sycl' into defbased_property
KseniyaTikhomirova Oct 7, 2024
a80b944
add check for kernel bundle free methods
KseniyaTikhomirova Oct 7, 2024
75cefe0
move graph properties to files
KseniyaTikhomirova Oct 9, 2024
f9c7862
enable check for graph
KseniyaTikhomirova Oct 9, 2024
2d563ff
update linux symbols
KseniyaTikhomirova Oct 9, 2024
483e645
add graph property validation
KseniyaTikhomirova Oct 10, 2024
f009c27
add unittests
KseniyaTikhomirova Oct 10, 2024
460470a
update win symbols
KseniyaTikhomirova Oct 10, 2024
c270827
Merge branch 'sycl' into propertycheck_ext
KseniyaTikhomirova Oct 11, 2024
bd99f58
fix potential warnings
KseniyaTikhomirova Oct 11, 2024
8612578
fix forward declaration issues
KseniyaTikhomirova Oct 15, 2024
b0ec3be
Merge branch 'sycl' into propertycheck_ext
KseniyaTikhomirova Dec 19, 2024
808287a
fix code-review comments
KseniyaTikhomirova Dec 19, 2024
7ceb2b8
fix comments
KseniyaTikhomirova Dec 19, 2024
9e874d3
update win symbols
KseniyaTikhomirova Dec 19, 2024
4c9eb8a
Merge branch 'sycl' into propertycheck_ext
KseniyaTikhomirova Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// --*- c++ -*---
#ifndef __SYCL_DATA_LESS_PROP
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL)
#endif
#ifndef __SYCL_MANUALLY_DEFINED_PROP
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
#endif

/// Property passed to command_graph constructor to disable checking for cycles.
__SYCL_DATA_LESS_PROP(property::graph, no_cycle_check, GraphNoCycleCheck)

/// Property passed to command_graph constructor to allow buffers to be used
/// with graphs. Passing this property represents a promise from the user that
/// the buffer will outlive any graph that it is used in.
__SYCL_DATA_LESS_PROP(property::graph, assume_buffer_outlives_graph, GraphAssumeBufferOutlivesGraph)

/// Property passed to command_graph<graph_state::modifiable>::finalize() to
/// mark the resulting executable command_graph as able to be updated.
__SYCL_DATA_LESS_PROP(property::graph, updatable, GraphUpdatable)

/// Property used to enable executable graph profiling. Enables profiling on
/// events returned by submissions of the executable graph
__SYCL_DATA_LESS_PROP(property::graph, enable_profiling, GraphEnableProfiling)

#undef __SYCL_DATA_LESS_PROP
#undef __SYCL_MANUALLY_DEFINED_PROP
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//==----------- queue_properties.hpp --- SYCL queue properties -------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#pragma once

#include <sycl/detail/property_helper.hpp> // for DataLessPropKind
#include <sycl/properties/property_traits.hpp> // for is_property_of

#include <type_traits> // for true_type

namespace sycl {
inline namespace _V1 {
namespace ext {
namespace oneapi {
namespace experimental {
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
namespace NS_QUALIFIER { \
class PROP_NAME \
: public sycl::detail::DataLessProperty<sycl::detail::ENUM_VAL> {}; \
}
#include <sycl/ext/oneapi/experimental/detail/properties/graph_properties.def>

#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
namespace NS_QUALIFIER { \
class PROP_NAME \
: public sycl::detail::DataLessProperty<sycl::detail::ENUM_VAL> {}; \
}
#include <sycl/ext/oneapi/experimental/detail/properties/node_properties.def>

class node;
namespace property::node {
class depends_on;
} // namespace property::node
// Graph property trait specializations.
enum class graph_state;
template <graph_state State> class command_graph;

} // namespace experimental
} // namespace oneapi
} // namespace ext

#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \
template <ext::oneapi::experimental::graph_state State> \
struct is_property_of<ext::oneapi::experimental::NS_QUALIFIER::PROP_NAME, \
ext::oneapi::experimental::command_graph<State>> \
: std::true_type {};
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
__SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)

#include <sycl/ext/oneapi/experimental/detail/properties/graph_properties.def>

#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \
template <> \
struct is_property_of<ext::oneapi::experimental::NS_QUALIFIER::PROP_NAME, \
ext::oneapi::experimental::node> : std::true_type {};
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
__SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)

#include <sycl/ext/oneapi/experimental/detail/properties/node_properties.def>

} // namespace _V1
} // namespace sycl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// --*- c++ -*---
#ifndef __SYCL_DATA_LESS_PROP
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL)
#endif
#ifndef __SYCL_MANUALLY_DEFINED_PROP
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
#endif

/// Property used to to add all previous graph leaves as dependencies when
/// creating a new node with command_graph::add().
__SYCL_DATA_LESS_PROP(property::node, depends_on_all_leaves, GraphDependOnAllLeaves)

// Contains data field, defined explicitly.
__SYCL_MANUALLY_DEFINED_PROP(property::node, depends_on)

#undef __SYCL_DATA_LESS_PROP
#undef __SYCL_MANUALLY_DEFINED_PROP
80 changes: 8 additions & 72 deletions sycl/include/sycl/ext/oneapi/experimental/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#include <sycl/detail/kernel_desc.hpp> // for kernel_param_kind_t
#include <sycl/detail/property_helper.hpp> // for DataLessPropKind, PropWith...
#include <sycl/device.hpp> // for device
#include <sycl/nd_range.hpp> // for range, nd_range
#include <sycl/ext/oneapi/experimental/detail/properties/graph_properties.hpp> // for graph properties classes
#include <sycl/nd_range.hpp> // for range, nd_range
#include <sycl/properties/property_traits.hpp> // for is_property, is_property_of
#include <sycl/property_list.hpp> // for property_list

Expand Down Expand Up @@ -145,47 +146,7 @@ class __SYCL_EXPORT node {
std::shared_ptr<detail::node_impl> impl;
};

namespace property {
namespace graph {

/// Property passed to command_graph constructor to disable checking for cycles.
///
class no_cycle_check : public ::sycl::detail::DataLessProperty<
::sycl::detail::GraphNoCycleCheck> {
public:
no_cycle_check() = default;
};

/// Property passed to command_graph constructor to allow buffers to be used
/// with graphs. Passing this property represents a promise from the user that
/// the buffer will outlive any graph that it is used in.
///
class assume_buffer_outlives_graph
: public ::sycl::detail::DataLessProperty<
::sycl::detail::GraphAssumeBufferOutlivesGraph> {
public:
assume_buffer_outlives_graph() = default;
};

/// Property passed to command_graph<graph_state::modifiable>::finalize() to
/// mark the resulting executable command_graph as able to be updated.
class updatable
: public ::sycl::detail::DataLessProperty<::sycl::detail::GraphUpdatable> {
public:
updatable() = default;
};

/// Property used to enable executable graph profiling. Enables profiling on
/// events returned by submissions of the executable graph
class enable_profiling : public ::sycl::detail::DataLessProperty<
::sycl::detail::GraphEnableProfiling> {
public:
enable_profiling() = default;
};
} // namespace graph

namespace node {

namespace property::node {
/// Property used to define dependent nodes when creating a new node with
/// command_graph::add().
class depends_on : public ::sycl::detail::PropertyWithData<
Expand All @@ -201,17 +162,7 @@ class depends_on : public ::sycl::detail::PropertyWithData<
private:
const std::vector<::sycl::ext::oneapi::experimental::node> MDeps;
};

/// Property used to to add all previous graph leaves as dependencies when
/// creating a new node with command_graph::add().
class depends_on_all_leaves : public ::sycl::detail::DataLessProperty<
::sycl::detail::GraphDependOnAllLeaves> {
public:
depends_on_all_leaves() = default;
};

} // namespace node
} // namespace property
} // namespace property::node

namespace detail {
// Templateless modifiable command-graph base class.
Expand All @@ -234,6 +185,7 @@ class __SYCL_EXPORT modifiable_command_graph {
/// @param PropList Property list used to pass [0..n] predecessor nodes.
/// @return Constructed empty node which has been added to the graph.
node add(const property_list &PropList = {}) {
checkNodePropertiesAndThrow(PropList);
if (PropList.has_property<property::node::depends_on>()) {
auto Deps = PropList.get_property<property::node::depends_on>();
node Node = addImpl(Deps.get_dependencies());
Expand All @@ -254,6 +206,7 @@ class __SYCL_EXPORT modifiable_command_graph {
/// @param PropList Property list used to pass [0..n] predecessor nodes.
/// @return Constructed node which has been added to the graph.
template <typename T> node add(T CGF, const property_list &PropList = {}) {
checkNodePropertiesAndThrow(PropList);
if (PropList.has_property<property::node::depends_on>()) {
auto Deps = PropList.get_property<property::node::depends_on>();
node Node = addImpl(CGF, Deps.get_dependencies());
Expand Down Expand Up @@ -352,6 +305,8 @@ class __SYCL_EXPORT modifiable_command_graph {
friend T sycl::detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);

std::shared_ptr<detail::graph_impl> impl;

void checkNodePropertiesAndThrow(const property_list &Properties);
};

// Templateless executable command-graph base class.
Expand Down Expand Up @@ -497,24 +452,5 @@ command_graph(const context &SyclContext, const device &SyclDevice,
} // namespace oneapi
} // namespace ext

template <>
struct is_property<ext::oneapi::experimental::property::graph::no_cycle_check>
: std::true_type {};

template <>
struct is_property<ext::oneapi::experimental::property::node::depends_on>
: std::true_type {};

template <>
struct is_property_of<
ext::oneapi::experimental::property::graph::no_cycle_check,
ext::oneapi::experimental::command_graph<
ext::oneapi::experimental::graph_state::modifiable>> : std::true_type {
};

template <>
struct is_property_of<ext::oneapi::experimental::property::node::depends_on,
ext::oneapi::experimental::node> : std::true_type {};

} // namespace _V1
} // namespace sycl
76 changes: 74 additions & 2 deletions sycl/source/detail/graph_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,48 @@ void exec_graph_impl::makePartitions() {
}
}

static void checkGraphPropertiesAndThrow(const property_list &Properties) {
auto CheckDataLessProperties = [](int PropertyKind) {
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
case NS_QUALIFIER::PROP_NAME::getKind(): \
return true;
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
switch (PropertyKind) {
#include <sycl/ext/oneapi/experimental/detail/properties/graph_properties.def>
default:
return false;
}
};
// No properties with data for graph now.
auto NoAllowedPropertiesCheck = [](int) { return false; };
sycl::detail::PropertyValidator::checkPropsAndThrow(
Properties, CheckDataLessProperties, NoAllowedPropertiesCheck);
}

graph_impl::graph_impl(const sycl::context &SyclContext,
const sycl::device &SyclDevice,
const sycl::property_list &PropList)
: MContext(SyclContext), MDevice(SyclDevice), MRecordingQueues(),
MEventsMap(), MInorderQueueMap() {
checkGraphPropertiesAndThrow(PropList);
if (PropList.has_property<property::graph::no_cycle_check>()) {
MSkipCycleChecks = true;
}
if (PropList.has_property<property::graph::assume_buffer_outlives_graph>()) {
MAllowBuffers = true;
}

if (!SyclDevice.has(aspect::ext_oneapi_limited_graph) &&
!SyclDevice.has(aspect::ext_oneapi_graph)) {
std::stringstream Stream;
Stream << SyclDevice.get_backend();
std::string BackendString = Stream.str();
throw sycl::exception(
sycl::make_error_code(errc::invalid),
BackendString + " backend is not supported by SYCL Graph extension.");
}
}

graph_impl::~graph_impl() {
try {
clearQueues();
Expand Down Expand Up @@ -814,7 +856,7 @@ exec_graph_impl::exec_graph_impl(sycl::context Context,
MIsUpdatable(PropList.has_property<property::graph::updatable>()),
MEnableProfiling(
PropList.has_property<property::graph::enable_profiling>()) {

checkGraphPropertiesAndThrow(PropList);
// If the graph has been marked as updatable then check if the backend
// actually supports that. Devices supporting aspect::ext_oneapi_graph must
// have support for graph update.
Expand Down Expand Up @@ -1619,7 +1661,9 @@ modifiable_command_graph::finalize(const sycl::property_list &PropList) const {

void modifiable_command_graph::begin_recording(
queue &RecordingQueue, const sycl::property_list &PropList) {
std::ignore = PropList;
// No properties is handled here originally, just check that properties are
// related to graph at all.
checkGraphPropertiesAndThrow(PropList);

auto QueueImpl = sycl::detail::getSyclObjImpl(RecordingQueue);
assert(QueueImpl);
Expand Down Expand Up @@ -1703,6 +1747,34 @@ std::vector<node> modifiable_command_graph::get_root_nodes() const {
return createNodesFromImpls(Impls);
}

void modifiable_command_graph::checkNodePropertiesAndThrow(
const property_list &Properties) {
auto CheckDataLessProperties = [](int PropertyKind) {
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
case NS_QUALIFIER::PROP_NAME::getKind(): \
return true;
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
switch (PropertyKind) {
#include <sycl/ext/oneapi/experimental/detail/properties/node_properties.def>
default:
return false;
}
};
auto CheckPropertiesWithData = [](int PropertyKind) {
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL)
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \
case NS_QUALIFIER::PROP_NAME::getKind(): \
return true;
switch (PropertyKind) {
#include <sycl/ext/oneapi/experimental/detail/properties/node_properties.def>
default:
return false;
}
};
sycl::detail::PropertyValidator::checkPropsAndThrow(
Properties, CheckDataLessProperties, CheckPropertiesWithData);
}

executable_command_graph::executable_command_graph(
const std::shared_ptr<detail::graph_impl> &Graph, const sycl::context &Ctx,
const property_list &PropList)
Expand Down
22 changes: 1 addition & 21 deletions sycl/source/detail/graph_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,27 +860,7 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
/// @param SyclDevice Device to create nodes with.
/// @param PropList Optional list of properties.
graph_impl(const sycl::context &SyclContext, const sycl::device &SyclDevice,
const sycl::property_list &PropList = {})
: MContext(SyclContext), MDevice(SyclDevice), MRecordingQueues(),
MEventsMap(), MInorderQueueMap() {
if (PropList.has_property<property::graph::no_cycle_check>()) {
MSkipCycleChecks = true;
}
if (PropList
.has_property<property::graph::assume_buffer_outlives_graph>()) {
MAllowBuffers = true;
}

if (!SyclDevice.has(aspect::ext_oneapi_limited_graph) &&
!SyclDevice.has(aspect::ext_oneapi_graph)) {
std::stringstream Stream;
Stream << SyclDevice.get_backend();
std::string BackendString = Stream.str();
throw sycl::exception(
sycl::make_error_code(errc::invalid),
BackendString + " backend is not supported by SYCL Graph extension.");
}
}
const sycl::property_list &PropList = {});

~graph_impl();

Expand Down
Loading
Loading