Skip to content

Commit

Permalink
Address formatting violations due to transition from clang-format 11 …
Browse files Browse the repository at this point in the history
…to 18
  • Loading branch information
oleksandr-pavlyk committed Jul 31, 2024
1 parent 521d141 commit b37657e
Show file tree
Hide file tree
Showing 103 changed files with 541 additions and 560 deletions.
20 changes: 4 additions & 16 deletions dpctl/apis/include/dpctl4pybind11.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,10 @@ class dpctl_capi
return api;
}

py::object default_sycl_queue_pyobj()
{
return *default_sycl_queue_;
}
py::object default_usm_memory_pyobj()
{
return *default_usm_memory_;
}
py::object default_usm_ndarray_pyobj()
{
return *default_usm_ndarray_;
}
py::object as_usm_memory_pyobj()
{
return *as_usm_memory_;
}
py::object default_sycl_queue_pyobj() { return *default_sycl_queue_; }
py::object default_usm_memory_pyobj() { return *default_usm_memory_; }
py::object default_usm_ndarray_pyobj() { return *default_usm_ndarray_; }
py::object as_usm_memory_pyobj() { return *as_usm_memory_; }

private:
struct Deleter
Expand Down
51 changes: 13 additions & 38 deletions dpctl/tensor/libtensor/include/kernels/accumulators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ namespace accumulators

using namespace dpctl::tensor::offset_utils;

template <typename T> T ceiling_quotient(T n, T m)
{
return (n + m - 1) / m;
}
template <typename T> T ceiling_quotient(T n, T m) { return (n + m - 1) / m; }

template <typename inputT, typename outputT> struct NonZeroIndicator
{
Expand All @@ -70,10 +67,7 @@ template <typename T> struct NoOpTransformer
{
constexpr NoOpTransformer() {}

T operator()(const T &val) const
{
return val;
}
T operator()(const T &val) const { return val; }
};

template <typename srcTy, typename dstTy> struct CastTransformer
Expand Down Expand Up @@ -108,20 +102,11 @@ template <typename T> class stack_t
}
~stack_t(){};

T *get_src_ptr() const
{
return src_;
}
T *get_src_ptr() const { return src_; }

size_t get_size() const
{
return size_;
}
size_t get_size() const { return size_; }

T *get_local_scans_ptr() const
{
return local_scans_;
}
T *get_local_scans_ptr() const { return local_scans_; }
};

template <typename T> class stack_strided_t
Expand All @@ -140,25 +125,13 @@ template <typename T> class stack_strided_t
}
~stack_strided_t(){};

T *get_src_ptr() const
{
return src_;
}
T *get_src_ptr() const { return src_; }

size_t get_size() const
{
return size_;
}
size_t get_size() const { return size_; }

T *get_local_scans_ptr() const
{
return local_scans_;
}
T *get_local_scans_ptr() const { return local_scans_; }

