Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 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
e44a496
fix win build
KseniyaTikhomirova Oct 8, 2024
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
3 changes: 2 additions & 1 deletion sycl/include/sycl/detail/property_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class PropertyWithDataBase {
PropertyWithDataBase(int ID) : MID(ID) {}
bool isSame(int ID) const { return ID == MID; }
virtual ~PropertyWithDataBase() = default;
int getKind() const { return MID; }

private:
int MID = -1;
Expand All @@ -99,7 +100,7 @@ class PropertyWithDataBase {
template <int ID> class PropertyWithData : public PropertyWithDataBase {
public:
PropertyWithData() : PropertyWithDataBase(ID) {}
static int getKind() { return ID; }
static constexpr int getKind() { return ID; }
};

} // namespace detail
Expand Down
19 changes: 19 additions & 0 deletions sycl/include/sycl/detail/property_list_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,25 @@ class PropertyListBase {
}
}

void checkPropsAndThrow(std::function<bool(int)> FunctionForDataless,
std::function<bool(int)> FunctionForData) const {
static const auto ErrorCode = sycl::make_error_code(errc::invalid);
static const auto ErrorMessage = "The property list contains property "
"unsupported for the current object";

for (int PropertyKind = 0;
PropertyKind < static_cast<int>(MDataLessProps.size());
PropertyKind++) {
if (MDataLessProps[PropertyKind] && !FunctionForDataless(PropertyKind))
throw sycl::exception(ErrorCode, ErrorMessage);
}

for (const auto &PropertyItem : MPropsWithData) {
if (!FunctionForData(PropertyItem->getKind()))
throw sycl::exception(ErrorCode, ErrorMessage);
}
}

// Stores enabled/disabled for simple properties
std::bitset<DataLessPropKind::DataLessPropKindSize> MDataLessProps;
// Stores shared_ptrs to complex properties
Expand Down
19 changes: 19 additions & 0 deletions sycl/include/sycl/properties/buffer_properties.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// --*- 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

__SYCL_DATA_LESS_PROP(property::buffer, use_host_ptr, BufferUseHostPtr)
__SYCL_DATA_LESS_PROP(ext::oneapi::property::buffer, use_pinned_host_memory, BufferUsePinnedHostMemory)

// Contains data field, defined explicitly.
__SYCL_MANUALLY_DEFINED_PROP(property::buffer, use_mutex)
__SYCL_MANUALLY_DEFINED_PROP(property::buffer, context_bound)
__SYCL_MANUALLY_DEFINED_PROP(property::buffer, mem_channel)
__SYCL_MANUALLY_DEFINED_PROP(property::buffer::detail, buffer_location)

#undef __SYCL_DATA_LESS_PROP
#undef __SYCL_MANUALLY_DEFINED_PROP
49 changes: 15 additions & 34 deletions sycl/include/sycl/properties/buffer_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@

namespace sycl {
inline namespace _V1 {
#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/properties/buffer_properties.def>

namespace property::buffer {
class use_host_ptr : public detail::DataLessProperty<detail::BufferUseHostPtr> {
};

class use_mutex : public detail::PropertyWithData<detail::BufferUseMutex> {
public:
use_mutex(std::mutex &MutexRef) : MMutex(MutexRef) {}
Expand Down Expand Up @@ -69,41 +72,19 @@ class buffer_location
} // namespace detail
} // namespace property::buffer

namespace ext::oneapi::property::buffer {

class use_pinned_host_memory : public sycl::detail::DataLessProperty<
sycl::detail::BufferUsePinnedHostMemory> {};
} // namespace ext::oneapi::property::buffer

// Forward declaration
template <typename T, int Dimensions, typename AllocatorT, typename Enable>
class buffer;

// Buffer property trait specializations
template <typename T, int Dimensions, typename AllocatorT>
struct is_property_of<property::buffer::use_host_ptr,
buffer<T, Dimensions, AllocatorT, void>>
: std::true_type {};
template <typename T, int Dimensions, typename AllocatorT>
struct is_property_of<property::buffer::use_mutex,
buffer<T, Dimensions, AllocatorT, void>>
: std::true_type {};
template <typename T, int Dimensions, typename AllocatorT>
struct is_property_of<property::buffer::detail::buffer_location,
buffer<T, Dimensions, AllocatorT, void>>
: std::true_type {};
template <typename T, int Dimensions, typename AllocatorT>
struct is_property_of<property::buffer::context_bound,
buffer<T, Dimensions, AllocatorT, void>>
: std::true_type {};
template <typename T, int Dimensions, typename AllocatorT>
struct is_property_of<property::buffer::mem_channel,
buffer<T, Dimensions, AllocatorT, void>>
: std::true_type {};
template <typename T, int Dimensions, typename AllocatorT>
struct is_property_of<ext::oneapi::property::buffer::use_pinned_host_memory,
buffer<T, Dimensions, AllocatorT, void>>
: std::true_type {};
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \
template <typename T, int Dimensions, typename AllocatorT> \
struct is_property_of<NS_QUALIFIER::PROP_NAME, \
buffer<T, Dimensions, AllocatorT, void>> \
: std::true_type {};
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
__SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)

#include <sycl/properties/buffer_properties.def>

} // namespace _V1
} // namespace sycl
16 changes: 16 additions & 0 deletions sycl/include/sycl/properties/image_properties.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// --*- 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

