Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 12 additions & 15 deletions sycl/include/sycl/ext/intel/experimental/grf_size_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,26 @@ template <typename Properties>
struct ConflictingProperties<sycl::ext::intel::experimental::grf_size_key,
Properties>
: std::bool_constant<
ContainsProperty<
sycl::ext::intel::experimental::grf_size_automatic_key,
Properties>::value ||
ContainsProperty<sycl::detail::register_alloc_mode_key,
Properties>::value> {};
Properties::template has_property<
sycl::ext::intel::experimental::grf_size_automatic_key>() ||
Properties::template has_property<
sycl::detail::register_alloc_mode_key>()> {};

template <typename Properties>
struct ConflictingProperties<
sycl::ext::intel::experimental::grf_size_automatic_key, Properties>
: std::bool_constant<
ContainsProperty<sycl::ext::intel::experimental::grf_size_key,
Properties>::value ||
ContainsProperty<sycl::detail::register_alloc_mode_key,
Properties>::value> {};
: std::bool_constant<Properties::template has_property<
sycl::ext::intel::experimental::grf_size_key>() ||
Properties::template has_property<
sycl::detail::register_alloc_mode_key>()> {};

template <typename Properties>
struct ConflictingProperties<sycl::detail::register_alloc_mode_key, Properties>
: std::bool_constant<
ContainsProperty<sycl::ext::intel::experimental::grf_size_key,
Properties>::value ||
ContainsProperty<
sycl::ext::intel::experimental::grf_size_automatic_key,
Properties>::value> {};
Properties::template has_property<
sycl::ext::intel::experimental::grf_size_key>() ||
Properties::template has_property<
sycl::ext::intel::experimental::grf_size_automatic_key>()> {};

} // namespace ext::oneapi::experimental::detail
} // namespace _V1
Expand Down
32 changes: 20 additions & 12 deletions sycl/include/sycl/ext/intel/experimental/pipes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,21 +376,29 @@ class pipe : public pipe_base {
static constexpr int32_t m_Capacity = _min_capacity;

static constexpr int32_t m_ready_latency =
oneapi::experimental::detail::ValueOrDefault<
_propertiesT, ready_latency_key>::template get<int32_t>(0);
oneapi::experimental::detail::get_property_or<ready_latency_key,
_propertiesT>(
ready_latency<0>)
.value;

static constexpr int32_t m_bits_per_symbol =
oneapi::experimental::detail::ValueOrDefault<
_propertiesT, bits_per_symbol_key>::template get<int32_t>(8);
oneapi::experimental::detail::get_property_or<bits_per_symbol_key,
_propertiesT>(
bits_per_symbol<8>)
.value;
static constexpr bool m_uses_valid =
oneapi::experimental::detail::ValueOrDefault<
_propertiesT, uses_valid_key>::template get<bool>(true);
oneapi::experimental::detail::get_property_or<uses_valid_key,
_propertiesT>(uses_valid_on)
.value;
static constexpr bool m_first_symbol_in_high_order_bits =
oneapi::experimental::detail::ValueOrDefault<
_propertiesT,
first_symbol_in_high_order_bits_key>::template get<int32_t>(0);
static constexpr protocol_name m_protocol = oneapi::experimental::detail::
ValueOrDefault<_propertiesT, protocol_key>::template get<protocol_name>(
protocol_name::avalon_streaming_uses_ready);
oneapi::experimental::detail::get_property_or<
first_symbol_in_high_order_bits_key, _propertiesT>(
first_symbol_in_high_order_bits_off)
.value;
static constexpr protocol_name m_protocol =
oneapi::experimental::detail::get_property_or<protocol_key, _propertiesT>(
protocol_avalon_streaming_uses_ready)
.value;

public:
static constexpr struct ConstantPipeStorageExp m_Storage = {
Expand Down
35 changes: 20 additions & 15 deletions sycl/include/sycl/ext/intel/experimental/task_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,28 @@ class task_sequence<
__spv::__spirv_TaskSequenceINTEL *taskSequence;
#endif
static constexpr int32_t pipelined =
oneapi::experimental::detail::ValueOrDefault<
property_list_t, pipelined_key>::template get<int32_t>(-1);
static constexpr int32_t fpga_cluster =
has_property<fpga_cluster_key>()
? static_cast<
typename std::underlying_type<fpga_cluster_options_enum>::type>(
oneapi::experimental::detail::ValueOrDefault<property_list_t,
fpga_cluster_key>::
template get<fpga_cluster_options_enum>(
fpga_cluster_options_enum::stall_free))
: -1;
oneapi::experimental::detail::get_property_or<pipelined_key,
property_list_t>(
intel::experimental::pipelined<-1>)
.value;
static constexpr int32_t fpga_cluster = []() constexpr {
if constexpr (has_property<fpga_cluster_key>())
return static_cast<
typename std::underlying_type<fpga_cluster_options_enum>::type>(
get_property<fpga_cluster_key>().value);
else
return -1;
}();
static constexpr uint32_t response_capacity =
oneapi::experimental::detail::ValueOrDefault<
property_list_t, response_capacity_key>::template get<uint32_t>(0);
oneapi::experimental::detail::get_property_or<response_capacity_key,
property_list_t>(
intel::experimental::response_capacity<0>)
.value;
static constexpr uint32_t invocation_capacity =
oneapi::experimental::detail::ValueOrDefault<
property_list_t, invocation_capacity_key>::template get<uint32_t>(0);
oneapi::experimental::detail::get_property_or<invocation_capacity_key,
property_list_t>(
intel::experimental::invocation_capacity<0>)
.value;
};

} // namespace ext::intel::experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ template <typename propertyListA = empty_properties_t,
std::enable_if_t<
detail::CheckTAndPropLists<void, propertyListA, propertyListB>::value,
annotated_ptr<void, propertyListB>>
aligned_alloc_annotated(size_t alignment, size_t numBytes,
const device &syclDevice, const context &syclContext,
sycl::usm::alloc kind,
aligned_alloc_annotated(size_t align, size_t numBytes, const device &syclDevice,
const context &syclContext, sycl::usm::alloc kind,
const propertyListA &propList = propertyListA{}) {
detail::ValidAllocPropertyList<void, propertyListA>::value;

Expand All @@ -53,12 +52,12 @@ aligned_alloc_annotated(size_t alignment, size_t numBytes,
static_cast<void>(propList);

constexpr size_t alignFromPropList =
detail::GetAlignFromPropList<propertyListA>::value;
detail::get_property_or<alignment_key, propertyListA>(alignment<0>).value;
const property_list &usmPropList = get_usm_property_list<propertyListA>();

if constexpr (detail::HasUsmKind<propertyListA>::value) {
if constexpr (propertyListA::template has_property<usm_kind_key>()) {
constexpr sycl::usm::alloc usmKind =
detail::GetUsmKindFromPropList<propertyListA>::value;
propertyListA::template get_property<usm_kind_key>().value;
if (usmKind != kind) {
throw sycl::exception(
sycl::make_error_code(sycl::errc::invalid),
Expand All @@ -72,7 +71,7 @@ aligned_alloc_annotated(size_t alignment, size_t numBytes,
"Unknown USM allocation kind was specified.");

void *rawPtr =
sycl::aligned_alloc(combine_align(alignment, alignFromPropList), numBytes,
sycl::aligned_alloc(combine_align(align, alignFromPropList), numBytes,
syclDevice, syclContext, kind, usmPropList);
return annotated_ptr<void, propertyListB>(rawPtr);
}
Expand All @@ -83,9 +82,8 @@ template <typename T, typename propertyListA = empty_properties_t,
std::enable_if_t<
detail::CheckTAndPropLists<T, propertyListA, propertyListB>::value,
annotated_ptr<T, propertyListB>>
aligned_alloc_annotated(size_t alignment, size_t count,
const device &syclDevice, const context &syclContext,
sycl::usm::alloc kind,
aligned_alloc_annotated(size_t align, size_t count, const device &syclDevice,
const context &syclContext, sycl::usm::alloc kind,
const propertyListA &propList = propertyListA{}) {
detail::ValidAllocPropertyList<T, propertyListA>::value;

Expand All @@ -95,12 +93,12 @@ aligned_alloc_annotated(size_t alignment, size_t count,
static_cast<void>(propList);

constexpr size_t alignFromPropList =
detail::GetAlignFromPropList<propertyListA>::value;
detail::get_property_or<alignment_key, propertyListA>(alignment<0>).value;
const property_list &usmPropList = get_usm_property_list<propertyListA>();

if constexpr (detail::HasUsmKind<propertyListA>::value) {
if constexpr (propertyListA::template has_property<usm_kind_key>()) {
constexpr sycl::usm::alloc usmKind =
detail::GetUsmKindFromPropList<propertyListA>::value;
propertyListA::template get_property<usm_kind_key>().value;
if (usmKind != kind) {
throw sycl::exception(
sycl::make_error_code(sycl::errc::invalid),
Expand All @@ -113,7 +111,7 @@ aligned_alloc_annotated(size_t alignment, size_t count,
throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
"Unknown USM allocation kind was specified.");

size_t combinedAlign = combine_align(alignment, alignFromPropList);
size_t combinedAlign = combine_align(align, alignFromPropList);
T *rawPtr = sycl::aligned_alloc<T>(combinedAlign, count, syclDevice,
syclContext, kind, usmPropList);
return annotated_ptr<T, propertyListB>(rawPtr);
Expand Down Expand Up @@ -212,7 +210,9 @@ std::enable_if_t<
malloc_annotated(size_t numBytes, const device &syclDevice,
const context &syclContext, const propertyListA &propList) {
constexpr sycl::usm::alloc usmKind =
detail::GetUsmKindFromPropList<propertyListA>::value;
detail::get_property_or<usm_kind_key, propertyListA>(
usm_kind<sycl::usm::alloc::unknown>)
.value;
static_assert(usmKind != sycl::usm::alloc::unknown,
"USM kind is not specified. Please specify it as an argument "
"or in the input property list.");
Expand All @@ -228,7 +228,9 @@ std::enable_if_t<
malloc_annotated(size_t count, const device &syclDevice,
const context &syclContext, const propertyListA &propList) {
constexpr sycl::usm::alloc usmKind =
detail::GetUsmKindFromPropList<propertyListA>::value;
detail::get_property_or<usm_kind_key, propertyListA>(
usm_kind<sycl::usm::alloc::unknown>)
.value;
static_assert(usmKind != sycl::usm::alloc::unknown,
"USM kind is not specified. Please specify it as an argument "
"or in the input property list.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,52 +25,6 @@ namespace detail {
// Type traits for USM allocation with property support
////

// Merge a property list with the usm_kind property
template <sycl::usm::alloc Kind, typename PropertyListT>
using MergeUsmKind =
detail::merged_properties_t<PropertyListT,
decltype(properties{usm_kind<Kind>})>;

// Check if a property list contains the a certain property
template <typename PropKey, typename PropertyListT>
struct HasProperty
: std::bool_constant<PropertyListT::template has_property<PropKey>()> {};

template <typename PropertyListT>
using HasAlign = HasProperty<alignment_key, PropertyListT>;
template <typename PropertyListT>
using HasUsmKind = HasProperty<usm_kind_key, PropertyListT>;
template <typename PropertyListT>
using HasBufferLocation = HasProperty<buffer_location_key, PropertyListT>;

template <typename PropKey, typename ConstType, typename DefaultPropVal,
typename... Props>
struct GetPropertyValueFromPropList<PropKey, ConstType, DefaultPropVal,
detail::properties_t<Props...>>
: GetPropertyValueFromPropList<PropKey, ConstType, DefaultPropVal,
std::tuple<Props...>> {};

// Get the value of alignment from a property list
// If alignment is not present in the property list, set to default value 0
template <typename PropertyListT>
using GetAlignFromPropList =
GetPropertyValueFromPropList<alignment_key, size_t, decltype(alignment<0>),
PropertyListT>;
// Get the value of usm_kind from a property list
// The usm_kind is sycl::usm::alloc::unknown by default
template <typename PropertyListT>
using GetUsmKindFromPropList =
GetPropertyValueFromPropList<usm_kind_key, sycl::usm::alloc,
decltype(usm_kind<sycl::usm::alloc::unknown>),
PropertyListT>;
// Get the value of buffer_location from a property list
// The buffer location is -1 by default
template <typename PropertyListT>
using GetBufferLocationFromPropList = GetPropertyValueFromPropList<
buffer_location_key, int,
decltype(sycl::ext::intel::experimental::buffer_location<-1>),
PropertyListT>;

// Check if a runtime property is valid
template <typename Prop> struct IsRuntimePropertyValid : std::false_type {};

Expand Down Expand Up @@ -143,9 +97,10 @@ struct GetAnnotatedPtrPropertiesWithUsmKind<Kind,
using filtered_input_properties_t =
typename GetCompileTimeProperties<input_properties_t>::type;

static_assert(!HasUsmKind<input_properties_t>::value ||
GetUsmKindFromPropList<input_properties_t>::value == Kind,
"Input property list contains conflicting USM kind.");
static_assert(
detail::get_property_or<usm_kind_key, input_properties_t>(usm_kind<Kind>)
.value == Kind,
"Input property list contains conflicting USM kind.");

using type =
detail::merged_properties_t<filtered_input_properties_t,
Expand Down Expand Up @@ -211,10 +166,10 @@ struct CheckTAndPropListsWithUsmKind<Kind, T, detail::properties_t<PropsA...>,
// runtime). Right now only the `buffer_location<N>` has its corresponding USM
// runtime property and is transformable
template <typename PropertyListT> inline property_list get_usm_property_list() {
if constexpr (detail::HasBufferLocation<PropertyListT>::value) {
if constexpr (PropertyListT::template has_property<buffer_location_key>()) {
return property_list{
sycl::ext::intel::experimental::property::usm::buffer_location(
detail::GetBufferLocationFromPropList<PropertyListT>::value)};
PropertyListT::template get_property<buffer_location_key>().value)};
}
return {};
}
Expand Down
Loading
Loading