diff --git a/include/vikunja/access/BaseStrategy.hpp b/include/vikunja/access/BaseStrategy.hpp index e8313eb..e020024 100644 --- a/include/vikunja/access/BaseStrategy.hpp +++ b/include/vikunja/access/BaseStrategy.hpp @@ -28,7 +28,7 @@ namespace vikunja::MemAccess //! Constructor. //! //! \param index The index. - //! \param maximum The first index outside of the iterator memory. + //! \param maximum value of the index (not inclusive). ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE BaseStrategy(TIdx const index, TIdx const maximum) : m_index(index) , m_maximum(maximum) @@ -37,34 +37,46 @@ namespace vikunja::MemAccess ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE BaseStrategy(const BaseStrategy& other) = default; - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator==(const BaseStrategy& other) const -> bool + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr friend auto operator==( + BaseStrategy const& st, + const BaseStrategy& other) -> bool { - return (this->m_index == other.m_index) && (this->m_maximum == other.m_maximum); + return (st.m_index == other.m_index) && (st.m_maximum == other.m_maximum); } - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator!=(const BaseStrategy& other) const -> bool + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr friend auto operator!=( + BaseStrategy const& st, + const BaseStrategy& other) -> bool { - return !operator==(other); + return !operator==(st, other); } - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator<(const BaseStrategy& other) const -> bool + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr friend auto operator<( + BaseStrategy const& st, + const BaseStrategy& other) -> bool { - return m_index < other.m_index; + return st.m_index < other.m_index; } - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator>(const BaseStrategy& other) const -> bool + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr friend auto operator>( + BaseStrategy const& st, + const BaseStrategy& other) -> bool { - return m_index > other.m_index; + return st.m_index > other.m_index; } - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator<=(const BaseStrategy& other) const -> bool + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr friend auto operator<=( + BaseStrategy const& st, + const BaseStrategy& other) -> bool { - return m_index <= other.m_index; + return st.m_index <= other.m_index; } - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator>=(const BaseStrategy& other) const -> bool + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr friend auto operator>=( + BaseStrategy const& st, + const BaseStrategy& other) -> bool { - return m_index >= other.m_index; + return st.m_index >= other.m_index; } //----------------------------------------------------------------------------- diff --git a/include/vikunja/access/PolicyBasedBlockStrategy.hpp b/include/vikunja/access/BlockStrategy.hpp similarity index 82% rename from include/vikunja/access/PolicyBasedBlockStrategy.hpp rename to include/vikunja/access/BlockStrategy.hpp index eff6efb..a94494d 100644 --- a/include/vikunja/access/PolicyBasedBlockStrategy.hpp +++ b/include/vikunja/access/BlockStrategy.hpp @@ -17,29 +17,29 @@ namespace vikunja::MemAccess { /** * A policy based memory access strategy that splits the data access into chunks. Depending on the memory access - * policy, these chunks can access the data sequential or in a striding pattern. + * policy, these chunks can access the data sequentially or in a striding pattern. * @tparam MemAccessPolicy The memory access policy to use. * @tparam TAcc The alpaka accelerator type. * @tparam TIdx The index type * * The memory access policy should provide three values: - * - The startIndex of the iterator, which is the first index to use. - * - The endIndex of the iterator, which is the last index to use. - * - The stepSize of the iterator, which tells how far the iterator should move. + * - The startIndex which is the first index to use. + * - The endIndex which is the last index to use. + * - The stepSize which specifies how large the distance is between an index position and its successor. */ template - class PolicyBasedBlockStrategy : public BaseStrategy + class BlockStrategy : public BaseStrategy { private: - TIdx m_step; /**< The step size of this iterator. */ + TIdx m_step; /**< The step size of this strategy. */ public: /** - * Create a policy based block iterator + * Create a policy based block strategy accessor * @param acc The accelerator type to use. - * @param problemSize The size of the original iterator. + * @param problemSize The size of the original strategy. * @param blockSize The size of the blocks. */ - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE PolicyBasedBlockStrategy(TAcc const& acc, TIdx problemSize, TIdx blockSize) + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE BlockStrategy(TAcc const& acc, TIdx problemSize, TIdx blockSize) : BaseStrategy( MemAccessPolicy::getStartIndex(acc, problemSize, blockSize), MemAccessPolicy::getEndIndex(acc, problemSize, blockSize)) @@ -47,13 +47,13 @@ namespace vikunja::MemAccess { } - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE PolicyBasedBlockStrategy(const PolicyBasedBlockStrategy& other) = default; + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE BlockStrategy(const BlockStrategy& other) = default; //----------------------------------------------------------------------------- //! Returns a memory access object with the index set to the last item. - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto end() const -> PolicyBasedBlockStrategy + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto end() const -> BlockStrategy { - PolicyBasedBlockStrategy ret(*this); + BlockStrategy ret(*this); ret.m_index = this->m_maximum; return ret; } @@ -62,7 +62,7 @@ namespace vikunja::MemAccess //! Increments the internal index to the next one. //! //! Returns a reference to the next index. - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator++() -> PolicyBasedBlockStrategy& + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator++() -> BlockStrategy& { this->m_index += this->m_step; return *this; @@ -73,7 +73,7 @@ namespace vikunja::MemAccess //! next one. //! //! Returns a reference to the current index. - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator++(int) -> PolicyBasedBlockStrategy + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator++(int) -> BlockStrategy { auto ret(*this); this->m_index += this->m_step; @@ -85,7 +85,7 @@ namespace vikunja::MemAccess //! element. //! //! Returns a reference to the previous index. - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator--() -> PolicyBasedBlockStrategy& + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator--() -> BlockStrategy& { this->m_index -= this->m_step; return *this; @@ -96,7 +96,7 @@ namespace vikunja::MemAccess //! previous one. //! //! Returns a reference to the current index. - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator--(int) -> PolicyBasedBlockStrategy + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator--(int) -> BlockStrategy { auto ret(*this); this->m_index -= this->m_step; @@ -107,7 +107,7 @@ namespace vikunja::MemAccess //! Returns the index + a supplied offset. //! //! \param n The offset. - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator+(uint64_t n) const -> PolicyBasedBlockStrategy + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator+(uint64_t n) const -> BlockStrategy { auto ret(*this); ret.m_index += n * m_step; @@ -118,7 +118,7 @@ namespace vikunja::MemAccess //! Returns the index - a supplied offset. //! //! \param n The offset. - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator-(uint64_t n) const -> PolicyBasedBlockStrategy + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator-(uint64_t n) const -> BlockStrategy { auto ret(*this); ret.m_index -= n * m_step; @@ -131,7 +131,7 @@ namespace vikunja::MemAccess //! \param offset The offset. //! //! Returns the current object offset by the offset. - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator+=(uint64_t offset) -> PolicyBasedBlockStrategy& + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator+=(uint64_t offset) -> BlockStrategy& { this->m_index += offset * this->m_step; return *this; @@ -143,7 +143,7 @@ namespace vikunja::MemAccess //! \param offset The offset. //! //! Returns the current object offset by the offset. - ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator-=(uint64_t offset) -> PolicyBasedBlockStrategy& + ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator-=(uint64_t offset) -> BlockStrategy& { this->m_index -= offset * this->m_step; return *this; @@ -153,15 +153,15 @@ namespace vikunja::MemAccess namespace policies { /** - * A memory policy for the PolicyBlockBasedIterator that provides grid striding memory access. + * A memory policy for the BlockStrategy that provides grid striding memory access. */ struct GridStridingMemAccessPolicy { template ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static auto getStartIndex( TAcc const& acc, - TIdx const& problemSize __attribute__((unused)), - TIdx const& blockSize __attribute__((unused))) -> TIdx const + TIdx const& /* problemSize */, + TIdx const& /* blockSize */) -> TIdx const { constexpr TIdx xIndex = alpaka::Dim::value - 1u; return alpaka::getIdx(acc)[xIndex]; @@ -171,7 +171,7 @@ namespace vikunja::MemAccess ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static auto getEndIndex( TAcc const& acc, TIdx const& problemSize, - TIdx const& blockSize __attribute__((unused))) -> TIdx const + TIdx const& /* blockSize */) -> TIdx const { return problemSize; } @@ -179,7 +179,7 @@ namespace vikunja::MemAccess template ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static auto getStepSize( TAcc const& acc, - TIdx const& problemSize __attribute__((unused)), + TIdx const& /* problemSize */, TIdx const& blockSize) -> TIdx const { constexpr TIdx xIndex = alpaka::Dim::value - 1u; @@ -191,7 +191,7 @@ namespace vikunja::MemAccess ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static auto isValidThreadResult( TAcc const& acc, TIdx const& problemSize, - TIdx const& blockSize __attribute__((unused))) -> bool const + TIdx const& /* blockSize */) -> bool const { constexpr TIdx xIndex = alpaka::Dim::value - 1u; auto threadIndex = (alpaka::getIdx(acc)[xIndex]); @@ -207,7 +207,7 @@ namespace vikunja::MemAccess }; /** - * A memory access policy for the PolicyBlockBasedIterator that provides linear memory access. + * A memory access policy for the BlockStrategy that provides linear memory access. */ struct LinearMemAccessPolicy { @@ -241,18 +241,18 @@ namespace vikunja::MemAccess template ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr auto getStepSize( - TAcc const& acc __attribute__((unused)), - TIdx const& problemSize __attribute__((unused)), - TIdx const& blockSize __attribute__((unused))) -> TIdx const + TAcc const& /* acc */, + TIdx const& /* problemSize */, + TIdx const& /* blockSize */) -> TIdx const { return 1; } template ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE static constexpr auto isValidThreadResult( - TAcc const& acc __attribute__((unused)), - TIdx const& problemSize __attribute__((unused)), - TIdx const& blockSize __attribute__((unused))) -> bool const + TAcc const& /* acc */, + TIdx const& /* problemSize */, + TIdx const& /* blockSize */) -> bool const { return true; } diff --git a/include/vikunja/reduce/detail/BlockThreadReduceKernel.hpp b/include/vikunja/reduce/detail/BlockThreadReduceKernel.hpp index b17e8cb..d5d9272 100644 --- a/include/vikunja/reduce/detail/BlockThreadReduceKernel.hpp +++ b/include/vikunja/reduce/detail/BlockThreadReduceKernel.hpp @@ -9,7 +9,7 @@ #pragma once -#include +#include #include @@ -104,7 +104,7 @@ namespace vikunja using MemPolicy = TMemAccessPolicy; // Create an iterator with the specified memory access policy that wraps the input iterator. - using MenIndex = vikunja::MemAccess::PolicyBasedBlockStrategy; + using MenIndex = vikunja::MemAccess::BlockStrategy; MenIndex iter(acc, n, TBlockSize); MenIndex end = iter.end(); diff --git a/include/vikunja/reduce/reduce.hpp b/include/vikunja/reduce/reduce.hpp index 6537116..dca4d74 100644 --- a/include/vikunja/reduce/reduce.hpp +++ b/include/vikunja/reduce/reduce.hpp @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include #include diff --git a/include/vikunja/transform/detail/BlockThreadTransformKernel.hpp b/include/vikunja/transform/detail/BlockThreadTransformKernel.hpp index 16091e7..ff1d527 100644 --- a/include/vikunja/transform/detail/BlockThreadTransformKernel.hpp +++ b/include/vikunja/transform/detail/BlockThreadTransformKernel.hpp @@ -9,7 +9,7 @@ #pragma once -#include +#include #include @@ -41,7 +41,7 @@ namespace vikunja TIdx const& n, TFunc const& func) const { - using MenIndex = vikunja::MemAccess::PolicyBasedBlockStrategy; + using MenIndex = vikunja::MemAccess::BlockStrategy; for(MenIndex iter(acc, n, TBlockSize), end = iter.end(); iter < end; ++iter) { destination[*iter] = TOperator::run(acc, func, source[*iter]); @@ -63,7 +63,7 @@ namespace vikunja TIdx const& n, TFunc const& func) const { - using MenIndex = vikunja::MemAccess::PolicyBasedBlockStrategy; + using MenIndex = vikunja::MemAccess::BlockStrategy; for(MenIndex iter(acc, n, TBlockSize), end = iter.end(); iter < end; ++iter) { destination[*iter] = TOperator::run(acc, func, source[*iter], sourceSecond[*iter]); diff --git a/include/vikunja/transform/transform.hpp b/include/vikunja/transform/transform.hpp index 2ead173..edbe623 100644 --- a/include/vikunja/transform/transform.hpp +++ b/include/vikunja/transform/transform.hpp @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include #include diff --git a/test/include/vikunja/test/AlpakaSetup.hpp b/test/include/vikunja/test/AlpakaSetup.hpp index d97f645..ec48896 100644 --- a/test/include/vikunja/test/AlpakaSetup.hpp +++ b/test/include/vikunja/test/AlpakaSetup.hpp @@ -52,7 +52,7 @@ namespace vikunja } /** - * @brief Allocate 1D memory on host. + * @brief Allocate 1D memory on the host. * * @tparam TData Type of the memory. * @param size Size of the memory. @@ -66,7 +66,7 @@ namespace vikunja } /** - * @brief Allocate ND memory on host. + * @brief Allocate ND memory on the host. * * @tparam TData Type of the memory. * @tparam TExtentDim alpaka::Vec @@ -80,7 +80,7 @@ namespace vikunja } /** - * @brief Allocate 1D memory on device. + * @brief Allocate 1D memory on the device. * * @tparam TData Type of the memory. * @param size Size of the memory. @@ -94,7 +94,7 @@ namespace vikunja } /** - * @brief Allocate ND memory on device. + * @brief Allocate ND memory on the device. * * @tparam TData Type of the memory. * @tparam TExtentDim alpaka::Vec diff --git a/test/include/vikunja/test/utility.hpp b/test/include/vikunja/test/utility.hpp index b96936c..78d5b11 100644 --- a/test/include/vikunja/test/utility.hpp +++ b/test/include/vikunja/test/utility.hpp @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include diff --git a/test/unit/access/src/BaseStrategy.cpp b/test/unit/access/src/BaseStrategy.cpp index 96da0e7..1135db0 100644 --- a/test/unit/access/src/BaseStrategy.cpp +++ b/test/unit/access/src/BaseStrategy.cpp @@ -8,7 +8,6 @@ */ #include -#include #include