Skip to content

Update clang-format version used #1775

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 3 commits into from
Jul 31, 2024
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
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@

# Linter changes
084ba59ce87efb55e09fff6ae33665d0f14f22b5

# Transition from clang-format 11 to clang-format 18
b37657e6ad9af16eaec2982d8e2397acd2af2881
14 changes: 12 additions & 2 deletions .github/workflows/cpp_style_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@ jobs:
- name: Run clang-format style check for C/C++ programs.
uses: jidicula/clang-format-action@v4.13.0
with:
clang-format-version: '11'
clang-format-version: '18'
check-path: 'libsyclinterface'
- name: Run clang-format style check for api headers.
uses: jidicula/clang-format-action@v4.13.0
with:
clang-format-version: '11'
clang-format-version: '18'
check-path: 'dpctl/apis'
- name: Run clang-format style check for libtensor/source.
uses: jidicula/clang-format-action@v4.13.0
with:
clang-format-version: '18'
check-path: 'dpctl/tensor/libtensor/source'
- name: Run clang-format style check for libtensor/include.
uses: jidicula/clang-format-action@v4.13.0
with:
clang-format-version: '18'
check-path: 'dpctl/tensor/libtensor/include'
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ permissions: read-all

jobs:
pre-commit:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4.1.7
- uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'
- name: Version of clang-format
run: |
clang-format --version
Expand Down
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
Loading
Loading