-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor Memory Access Iterators #75
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
SimeonEhrig
merged 5 commits into
alpaka-group:master
from
SimeonEhrig:refactorMemAccessStrategy
Feb 15, 2022
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f905d91
Rename Iterator to Memory Access Strategy
SimeonEhrig dbc5d3a
Remove data member from the memory access strategy
SimeonEhrig 5b3f091
rename iterator test to MemAccessStrategy test
SimeonEhrig 44bd5db
Rename MemAccessStrategy.cpp to BaseStrategy.cpp
SimeonEhrig f3aaa68
Overwork several thinks in mem access strategy
SimeonEhrig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Copyright 2022 Simeon Ehrig | ||
| # | ||
| # This file is part of vikunja. | ||
| # | ||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
|
||
| # Create an executable file for the test, link it to the required test targets and add it to ctest. | ||
| # | ||
| # vikunja_add_default_test(TARGET <name> | ||
| # SOURCE <list of source files> | ||
| # [INCLUDE <list of include paths>] | ||
| # ) | ||
| # | ||
| # * TARGET: name of the executable, will be prefixed with `test_` | ||
| # * SOURCE: path of the source file(s) | ||
| # * INCLUDE: optional path(s) to include folder(s) | ||
| macro(vikunja_add_default_test) | ||
| set(_MACRO_PREFIX "vikTest") | ||
| set(_SINGLE_ARG TARGET) | ||
| set(_MULTI_ARG SOURCE INCLUDE) | ||
|
|
||
| cmake_parse_arguments( | ||
| "${_MACRO_PREFIX}" | ||
| "" # option | ||
| "${_SINGLE_ARG}" | ||
| "${_MULTI_ARG}" | ||
| "${ARGN}" | ||
| ) | ||
|
|
||
| if(NOT DEFINED ${_MACRO_PREFIX}_TARGET) | ||
| message(FATAL_ERROR "vikunja_add_default_test: no target name defined") | ||
| endif() | ||
|
|
||
| if(NOT DEFINED ${_MACRO_PREFIX}_SOURCE) | ||
| message(FATAL_ERROR "vikunja_add_default_test: no source files defined") | ||
| endif() | ||
|
|
||
| set(_TARGET_NAME "test_${${_MACRO_PREFIX}_TARGET}") | ||
|
|
||
| alpaka_add_executable( | ||
| ${_TARGET_NAME} | ||
| ${${_MACRO_PREFIX}_SOURCE} | ||
| ) | ||
|
|
||
| if(DEFINED ${_MACRO_PREFIX}_INCLUDE) | ||
| message(VERBOSE "vikunja_add_default_test: add ${${_MACRO_PREFIX}_INCLUDE} include paths to ${_TARGET_NAME}") | ||
| target_include_directories(${_TARGET_NAME} PRIVATE ${${_MACRO_PREFIX}_INCLUDE}) | ||
| endif() | ||
|
|
||
| target_link_libraries(${_TARGET_NAME} | ||
| PRIVATE | ||
| vikunja::internalvikunja | ||
| vikunja::testSetup | ||
| ) | ||
|
|
||
| add_test(NAME ${_TARGET_NAME} COMMAND ${_TARGET_NAME} ${_VIKUNJA_TEST_OPTIONS}) | ||
|
|
||
| endmacro() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* Copyright 2022 Hauke Mewes, Jonas Schenke, Simeon Ehrig | ||
| * | ||
| * This file is part of vikunja. | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <alpaka/alpaka.hpp> | ||
|
|
||
| namespace vikunja::MemAccess | ||
| { | ||
| //! Base class to implement memory access strategy. | ||
| //! | ||
| //! \tparam TIdx Index type | ||
| template<typename TIdx> | ||
| class BaseStrategy | ||
| { | ||
| protected: | ||
| TIdx m_index; | ||
| TIdx const m_maximum; | ||
|
|
||
| public: | ||
| //----------------------------------------------------------------------------- | ||
| //! Constructor. | ||
| //! | ||
| //! \param index The index. | ||
| //! \param maximum The first index outside of the iterator memory. | ||
| ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE BaseStrategy(TIdx const index, TIdx const maximum) | ||
| : m_index(index) | ||
| , m_maximum(maximum) | ||
| { | ||
| } | ||
|
|
||
| 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 | ||
| { | ||
| return (this->m_index == other.m_index) && (this->m_maximum == other.m_maximum); | ||
| } | ||
|
|
||
| ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator!=(const BaseStrategy& other) const -> bool | ||
| { | ||
| return !operator==(other); | ||
| } | ||
|
|
||
| ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator<(const BaseStrategy& other) const -> bool | ||
| { | ||
| return m_index < other.m_index; | ||
| } | ||
|
|
||
| ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator>(const BaseStrategy& other) const -> bool | ||
| { | ||
| return m_index > other.m_index; | ||
| } | ||
|
|
||
| ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator<=(const BaseStrategy& other) const -> bool | ||
| { | ||
| return m_index <= other.m_index; | ||
| } | ||
|
|
||
| ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator>=(const BaseStrategy& other) const -> bool | ||
| { | ||
| return m_index >= other.m_index; | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| //! Get the current index. | ||
| //! | ||
| //! Returns a const reference to the current index. | ||
| ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator*() const -> TIdx const& | ||
| { | ||
| return m_index; | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| //! Set the current index | ||
| //! | ||
| //! Returns a reference to the current index. | ||
| ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE auto operator*() -> TIdx& | ||
| { | ||
| return m_index; | ||
| } | ||
| }; | ||
|
|
||
| } // namespace vikunja::MemAccess | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.