Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Replace use of anonymous namespace in headers
Using anonymous namespace in headers is against best C++ practices
due to internal linkage of entities in that namespace.
  • Loading branch information
oleksandr-pavlyk committed Jan 8, 2025
commit 87052e2a74a7265522e7216d14c1d0e0d0b67ac2
8 changes: 4 additions & 4 deletions dpctl/tensor/libtensor/include/kernels/accumulators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ template <typename BinOpT, typename T> struct can_use_inclusive_scan_over_group
static constexpr bool value = sycl::has_known_identity<BinOpT, T>::value;
};

namespace
namespace detail
{
template <typename T> class stack_t
{
Expand Down Expand Up @@ -141,7 +141,7 @@ template <typename T> class stack_strided_t
std::size_t get_local_stride() const { return local_stride_; }
};

} // end of anonymous namespace
} // end of namespace detail

// Iterative cumulative summation

Expand Down Expand Up @@ -627,7 +627,7 @@ sycl::event inclusive_scan_iter_1d(sycl::queue &exec_q,
throw std::bad_alloc();
}

std::vector<stack_t<outputT>> stack{};
std::vector<detail::stack_t<outputT>> stack{};

// inclusive scans over blocks
n_groups_ = n_groups;
Expand Down Expand Up @@ -867,7 +867,7 @@ sycl::event inclusive_scan_iter(sycl::queue &exec_q,
throw std::bad_alloc();
}

std::vector<stack_strided_t<outputT>> stack{};
std::vector<detail::stack_strided_t<outputT>> stack{};

// inclusive scans over blocks
acc_groups_ = acc_groups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ struct MaskedPlaceStridedFunctor

// ======= Masked extraction ================================

namespace
namespace detail
{

template <std::size_t I, std::size_t... IR>
Expand All @@ -234,7 +234,7 @@ std::size_t get_lws(std::size_t n)
return _get_lws_impl<lws0, lws1, lws2>(n);
}

} // end of anonymous namespace
} // end of namespace detail

template <typename MaskedDstIndexerT, typename dataT, typename indT>
class masked_extract_all_slices_contig_impl_krn;
Expand Down Expand Up @@ -278,7 +278,7 @@ sycl::event masked_extract_all_slices_contig_impl(

const std::size_t masked_extent = iteration_size;

const std::size_t lws = get_lws(masked_extent);
const std::size_t lws = detail::get_lws(masked_extent);

const std::size_t n_groups = (iteration_size + lws - 1) / lws;

Expand Down Expand Up @@ -357,7 +357,7 @@ sycl::event masked_extract_all_slices_strided_impl(

const std::size_t masked_nelems = iteration_size;

const std::size_t lws = get_lws(masked_nelems);
const std::size_t lws = detail::get_lws(masked_nelems);

const std::size_t n_groups = (masked_nelems + lws - 1) / lws;

Expand Down Expand Up @@ -452,7 +452,7 @@ sycl::event masked_extract_some_slices_strided_impl(

const std::size_t masked_extent = masked_nelems;

const std::size_t lws = get_lws(masked_extent);
const std::size_t lws = detail::get_lws(masked_extent);

const std::size_t n_groups = ((masked_extent + lws - 1) / lws);
const std::size_t orthog_extent = static_cast<std::size_t>(orthog_nelems);
Expand Down
6 changes: 3 additions & 3 deletions dpctl/tensor/libtensor/include/utils/sycl_alloc_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ smart_malloc_host(std::size_t count,
return smart_malloc<T>(count, q, sycl::usm::alloc::host, propList);
}

namespace
namespace detail
{
template <typename T> struct valid_smart_ptr : public std::false_type
{
Expand Down Expand Up @@ -172,7 +172,7 @@ struct all_valid_smart_ptrs<Arg, RestArgs...>
static constexpr bool value = valid_smart_ptr<Arg>::value &&
(all_valid_smart_ptrs<RestArgs...>::value);
};
} // namespace
} // end of namespace detail

template <typename... Args>
sycl::event async_smart_free(sycl::queue &exec_q,
Expand All @@ -184,7 +184,7 @@ sycl::event async_smart_free(sycl::queue &exec_q,
n > 0, "async_smart_free requires at least one smart pointer argument");

static_assert(
all_valid_smart_ptrs<Args...>::value,
detail::all_valid_smart_ptrs<Args...>::value,
"async_smart_free requires unique_ptr created with smart_malloc");

std::vector<void *> ptrs;
Expand Down
9 changes: 5 additions & 4 deletions dpctl/tensor/libtensor/include/utils/sycl_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ std::size_t choose_workgroup_size(const std::size_t nelems,
return wg;
}

namespace
namespace detail
{

template <typename LocAccT, typename OpT>
Expand All @@ -158,7 +158,7 @@ void _fold(LocAccT &local_mem_acc,
}
}

} // namespace
} // end of namespace detail

template <typename T, typename GroupT, typename LocAccT, typename OpT>
T custom_reduce_over_group(const GroupT &wg,
Expand All @@ -184,7 +184,8 @@ T custom_reduce_over_group(const GroupT &wg,
for (std::uint32_t sz = high_sz; sz >= low_sz; sz >>= 1) {
if (n_witems >= sz) {
const std::uint32_t n_witems_ = (n_witems + 1) >> 1;
_fold(local_mem_acc, lid, n_witems - n_witems_, n_witems_, op);
detail::_fold(local_mem_acc, lid, n_witems - n_witems_,
n_witems_, op);
sycl::group_barrier(wg, sycl::memory_scope::work_group);
n_witems = n_witems_;
}
Expand All @@ -196,7 +197,7 @@ T custom_reduce_over_group(const GroupT &wg,
for (std::uint32_t sz = high_sz; sz >= low_sz; sz >>= 1) {
if (n_witems >= sz) {
n_witems >>= 1;
_fold(local_mem_acc, lid, n_witems, op);
detail::_fold(local_mem_acc, lid, n_witems, op);
sycl::group_barrier(wg, sycl::memory_scope::work_group);
}
}
Expand Down