Skip to content

[SYCL] Reorganize annotated_arg/ptr folder #10420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 21, 2023
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//==-- properties.hpp - SYCL properties associated with annotated_arg/ptr --==//
//==-- fpga_annotated_properties.hpp - SYCL properties associated with
// annotated_arg/ptr --==//
Comment on lines +1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@broxigarchen, formatting if off here and in sycl/include/sycl/ext/oneapi/experimental/common_annotated_properties/properties.hpp.

//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand All @@ -8,20 +9,19 @@

#pragma once

#include <sycl/ext/oneapi/properties/property.hpp>
#include <sycl/ext/oneapi/properties/property_value.hpp>
#include <sycl/ext/oneapi/experimental/common_annotated_properties/properties.hpp>

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace ext {
namespace oneapi {
namespace intel {
namespace experimental {

template <typename T, typename PropertyListT> class annotated_arg;
template <typename T, typename PropertyListT> class annotated_ptr;

template <typename PropertyT, typename... Ts>
using property_value =
sycl::ext::oneapi::experimental::property_value<PropertyT, Ts...>;
//===----------------------------------------------------------------------===//
// Common properties of annotated_arg/annotated_ptr
// FPGA properties of annotated_arg/annotated_ptr
//===----------------------------------------------------------------------===//
struct register_map_key {
using value_t = property_value<register_map_key>;
Expand Down Expand Up @@ -102,6 +102,27 @@ inline constexpr read_write_mode_key::value_t<read_write_mode_enum::write>
inline constexpr read_write_mode_key::value_t<read_write_mode_enum::read_write>
read_write_mode_readwrite;

} // namespace experimental
} // namespace intel

namespace oneapi {
namespace experimental {
template <typename T, typename PropertyListT> class annotated_arg;
template <typename T, typename PropertyListT> class annotated_ptr;

struct alignment_key;
using register_map_key = intel::experimental::register_map_key;
using conduit_key = intel::experimental::conduit_key;
using stable_key = intel::experimental::stable_key;
using buffer_location_key = intel::experimental::buffer_location_key;
using awidth_key = intel::experimental::awidth_key;
using dwidth_key = intel::experimental::dwidth_key;
using latency_key = intel::experimental::latency_key;
using read_write_mode_key = intel::experimental::read_write_mode_key;
using maxburst_key = intel::experimental::maxburst_key;
using wait_request_key = intel::experimental::wait_request_key;
using read_write_mode_enum = intel::experimental::read_write_mode_enum;

template <> struct is_property_key<register_map_key> : std::true_type {};
template <> struct is_property_key<conduit_key> : std::true_type {};
template <> struct is_property_key<stable_key> : std::true_type {};
Expand Down Expand Up @@ -287,9 +308,6 @@ struct PropertyMetaInfo<read_write_mode_key::value_t<Mode>> {
} // namespace detail

// 'buffer_location' and mmhost properties are pointers-only
template <typename T, typename PropertyValueT>
struct is_valid_property : std::false_type {};

template <typename T, int N>
struct is_valid_property<T, buffer_location_key::value_t<N>>
: std::bool_constant<std::is_pointer<T>::value> {};
Expand Down Expand Up @@ -327,69 +345,11 @@ struct is_valid_property<T, conduit_key::value_t> : std::true_type {};
template <typename T>
struct is_valid_property<T, stable_key::value_t> : std::true_type {};

template <typename T, typename... Props>
struct check_property_list : std::true_type {};

template <typename T, typename Prop, typename... Props>
struct check_property_list<T, Prop, Props...>
: std::conditional_t<is_valid_property<T, Prop>::value,
check_property_list<T, Props...>, std::false_type> {
static_assert(is_valid_property<T, Prop>::value,
"Property is invalid for the given type.");
};

//===----------------------------------------------------------------------===//
// Specific properties of annotated_ptr
//===----------------------------------------------------------------------===//
struct alignment_key {
template <int K>
using value_t = property_value<alignment_key, std::integral_constant<int, K>>;
};

template <int K> inline constexpr alignment_key::value_t<K> alignment;

template <typename T, int W>
struct is_valid_property<T, alignment_key::value_t<W>>
: std::bool_constant<std::is_pointer<T>::value> {};

template <> struct is_property_key<alignment_key> : std::true_type {};

template <typename T, typename PropertyListT>
struct is_property_key_of<alignment_key, annotated_ptr<T, PropertyListT>>
: std::true_type {};

namespace detail {

template <> struct PropertyToKind<alignment_key> {
static constexpr PropKind Kind = PropKind::Alignment;
};

template <> struct IsCompileTimeProperty<alignment_key> : std::true_type {};

template <int N> struct PropertyMetaInfo<alignment_key::value_t<N>> {
static constexpr const char *name = "sycl-alignment";
static constexpr int value = N;
};

} // namespace detail

//===----------------------------------------------------------------------===//
// Utility type trait for annotated_arg/annotated_ptr deduction guide
// Utility for FPGA properties
//===----------------------------------------------------------------------===//
//
namespace detail {
// Deduce a `properties<>` type from given variadic properties
template <typename... Args> struct DeducedProperties {
using type = decltype(properties{std::declval<Args>()...});
};

// Partial specialization for deducing a `properties<>` type by forwarding the
// given `properties<>` type
template <typename... Args>
struct DeducedProperties<detail::properties_t<Args...>> {
using type = detail::properties_t<Args...>;
};

template <typename... Args> struct checkValidFPGAPropertySet {
using list = std::tuple<Args...>;
static constexpr bool has_BufferLocation =
Expand Down
4 changes: 4 additions & 0 deletions sycl/include/sycl/ext/intel/fpga_extensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
//===----------------------------------------------------------------------===//

#pragma once
#include <sycl/detail/defines_elementary.hpp>
#include <sycl/detail/stl_type_traits.hpp>
#include <sycl/ext/intel/experimental/fpga_annotated_properties.hpp>
#include <sycl/ext/intel/experimental/fpga_kernel_properties.hpp>
#include <sycl/ext/intel/experimental/fpga_lsu.hpp>
#include <sycl/ext/intel/experimental/pipes.hpp>
#include <sycl/ext/intel/fpga_device_selector.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

#include <sycl/detail/stl_type_traits.hpp>
#include <sycl/exception.hpp>
#include <sycl/ext/oneapi/annotated_arg/properties.hpp>
#include <sycl/ext/intel/experimental/fpga_annotated_properties.hpp>
#include <sycl/ext/oneapi/experimental/common_annotated_properties/properties.hpp>
#include <sycl/ext/oneapi/properties/properties.hpp>

namespace sycl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

#include <sycl/detail/stl_type_traits.hpp>
#include <sycl/exception.hpp>
#include <sycl/ext/oneapi/annotated_arg/properties.hpp>
#include <sycl/ext/intel/experimental/fpga_annotated_properties.hpp>
#include <sycl/ext/oneapi/experimental/common_annotated_properties/properties.hpp>
#include <sycl/ext/oneapi/properties/properties.hpp>

namespace sycl {
Expand All @@ -22,6 +23,41 @@ namespace ext {
namespace oneapi {
namespace experimental {

//===----------------------------------------------------------------------===//
// Specific properties of annotated_ptr
//===----------------------------------------------------------------------===//
struct alignment_key {
template <int K>
using value_t = property_value<alignment_key, std::integral_constant<int, K>>;
};

template <int K> inline constexpr alignment_key::value_t<K> alignment;

template <> struct is_property_key<alignment_key> : std::true_type {};

template <typename T, int W>
struct is_valid_property<T, alignment_key::value_t<W>>
: std::bool_constant<std::is_pointer<T>::value> {};

template <typename T, typename PropertyListT>
struct is_property_key_of<alignment_key, annotated_ptr<T, PropertyListT>>
: std::true_type {};

namespace detail {

template <> struct PropertyToKind<alignment_key> {
static constexpr PropKind Kind = PropKind::Alignment;
};

template <> struct IsCompileTimeProperty<alignment_key> : std::true_type {};

template <int N> struct PropertyMetaInfo<alignment_key::value_t<N>> {
static constexpr const char *name = "sycl-alignment";
static constexpr int value = N;
};

} // namespace detail

namespace {
#define PROPAGATE_OP(op) \
annotated_ref operator op(const T &rhs) { \
Expand Down Expand Up @@ -135,7 +171,8 @@ __SYCL_TYPE(annotated_ptr) annotated_ptr<T, detail::properties_t<Props...>> {

// buffer_location and alignment are allowed for annotated_ref
using allowed_properties =
std::tuple<decltype(buffer_location<0>), decltype(alignment<0>)>;
std::tuple<decltype(ext::intel::experimental::buffer_location<0>),
decltype(ext::oneapi::experimental::alignment<0>)>;
using filtered_properties =
typename PropertiesFilter<allowed_properties, Props...>::tuple;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//==-- properties.hpp - SYCL properties associated with
// annotated_arg/ptr --==//
//
// 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/ext/oneapi/properties/properties.hpp>
#include <sycl/ext/oneapi/properties/property.hpp>
#include <sycl/ext/oneapi/properties/property_value.hpp>

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace ext {
namespace oneapi {
namespace experimental {

template <typename T, typename PropertyListT> class annotated_arg;
template <typename T, typename PropertyListT> class annotated_ptr;

//===----------------------------------------------------------------------===//
// Common properties of annotated_arg/annotated_ptr
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
// Utility type trait for annotated_arg/annotated_ptr deduction guide
//===----------------------------------------------------------------------===//
template <typename T, typename PropertyValueT>
struct is_valid_property : std::false_type {};

namespace detail {
// Deduce a `properties<>` type from given variadic properties
template <typename... Args> struct DeducedProperties {
using type = decltype(properties{std::declval<Args>()...});
};

// Partial specialization for deducing a `properties<>` type by forwarding the
// given `properties<>` type
template <typename... Args>
struct DeducedProperties<detail::properties_t<Args...>> {
using type = detail::properties_t<Args...>;
};
} // namespace detail

template <typename T, typename... Props>
struct check_property_list : std::true_type {};

template <typename T, typename Prop, typename... Props>
struct check_property_list<T, Prop, Props...>
: std::conditional_t<is_valid_property<T, Prop>::value,
check_property_list<T, Props...>, std::false_type> {
static_assert(is_valid_property<T, Prop>::value,
"Property is invalid for the given type.");
};

} // namespace experimental
} // namespace oneapi
} // namespace ext
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl
5 changes: 2 additions & 3 deletions sycl/include/sycl/sycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@
#include <sycl/ext/intel/experimental/pipe_properties.hpp>
#include <sycl/ext/intel/experimental/pipes.hpp>
#include <sycl/ext/intel/usm_pointers.hpp>
#include <sycl/ext/oneapi/annotated_arg/annotated_arg.hpp>
#include <sycl/ext/oneapi/annotated_arg/annotated_ptr.hpp>
#include <sycl/ext/oneapi/annotated_arg/properties.hpp>
#include <sycl/ext/oneapi/device_global/device_global.hpp>
#include <sycl/ext/oneapi/device_global/properties.hpp>
#include <sycl/ext/oneapi/experimental/annotated_arg/annotated_arg.hpp>
#include <sycl/ext/oneapi/experimental/annotated_ptr/annotated_ptr.hpp>
#include <sycl/ext/oneapi/experimental/ballot_group.hpp>
#include <sycl/ext/oneapi/experimental/bfloat16_math.hpp>
#include <sycl/ext/oneapi/experimental/builtins.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

using namespace sycl;
using namespace ext::oneapi::experimental;
using namespace ext::intel::experimental;

struct B {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

using namespace sycl;
using namespace ext::oneapi::experimental;
using namespace ext::intel::experimental;

using annotated_arg_t1 =
annotated_arg<int *, decltype(properties(awidth<32>, dwidth<32>))>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s
// expected-no-diagnostics

#include <sycl/sycl.hpp>
#include "sycl/sycl.hpp"
#include <sycl/ext/intel/fpga_extensions.hpp>

using namespace sycl::ext::oneapi::experimental;
using namespace sycl::ext::intel::experimental;

static annotated_arg<int, decltype(properties())> AnnotatedArg1;
static annotated_arg<int, decltype(properties(register_map))> AnnotatedArg2;
Expand Down
1 change: 1 addition & 0 deletions sycl/test/extensions/annotated_arg/annotated_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

using namespace sycl;
using namespace ext::oneapi::experimental;
using namespace ext::intel::experimental;

using annotated_ptr_t1 =
annotated_ptr<int, decltype(properties(buffer_location<0>, awidth<32>,
Expand Down