Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions sycl/include/sycl/property_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class property_list : protected detail::PropertyListBase {

template <typename... T> operator ext::oneapi::accessor_property_list<T...>();

using PropertyListBase::checkPropsAndThrow;

private:
property_list(
std::bitset<detail::DataLessPropKind::DataLessPropKindSize> DataLessProps,
Expand Down
26 changes: 26 additions & 0 deletions sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,32 @@ void queue_impl::doUnenqueuedCommandCleanup(
tryToCleanup(MDefaultGraphDeps);
}

void queue_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/queue_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/queue_properties.def>
default:
return false;
}
};
Props.checkPropsAndThrow(CheckDataLessProperties, CheckPropertiesWithData);
}

} // namespace detail
} // namespace _V1
} // namespace sycl
4 changes: 4 additions & 0 deletions sycl/source/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class queue_impl {
MIsProfilingEnabled(has_property<property::queue::enable_profiling>()),
MQueueID{
MNextAvailableQueueID.fetch_add(1, std::memory_order_relaxed)} {
verifyProps(PropList);
if (has_property<property::queue::enable_profiling>()) {
if (has_property<ext::oneapi::property::queue::discard_events>())
throw sycl::exception(make_error_code(errc::invalid),
Expand Down Expand Up @@ -249,6 +250,7 @@ class queue_impl {
MDiscardEvents(
has_property<ext::oneapi::property::queue::discard_events>()),
MIsProfilingEnabled(has_property<property::queue::enable_profiling>()) {
verifyProps(PropList);
queue_impl_interop(UrQueue);
}

Expand Down Expand Up @@ -984,6 +986,8 @@ class queue_impl {
std::mutex MMissedCleanupRequestsMtx;

friend class sycl::ext::oneapi::experimental::detail::node_impl;

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

} // namespace detail
Expand Down
1 change: 1 addition & 0 deletions sycl/unittests/queue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ add_sycl_unittest(QueueTests OBJECT
ShortcutFunctions.cpp
InOrderQueue.cpp
InteropRetain.cpp
Properties.cpp
)
90 changes: 90 additions & 0 deletions sycl/unittests/queue/Properties.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//==-------- Properties.cpp --- check properties handling in RT --- --------==//
//
// 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
//
//===----------------------------------------------------------------------===//

#include <gtest/gtest.h>
#include <helpers/UrMock.hpp>
#include <sycl/properties/queue_properties.hpp>
#include <sycl/sycl.hpp>

template <typename PropertyType> void DatalessQueuePropertyCheck() {
try {
sycl::queue Queue{PropertyType{}};
ASSERT_TRUE(Queue.has_property<PropertyType>());
Queue.get_property<PropertyType>();
// no explicit checks, we expect no exception to be thrown
} catch (...) {
FAIL();
}
}

TEST(QueueProperties, ValidDatalessProperties) {
sycl::unittest::UrMock<> Mock;
DatalessQueuePropertyCheck<sycl::property::queue::in_order>();
DatalessQueuePropertyCheck<sycl::property::queue::enable_profiling>();
DatalessQueuePropertyCheck<
sycl::ext::oneapi::property::queue::discard_events>();
DatalessQueuePropertyCheck<
sycl::ext::oneapi::property::queue::priority_normal>();
DatalessQueuePropertyCheck<
sycl::ext::oneapi::property::queue::priority_low>();
DatalessQueuePropertyCheck<
sycl::ext::oneapi::property::queue::priority_high>();
DatalessQueuePropertyCheck<
sycl::ext::intel::property::queue::no_immediate_command_list>();
DatalessQueuePropertyCheck<
sycl::ext::intel::property::queue::immediate_command_list>();
DatalessQueuePropertyCheck<
sycl::ext::oneapi::cuda::property::queue::use_default_stream>();
}

inline ur_result_t urDeviceGetInfoRedefined(void *pParams) {
auto params = reinterpret_cast<ur_device_get_info_params_t *>(pParams);
switch (*params->ppropName) {
case UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: {
if (*params->ppPropValue)
*static_cast<int32_t *>(*params->ppPropValue) = 8;
if (*params->ppPropSizeRet)
**params->ppPropSizeRet = sizeof(int32_t);
return UR_RESULT_SUCCESS;
}
default:
return UR_RESULT_SUCCESS;
}
}

TEST(QueueProperties, ValidPropertyComputeIndex) {
sycl::unittest::UrMock<> Mock;
mock::getCallbacks().set_after_callback("urDeviceGetInfo",
&urDeviceGetInfoRedefined);
try {
sycl::queue Queue{sycl::ext::intel::property::queue::compute_index{1}};
ASSERT_TRUE(
Queue.has_property<sycl::ext::intel::property::queue::compute_index>());
EXPECT_EQ(
Queue.get_property<sycl::ext::intel::property::queue::compute_index>()
.get_index(),
1);
// no explicit checks, we expect no exception to be thrown
} catch (...) {
FAIL();
}
}

TEST(QueueProperties, SetUnsupportedParam) {
sycl::unittest::UrMock<> Mock;
try {
sycl::queue Queue{sycl::property::image::use_host_ptr{}};
} catch (sycl::exception &e) {
EXPECT_EQ(e.code(), sycl::errc::invalid);
EXPECT_STREQ(e.what(), "The property list contains property unsupported "
"for the current object");
return;
}

FAIL() << "Test must exit in exception handler. Exception is not thrown.";
}