size_t get_local_stride() const
{
return local_stride_;
}
size_t get_local_stride() const { return local_stride_; }
};

} // end of anonymous namespace
Expand Down Expand Up @@ -283,7 +256,8 @@ inclusive_scan_base_step(sycl::queue &exec_q,

outputT wg_iscan_val;
if constexpr (can_use_inclusive_scan_over_group<ScanOpT,
outputT>::value) {
outputT>::value)
{
wg_iscan_val = sycl::inclusive_scan_over_group(
it.get_group(), local_iscan.back(), scan_op, identity);
}
Expand All @@ -305,7 +279,8 @@ inclusive_scan_base_step(sycl::queue &exec_q,
}

for (nwiT m_wi = 0; (m_wi < n_wi) && (i + m_wi < acc_nelems);
++m_wi) {
++m_wi)
{
output[out_iter_offset + out_indexer(i + m_wi)] =
local_iscan[m_wi];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,28 +573,27 @@ sycl::event non_zero_indexes_impl(sycl::queue &exec_q,
sycl::event comp_ev = exec_q.submit([&](sycl::handler &cgh) {
cgh.depends_on(depends);
cgh.parallel_for<class non_zero_indexes_krn<indT1, indT2>>(
sycl::range<1>(iter_size), [=](sycl::id<1> idx)
{
auto i = idx[0];

auto cs_curr_val = cumsum_data[i] - 1;
auto cs_prev_val = (i > 0) ? cumsum_data[i - 1] : indT1(0);
bool cond = (cs_curr_val == cs_prev_val);

ssize_t i_ = static_cast<ssize_t>(i);
for (int dim = nd; --dim > 0;) {
auto sd = mask_shape[dim];
ssize_t q = i_ / sd;
ssize_t r = (i_ - q * sd);
sycl::range<1>(iter_size), [=](sycl::id<1> idx) {
auto i = idx[0];

auto cs_curr_val = cumsum_data[i] - 1;
auto cs_prev_val = (i > 0) ? cumsum_data[i - 1] : indT1(0);
bool cond = (cs_curr_val == cs_prev_val);

ssize_t i_ = static_cast<ssize_t>(i);
for (int dim = nd; --dim > 0;) {
auto sd = mask_shape[dim];
ssize_t q = i_ / sd;
ssize_t r = (i_ - q * sd);
if (cond) {
indexes_data[cs_curr_val + dim * nz_elems] =
static_cast<indT2>(r);
}
i_ = q;
}
if (cond) {
indexes_data[cs_curr_val + dim * nz_elems] =
static_cast<indT2>(r);
indexes_data[cs_curr_val] = static_cast<indT2>(i_);
}
i_ = q;
}
if (cond) {
indexes_data[cs_curr_val] = static_cast<indT2>(i_);
}
});
});

Expand Down
9 changes: 6 additions & 3 deletions dpctl/tensor/libtensor/include/kernels/clip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ template <typename T> T clip(const T &x, const T &min, const T &max)
return min_complex(max_complex(x, min), max);
}
else if constexpr (std::is_floating_point_v<T> ||
std::is_same_v<T, sycl::half>) {
std::is_same_v<T, sycl::half>)
{
auto tmp = (std::isnan(x) || x > min) ? x : min;
return (std::isnan(tmp) || tmp < max) ? tmp : max;
}
Expand Down Expand Up @@ -121,7 +122,8 @@ class ClipContigFunctor
sg.get_group_id()[0] * max_sgSize);

if (base + n_vecs * vec_sz * sgSize < nelems &&
sgSize == max_sgSize) {
sgSize == max_sgSize)
{
sycl::vec<T, vec_sz> x_vec;
sycl::vec<T, vec_sz> min_vec;
sycl::vec<T, vec_sz> max_vec;
Expand Down Expand Up @@ -155,7 +157,8 @@ class ClipContigFunctor
}
else {
for (size_t k = base + sg.get_local_id()[0]; k < nelems;
k += sgSize) {
k += sgSize)
{
dst_p[k] = clip(x_p[k], min_p[k], max_p[k]);
}
}
Expand Down
16 changes: 6 additions & 10 deletions dpctl/tensor/libtensor/include/kernels/copy_and_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ class ContigCopyFunctor
sg.get_group_id()[0] * max_sgSize);

if (base + n_vecs * vec_sz * sgSize < nelems &&
sgSize == max_sgSize) {
sgSize == max_sgSize)
{
sycl::vec<srcT, vec_sz> src_vec;
sycl::vec<dstT, vec_sz> dst_vec;

Expand All @@ -273,7 +274,8 @@ class ContigCopyFunctor
}
else {
for (size_t k = base + sg.get_local_id()[0]; k < nelems;
k += sgSize) {
k += sgSize)
{
dst_p[k] = fn(src_p[k]);
}
}
Expand Down Expand Up @@ -803,10 +805,7 @@ template <typename IndexerT, typename TransformerT> struct CompositionIndexer
{
CompositionIndexer(IndexerT f, TransformerT t) : f_(f), t_(t) {}

auto operator()(size_t gid) const
{
return f_(t_(gid));
}
auto operator()(size_t gid) const { return f_(t_(gid)); }

private:
IndexerT f_;
Expand All @@ -827,10 +826,7 @@ struct RolledNDIndexer
{
}

ssize_t operator()(size_t gid) const
{
return compute_offset(gid);
}
ssize_t operator()(size_t gid) const { return compute_offset(gid); }

private:
int nd_ = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ template <typename fnT, typename T> struct AbsContigFactory
fnT get()
{
if constexpr (std::is_same_v<typename AbsOutputType<T>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down Expand Up @@ -191,7 +192,8 @@ template <typename fnT, typename T> struct AbsStridedFactory
fnT get()
{
if constexpr (std::is_same_v<typename AbsOutputType<T>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ template <typename fnT, typename T> struct AcosContigFactory
fnT get()
{
if constexpr (std::is_same_v<typename AcosOutputType<T>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down Expand Up @@ -222,7 +223,8 @@ template <typename fnT, typename T> struct AcosStridedFactory
fnT get()
{
if constexpr (std::is_same_v<typename AcosOutputType<T>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ template <typename fnT, typename T> struct AcoshContigFactory
fnT get()
{
if constexpr (std::is_same_v<typename AcoshOutputType<T>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down Expand Up @@ -249,7 +250,8 @@ template <typename fnT, typename T> struct AcoshStridedFactory
fnT get()
{
if constexpr (std::is_same_v<typename AcoshOutputType<T>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ template <typename argT1, typename argT2, typename resT> struct AddFunctor
{
auto tmp = in1 + in2;
if constexpr (std::is_same_v<resT,
typename decltype(tmp)::element_type>) {
typename decltype(tmp)::element_type>)
{
return tmp;
}
else {
Expand Down Expand Up @@ -223,7 +224,8 @@ template <typename fnT, typename T1, typename T2> struct AddContigFactory
fnT get()
{
if constexpr (std::is_same_v<typename AddOutputType<T1, T2>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down Expand Up @@ -272,7 +274,8 @@ template <typename fnT, typename T1, typename T2> struct AddStridedFactory
fnT get()
{
if constexpr (std::is_same_v<typename AddOutputType<T1, T2>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down Expand Up @@ -398,10 +401,7 @@ template <typename argT, typename resT> struct AddInplaceFunctor
using supports_vec = std::negation<
std::disjunction<tu_ns::is_complex<argT>, tu_ns::is_complex<resT>>>;

void operator()(resT &res, const argT &in)
{
res += in;
}
void operator()(resT &res, const argT &in) { res += in; }

template <int vec_sz>
void operator()(sycl::vec<resT, vec_sz> &res,
Expand Down Expand Up @@ -458,7 +458,8 @@ template <typename fnT, typename T1, typename T2> struct AddInplaceContigFactory
fnT get()
{
if constexpr (std::is_same_v<typename AddOutputType<T1, T2>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down Expand Up @@ -497,7 +498,8 @@ struct AddInplaceStridedFactory
fnT get()
{
if constexpr (std::is_same_v<typename AddOutputType<T1, T2>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ template <typename fnT, typename T> struct AngleContigFactory
fnT get()
{
if constexpr (std::is_same_v<typename AngleOutputType<T>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down Expand Up @@ -165,7 +166,8 @@ template <typename fnT, typename T> struct AngleStridedFactory
fnT get()
{
if constexpr (std::is_same_v<typename AngleOutputType<T>::value_type,
void>) {
void>)
{
fnT fn = nullptr;
return fn;
}
Expand Down
Loading

0 comments on commit b37657e

Please sign in to comment.