__SYCL_DATA_LESS_PROP(property::image, use_host_ptr, ImageUseHostPtr)

// Contains data field, defined explicitly.
__SYCL_MANUALLY_DEFINED_PROP(property::image, use_mutex)
__SYCL_MANUALLY_DEFINED_PROP(property::image, context_bound)

#undef __SYCL_DATA_LESS_PROP
#undef __SYCL_MANUALLY_DEFINED_PROP
65 changes: 29 additions & 36 deletions sycl/include/sycl/properties/image_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@

namespace sycl {
inline namespace _V1 {
namespace property::image {
class use_host_ptr : public detail::DataLessProperty<detail::ImageUseHostPtr> {
};
#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/properties/image_properties.def>

namespace property::image {
class use_mutex : public detail::PropertyWithData<detail::ImageUseMutex> {
public:
use_mutex(std::mutex &MutexRef) : MMutex(MutexRef) {}
Expand Down Expand Up @@ -50,41 +54,30 @@ template <int Dimensions, typename AllocatorT> class sampled_image;
template <int Dimensions, typename AllocatorT> class unsampled_image;

// SYCL 1.2.1 image property trait specializations
template <int Dimensions, typename AllocatorT>
struct is_property_of<property::image::use_host_ptr,
image<Dimensions, AllocatorT>> : std::true_type {};
template <int Dimensions, typename AllocatorT>
struct is_property_of<property::image::use_mutex, image<Dimensions, AllocatorT>>
: std::true_type {};
template <int Dimensions, typename AllocatorT>
struct is_property_of<property::image::context_bound,
image<Dimensions, AllocatorT>> : std::true_type {};
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \
template <int Dimensions, typename AllocatorT> \
struct is_property_of < NS_QUALIFIER::PROP_NAME, \
image<Dimensions, AllocatorT> : std::true_type {};
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
__SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
#include <sycl/properties/image_properties.def>

// SYCL 2020 image property trait specializations
template <int Dimensions, typename AllocatorT>
struct is_property_of<property::image::use_host_ptr,
sampled_image<Dimensions, AllocatorT>> : std::true_type {
};
template <int Dimensions, typename AllocatorT>
struct is_property_of<property::image::use_mutex,
sampled_image<Dimensions, AllocatorT>> : std::true_type {
};
template <int Dimensions, typename AllocatorT>
struct is_property_of<property::image::context_bound,
sampled_image<Dimensions, AllocatorT>> : std::true_type {
};
template <int Dimensions, typename AllocatorT>
struct is_property_of<property::image::use_host_ptr,
unsampled_image<Dimensions, AllocatorT>>
: std::true_type {};
template <int Dimensions, typename AllocatorT>
struct is_property_of<property::image::use_mutex,
unsampled_image<Dimensions, AllocatorT>>
: std::true_type {};
template <int Dimensions, typename AllocatorT>
struct is_property_of<property::image::context_bound,
unsampled_image<Dimensions, AllocatorT>>
: std::true_type {};
#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \
template <int Dimensions, typename AllocatorT> \
struct is_property_of < NS_QUALIFIER::PROP_NAME, \
sampled_image<Dimensions, AllocatorT> : std::true_type {};
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
__SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
#include <sycl/properties/image_properties.def>

#define __SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME) \
template <int Dimensions, typename AllocatorT> \
struct is_property_of < NS_QUALIFIER::PROP_NAME, \
unsampled_image<Dimensions, AllocatorT> : std::true_type {};
#define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \
__SYCL_MANUALLY_DEFINED_PROP(NS_QUALIFIER, PROP_NAME)
#include <sycl/properties/image_properties.def>

} // namespace _V1
} // namespace sycl
15 changes: 15 additions & 0 deletions sycl/include/sycl/property_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ inline namespace _V1 {
namespace ext::oneapi {
template <typename... PropsT> class accessor_property_list;
} // namespace ext::oneapi
namespace detail {
class PropertyValidator;
} // namespace detail

/// Objects of the property_list class are containers for the SYCL properties
///
Expand Down Expand Up @@ -72,7 +75,19 @@ class property_list : protected detail::PropertyListBase {

template <typename... PropsT>
friend class ext::oneapi::accessor_property_list;
friend class detail::PropertyValidator;
};

namespace detail {
class PropertyValidator {
public:
static void checkPropsAndThrow(const property_list &PropList,
std::function<bool(int)> FunctionForDataless,
std::function<bool(int)> FunctionForData) {
PropList.checkPropsAndThrow(FunctionForDataless, FunctionForData);
}
};
} // namespace detail

} // namespace _V1
} // namespace sycl
29 changes: 29 additions & 0 deletions sycl/source/detail/buffer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <detail/scheduler/scheduler.hpp>
#include <detail/xpti_registry.hpp>
#include <sycl/detail/ur.hpp>
#include <sycl/properties/buffer_properties.hpp>

namespace sycl {
inline namespace _V1 {
Expand Down Expand Up @@ -99,6 +100,34 @@ buffer_impl::getNativeVector(backend BackendName) const {
addInteropObject(Handles);
return Handles;
}

void buffer_impl::verifyProps(const property_list &Props) const {
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/properties/buffer_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/properties/buffer_properties.def>
default:
return false;
}
};
detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties,
CheckPropertiesWithData);
}

} // namespace detail
} // namespace _V1
} // namespace sycl
11 changes: 7 additions & 4 deletions sycl/source/detail/buffer_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class buffer_impl final : public SYCLMemObjT {
buffer_impl(size_t SizeInBytes, size_t, const property_list &Props,
std::unique_ptr<SYCLMemObjAllocator> Allocator)
: BaseT(SizeInBytes, Props, std::move(Allocator)) {

verifyProps(Props);
if (Props.has_property<sycl::property::buffer::use_host_ptr>())
throw sycl::exception(
make_error_code(errc::invalid),
Expand All @@ -57,7 +57,7 @@ class buffer_impl final : public SYCLMemObjT {
const property_list &Props,
std::unique_ptr<SYCLMemObjAllocator> Allocator)
: BaseT(SizeInBytes, Props, std::move(Allocator)) {

verifyProps(Props);
if (Props.has_property<
sycl::ext::oneapi::property::buffer::use_pinned_host_memory>())
throw sycl::exception(
Expand All @@ -71,7 +71,7 @@ class buffer_impl final : public SYCLMemObjT {
const property_list &Props,
std::unique_ptr<SYCLMemObjAllocator> Allocator)
: BaseT(SizeInBytes, Props, std::move(Allocator)) {

verifyProps(Props);
if (Props.has_property<
sycl::ext::oneapi::property::buffer::use_pinned_host_memory>())
throw sycl::exception(
Expand All @@ -86,7 +86,7 @@ class buffer_impl final : public SYCLMemObjT {
const property_list &Props,
std::unique_ptr<SYCLMemObjAllocator> Allocator, bool IsConstPtr)
: BaseT(SizeInBytes, Props, std::move(Allocator)) {

verifyProps(Props);
if (Props.has_property<
sycl::ext::oneapi::property::buffer::use_pinned_host_memory>())
throw sycl::exception(
Expand All @@ -103,6 +103,7 @@ class buffer_impl final : public SYCLMemObjT {
std::unique_ptr<detail::SYCLMemObjAllocator> Allocator,
bool IsConstPtr)
: BaseT(SizeInBytes, Props, std::move(Allocator)) {
verifyProps(Props);
if (Props.has_property<
sycl::ext::oneapi::property::buffer::use_pinned_host_memory>())
throw sycl::exception(
Expand Down Expand Up @@ -152,6 +153,8 @@ class buffer_impl final : public SYCLMemObjT {
void addInteropObject(std::vector<ur_native_handle_t> &Handles) const;

std::vector<ur_native_handle_t> getNativeVector(backend BackendName) const;

void verifyProps(const property_list &Props) const;
};

} // namespace detail
Expand Down
27 changes: 27 additions & 0 deletions sycl/source/detail/image_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,33 @@ void image_impl::unsampledImageDestructorNotification(void *UserObj) {
XPTIRegistry::unsampledImageDestructorNotification(UserObj);
}

void image_impl::verifyProps(const property_list &Props) const {
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/properties/image_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/properties/image_properties.def>
default:
return false;
}
};
detail::PropertyValidator::checkPropsAndThrow(Props, CheckDataLessProperties,
CheckPropertiesWithData);
}

} // namespace detail
} // namespace _V1
} // namespace sycl
Loading