Skip to content

Commit

Permalink
Move dim3 to util.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjj11 committed Jun 25, 2024
1 parent a1efa3c commit 50bc68c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
15 changes: 0 additions & 15 deletions clang/runtime/dpct-rt/include/dpct/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@
#include <type_traits>

namespace dpct {
class dim3 {
public:
unsigned x, y, z;

constexpr dim3(size_t x = 1, size_t y = 1, size_t z = 1) : x(x), y(y), z(z) {}

dim3(const sycl::id<3> &r) : dim3(r[2], r[1], r[0]) {}

operator sycl::range<3>() const { return sycl::range<3>(z, y, x); }
};

inline dim3 operator*(const dim3 &a, const dim3 &b) {
return dim3{a.x * b.x, a.y * b.y, a.z * b.z};
}

namespace detail {
template <typename VecT, class BinaryOperation, class = void>
class vectorized_binary {
Expand Down
14 changes: 14 additions & 0 deletions clang/runtime/dpct-rt/include/dpct/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ T __spirv_GroupNonUniformShuffleUp(__spv::Scope::Flag, T, unsigned) noexcept;
#endif

namespace dpct {
class dim3 {
public:
unsigned x, y, z;

constexpr dim3(size_t x = 1, size_t y = 1, size_t z = 1) : x(x), y(y), z(z) {}

dim3(const sycl::id<3> &r) : dim3(r[2], r[1], r[0]) {}

operator sycl::range<3>() const { return sycl::range<3>(z, y, x); }
};

inline dim3 operator*(const dim3 &a, const dim3 &b) {
return dim3{a.x * b.x, a.y * b.y, a.z * b.z};
}

namespace detail {

Expand Down

0 comments on commit 50bc68c

Please sign in to comment.