Skip to content

Commit

Permalink
Clang-format everything
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterTh committed Dec 13, 2023
1 parent 57211f7 commit af78034
Show file tree
Hide file tree
Showing 41 changed files with 490 additions and 492 deletions.
6 changes: 3 additions & 3 deletions examples/matmul.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

const size_t MAT_SIZE = 128;

template <typename T>
template<typename T>
void set_identity(sycl::queue queue, sycl::buffer<T, 2> mat, bool reverse) {
queue.submit([&](sycl::handler &cgh) {
sycl::accessor dw{mat, cgh, sycl::write_only, sycl::no_init};
Expand All @@ -21,7 +21,7 @@ void set_identity(sycl::queue queue, sycl::buffer<T, 2> mat, bool reverse) {
});
}

template <typename T>
template<typename T>
void multiply(sycl::queue queue, sycl::buffer<T, 2> mat_a, sycl::buffer<T, 2> mat_b, sycl::buffer<T, 2> mat_c) {
queue.submit([&](sycl::handler &cgh) {
sycl::accessor a{mat_a, cgh, sycl::read_only};
Expand Down Expand Up @@ -56,7 +56,7 @@ void multiply(sycl::queue queue, sycl::buffer<T, 2> mat_a, sycl::buffer<T, 2> ma
}

// TODO this should really reduce into a buffer<bool> on the device, but we currently do not support reductions
template <typename T>
template<typename T>
void verify(sycl::queue &queue, sycl::buffer<T, 2> mat_c) {
queue
.submit([&](sycl::handler &cgh) {
Expand Down
2 changes: 1 addition & 1 deletion include/simsycl/detail/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class config {
inline static uint32_t max_sub_group_size = 32;
};

template <typename T>
template<typename T>
class configure_temporarily {
public:
configure_temporarily(T &to_configure, T new_value) : m_to_configure(to_configure) {
Expand Down
4 changes: 2 additions & 2 deletions include/simsycl/detail/coordinate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

namespace simsycl::detail {

template <typename Interface, int Dimensions>
template<typename Interface, int Dimensions>
class coordinate {
public:
constexpr static int dimensions = Dimensions;

coordinate() = default;

template <typename... Values,
template<typename... Values,
typename
= std::enable_if_t<sizeof...(Values) + 1 == Dimensions && (... && std::is_convertible_v<Values, size_t>)>>
constexpr coordinate(const size_t dim_0, const Values... dim_n) : m_values{dim_0, static_cast<size_t>(dim_n)...} {}
Expand Down
38 changes: 19 additions & 19 deletions include/simsycl/detail/group_operation_impl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace simsycl::detail {

template <typename T>
template<typename T>
constexpr auto unspecified = (T)(0xDEADBEEFull);

enum class group_operation_id {
Expand Down Expand Up @@ -48,7 +48,7 @@ struct group_per_operation_data {
virtual ~group_per_operation_data() = default;
};

template <typename T>
template<typename T>
struct group_broadcast_data : group_per_operation_data {
size_t local_linear_id = 0;
std::type_index type = std::type_index(typeid(void));
Expand All @@ -57,7 +57,7 @@ struct group_broadcast_data : group_per_operation_data {
struct group_barrier_data : group_per_operation_data {
sycl::memory_scope fence_scope;
};
template <typename T>
template<typename T>
struct group_joint_bool_op_data : group_per_operation_data {
T *first;
T *last;
Expand All @@ -68,24 +68,24 @@ struct group_bool_data : group_per_operation_data {
std::vector<bool> values;
group_bool_data(size_t num_work_items) : values(num_work_items) {}
};
template <typename T>
template<typename T>
struct group_shift_data : group_per_operation_data {
std::vector<T> values;
size_t delta;
group_shift_data(size_t num_work_items, size_t delta) : values(num_work_items), delta(delta) {}
};
template <typename T>
template<typename T>
struct group_permute_data : group_per_operation_data {
std::vector<T> values;
size_t mask;
group_permute_data(size_t num_work_items, size_t mask) : values(num_work_items), mask(mask) {}
};
template <typename T>
template<typename T>
struct group_select_data : group_per_operation_data {
std::vector<T> values;
group_select_data(size_t num_work_items) : values(num_work_items) {}
};
template <typename T>
template<typename T>
struct group_joint_reduce_data : group_per_operation_data {
T *first;
T *last;
Expand All @@ -94,13 +94,13 @@ struct group_joint_reduce_data : group_per_operation_data {
group_joint_reduce_data(T *first, T *last, std::optional<T> init, T result)
: first(first), last(last), init(init), result(result) {}
};
template <typename T>
template<typename T>
struct group_reduce_data : group_per_operation_data {
std::optional<T> init;
std::vector<T> values;
group_reduce_data(size_t num_work_items, std::optional<T> init) : init(init), values(num_work_items) {}
};
template <typename T>
template<typename T>
struct group_joint_scan_data : group_per_operation_data {
T *first;
T *last;
Expand All @@ -109,7 +109,7 @@ struct group_joint_scan_data : group_per_operation_data {
group_joint_scan_data(T *first, T *last, std::optional<T> init, const std::vector<T> &results)
: first(first), last(last), init(init), results(results) {}
};
template <typename T>
template<typename T>
struct group_scan_data : group_per_operation_data {
std::optional<T> init;
std::vector<T> values;
Expand All @@ -131,7 +131,7 @@ struct group_impl {
std::vector<group_operation_data> operations;
};

template <int Dimensions>
template<int Dimensions>
group_impl &get_group_impl(const sycl::group<Dimensions> &g) {
return *g.m_impl;
}
Expand All @@ -145,19 +145,19 @@ inline detail::sub_group_impl &get_group_impl(const sycl::sub_group &g) { return

// group operation function template

template <typename Func>
template<typename Func>
concept GroupOpInitFunction = std::is_invocable_r_v<std::unique_ptr<group_per_operation_data>, Func>;

inline std::unique_ptr<group_per_operation_data> default_group_op_init_function() {
return std::unique_ptr<group_per_operation_data>();
}

template <typename T>
template<typename T>
void default_group_op_function(T &per_group) {
(void)per_group;
}

template <GroupOpInitFunction InitF = decltype(default_group_op_init_function),
template<GroupOpInitFunction InitF = decltype(default_group_op_init_function),
typename PerOpT = typename std::invoke_result_t<InitF>::element_type,
typename ReachedF = decltype(default_group_op_function<PerOpT>),
typename CompleteF = decltype(default_group_op_function<PerOpT>)>
Expand All @@ -170,7 +170,7 @@ struct group_operation_spec {
const CompleteF &complete = default_group_op_function<PerOpT>;
};

template <sycl::Group G, typename Spec>
template<sycl::Group G, typename Spec>
auto perform_group_operation(G g, group_operation_id id, const Spec &spec) {
auto &group_impl = detail::get_group_impl(g);
const auto linear_id_in_group = g.get_local_linear_id();
Expand Down Expand Up @@ -211,7 +211,7 @@ auto perform_group_operation(G g, group_operation_id id, const Spec &spec) {

// more specific helper functions for group operations

template <sycl::Group G, sycl::Pointer Ptr, sycl::Fundamental T>
template<sycl::Group G, sycl::Pointer Ptr, sycl::Fundamental T>
void joint_reduce_impl(G g, Ptr first, Ptr last, std::optional<T> init, T result) {
perform_group_operation(g, group_operation_id::joint_reduce,
group_operation_spec{//
Expand All @@ -225,7 +225,7 @@ void joint_reduce_impl(G g, Ptr first, Ptr last, std::optional<T> init, T result
}});
}

template <sycl::Group G, sycl::Fundamental T, sycl::SyclFunctionObject Op>
template<sycl::Group G, sycl::Fundamental T, sycl::SyclFunctionObject Op>
T group_reduce_impl(G g, T x, std::optional<T> init, Op op) {
return perform_group_operation(g, group_operation_id::reduce,
group_operation_spec{//
Expand Down Expand Up @@ -254,7 +254,7 @@ T group_reduce_impl(G g, T x, std::optional<T> init, Op op) {
}});
}

template <sycl::Group G, sycl::Pointer Ptr, sycl::Fundamental T>
template<sycl::Group G, sycl::Pointer Ptr, sycl::Fundamental T>
void joint_scan_impl(
G g, group_operation_id op_id, Ptr first, Ptr last, std::optional<T> init, const std::vector<T> &results) {
perform_group_operation(g, op_id,
Expand All @@ -269,7 +269,7 @@ void joint_scan_impl(
}});
}

template <sycl::Group G, sycl::Fundamental T, sycl::SyclFunctionObject Op>
template<sycl::Group G, sycl::Fundamental T, sycl::SyclFunctionObject Op>
T group_scan_impl(G g, group_operation_id op_id, T x, std::optional<T> init, Op op) {
return perform_group_operation(g, op_id,
group_operation_spec{//
Expand Down
6 changes: 4 additions & 2 deletions include/simsycl/detail/hash.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace simsycl::detail {

// Implementation from Boost.ContainerHash, licensed under the Boost Software License, Version 1.0.
inline void hash_combine(std::size_t& seed, std::size_t value) { seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2); }

inline void hash_combine(std::size_t &seed, std::size_t value) {
seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}

} // namespace simsycl::detail
8 changes: 4 additions & 4 deletions include/simsycl/detail/reference_type.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

namespace simsycl::detail {

template <typename Derived, typename State>
template<typename Derived, typename State>
class reference_type;

}

template <typename Derived, typename State>
template<typename Derived, typename State>
struct std::hash<simsycl::detail::reference_type<Derived, State>> {
size_t operator()(const Derived &rt) { return static_cast<size_t>(reinterpret_cast<uintptr_t>(rt.m_state.get())); }
};

namespace simsycl::detail {

template <typename Derived, typename State>
template<typename Derived, typename State>
class reference_type {
public:
friend bool operator==(const Derived &lhs, const Derived &rhs) { return lhs.m_state.get() == rhs.m_state.get(); }
Expand All @@ -27,7 +27,7 @@ class reference_type {

reference_type() = default;

template <typename... CtorParams>
template<typename... CtorParams>
explicit reference_type(std::in_place_t /* tag */, CtorParams &&...ctor_args)
: m_state(std::make_shared<State>(std::forward<CtorParams>(ctor_args)...)) {
static_assert(std::is_base_of_v<reference_type, Derived>);
Expand Down
8 changes: 4 additions & 4 deletions include/simsycl/detail/subscript.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

namespace simsycl::detail {

template <int TargetDimensions, typename Target, int SubscriptDimension = 0>
template<int TargetDimensions, typename Target, int SubscriptDimension = 0>
class subscript_proxy;

template <int TargetDimensions, typename Target, int SubscriptDimension>
template<int TargetDimensions, typename Target, int SubscriptDimension>
inline decltype(auto) subscript(Target &tgt, sycl::id<TargetDimensions> id, const size_t index) {
static_assert(SubscriptDimension < TargetDimensions);
id[SubscriptDimension] = index;
Expand All @@ -20,12 +20,12 @@ inline decltype(auto) subscript(Target &tgt, sycl::id<TargetDimensions> id, cons
}
}

template <int TargetDims, typename Target>
template<int TargetDims, typename Target>
inline decltype(auto) subscript(Target &tgt, const size_t index) {
return subscript<TargetDims, Target, 0>(tgt, sycl::id<TargetDims>{}, index);
}

template <int TargetDimensions, typename Target, int SubscriptDim>
template<int TargetDimensions, typename Target, int SubscriptDim>
class subscript_proxy {
public:
subscript_proxy(Target &tgt, const sycl::id<TargetDimensions> id) : m_tgt(tgt), m_id(id) {}
Expand Down
2 changes: 1 addition & 1 deletion include/simsycl/detail/utils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace simsycl::detail {

template <typename T, typename T2>
template<typename T, typename T2>
auto div_ceil(T a, T2 b) {
return (a + b - 1) / b;
}
Expand Down
2 changes: 1 addition & 1 deletion include/simsycl/sycl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <simsycl/config.hh>

#include "sycl/accessor.hh"
#include "sycl/atomic_ref.hh"
#include "sycl/allocator.hh"
#include "sycl/atomic_ref.hh"
#include "sycl/backend.hh"
#include "sycl/buffer.hh"
#include "sycl/context.hh"
Expand Down
Loading

0 comments on commit af78034

Please sign in to comment.