diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 225c6ac..24763a6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,6 +2,7 @@ "dockerFile": "dockerfile", "extensions" : [ "ms-vscode.cmake-tools", + "eamodio.gitlens", "mhutchie.git-graph", "ms-azuretools.vscode-docker" ], diff --git a/CMakeLists.txt b/CMakeLists.txt index 70410a5..9468659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,10 @@ target_sources( include/kokkos-utils/atomics/InsertOp.hpp include/kokkos-utils/concepts/DualView.hpp + + include/kokkos-utils/concepts/ExecutionSpace.hpp + include/kokkos-utils/concepts/MemorySpace.hpp + include/kokkos-utils/concepts/Space.hpp include/kokkos-utils/concepts/View.hpp ) diff --git a/include/kokkos-utils/concepts/ExecutionSpace.hpp b/include/kokkos-utils/concepts/ExecutionSpace.hpp new file mode 100644 index 0000000..abba344 --- /dev/null +++ b/include/kokkos-utils/concepts/ExecutionSpace.hpp @@ -0,0 +1,15 @@ +#ifndef KOKKOS_UTILS_CONCEPTS_EXECUTIONSPACE_HPP +#define KOKKOS_UTILS_CONCEPTS_EXECUTIONSPACE_HPP + +#include "Kokkos_Concepts.hpp" + +namespace Kokkos::utils::concepts +{ + +//! Concept to specify that a type is a @c Kokkos execution space. +template +concept ExecutionSpace = Kokkos::is_execution_space_v; + +} // namespace Kokkos::utils::concepts + +#endif // KOKKOS_UTILS_CONCEPTS_EXECUTIONSPACE_HPP diff --git a/include/kokkos-utils/concepts/MemorySpace.hpp b/include/kokkos-utils/concepts/MemorySpace.hpp new file mode 100644 index 0000000..9ddb56b --- /dev/null +++ b/include/kokkos-utils/concepts/MemorySpace.hpp @@ -0,0 +1,15 @@ +#ifndef KOKKOS_UTILS_CONCEPTS_MEMORYSPACE_HPP +#define KOKKOS_UTILS_CONCEPTS_MEMORYSPACE_HPP + +#include "Kokkos_Concepts.hpp" + +namespace Kokkos::utils::concepts +{ + +//! Concept to specify that a type is a @c Kokkos memory space. +template +concept MemorySpace = Kokkos::is_memory_space_v; + +} // namespace Kokkos::utils::concepts + +#endif // KOKKOS_UTILS_CONCEPTS_MEMORYSPACE_HPP diff --git a/include/kokkos-utils/concepts/Space.hpp b/include/kokkos-utils/concepts/Space.hpp new file mode 100644 index 0000000..ded207b --- /dev/null +++ b/include/kokkos-utils/concepts/Space.hpp @@ -0,0 +1,15 @@ +#ifndef KOKKOS_UTILS_CONCEPTS_SPACE_HPP +#define KOKKOS_UTILS_CONCEPTS_SPACE_HPP + +#include "Kokkos_Concepts.hpp" + +namespace Kokkos::utils::concepts +{ + +//! Concept to specify that a type is a @c Kokkos space. +template +concept Space = Kokkos::is_space::value; + +} // namespace Kokkos::utils::concepts + +#endif // KOKKOS_UTILS_CONCEPTS_SPACE_HPP diff --git a/tests/concepts/CMakeLists.txt b/tests/concepts/CMakeLists.txt index bb42569..e5d7ec8 100644 --- a/tests/concepts/CMakeLists.txt +++ b/tests/concepts/CMakeLists.txt @@ -3,8 +3,22 @@ add_one_test( TEST_NAME DualView ) +### TEST : ExecutionSpace ### +add_one_test( + TEST_NAME ExecutionSpace +) + +### TEST : MemorySpace ### +add_one_test( + TEST_NAME MemorySpace +) + +### TEST : Space ### +add_one_test( + TEST_NAME Space +) + ### TEST : View ### add_one_test( TEST_NAME View ) - diff --git a/tests/concepts/test_ExecutionSpace.cpp b/tests/concepts/test_ExecutionSpace.cpp new file mode 100644 index 0000000..29a170b --- /dev/null +++ b/tests/concepts/test_ExecutionSpace.cpp @@ -0,0 +1,30 @@ +#include "gtest/gtest.h" + +#include "Kokkos_Core.hpp" + +#include "kokkos-utils/concepts/ExecutionSpace.hpp" + +using execution_space = Kokkos::DefaultExecutionSpace; + +/** + * @file + * + * @addtogroup unittests + * + * **Concepts related to @c Kokkos execution space** + * + * This group of tests check the behavior of our concepts related to @c Kokkos execution space. + */ + +namespace Kokkos::utils::tests::concepts +{ + +//! @test Check that @ref Kokkos::utils::concepts::ExecutionSpace works as expected. +TEST(concepts, ExecutionSpace) +{ + static_assert( Kokkos::utils::concepts::ExecutionSpace); + static_assert(! Kokkos::utils::concepts::ExecutionSpace); + static_assert(! Kokkos::utils::concepts::ExecutionSpace>); +} + +} // namespace Kokkos::utils::tests::concepts diff --git a/tests/concepts/test_MemorySpace.cpp b/tests/concepts/test_MemorySpace.cpp new file mode 100644 index 0000000..fd56b37 --- /dev/null +++ b/tests/concepts/test_MemorySpace.cpp @@ -0,0 +1,30 @@ +#include "gtest/gtest.h" + +#include "Kokkos_Core.hpp" + +#include "kokkos-utils/concepts/MemorySpace.hpp" + +using execution_space = Kokkos::DefaultExecutionSpace; + +/** + * @file + * + * @addtogroup unittests + * + * **Concepts related to @c Kokkos memory space** + * + * This group of tests check the behavior of our concepts related to @c Kokkos memory space. + */ + +namespace Kokkos::utils::tests::concepts +{ + +//! @test Check that @ref Kokkos::utils::concepts::MemorySpace works as expected. +TEST(concepts, MemorySpace) +{ + static_assert(! Kokkos::utils::concepts::MemorySpace); + static_assert( Kokkos::utils::concepts::MemorySpace); + static_assert(! Kokkos::utils::concepts::MemorySpace>); +} + +} // namespace Kokkos::utils::tests::concepts diff --git a/tests/concepts/test_Space.cpp b/tests/concepts/test_Space.cpp new file mode 100644 index 0000000..6f754d4 --- /dev/null +++ b/tests/concepts/test_Space.cpp @@ -0,0 +1,30 @@ +#include "gtest/gtest.h" + +#include "Kokkos_Core.hpp" + +#include "kokkos-utils/concepts/Space.hpp" + +using execution_space = Kokkos::DefaultExecutionSpace; + +/** + * @file + * + * @addtogroup unittests + * + * **Concepts related to @c Kokkos space** + * + * This group of tests check the behavior of our concepts related to @c Kokkos space. + */ + +namespace Kokkos::utils::tests::concepts +{ + +//! @test Check that @ref Kokkos::utils::concepts::Space works as expected. +TEST(concepts, Space) +{ + static_assert(Kokkos::utils::concepts::Space); + static_assert(Kokkos::utils::concepts::Space); + static_assert(Kokkos::utils::concepts::Space>); +} + +} // namespace Kokkos::utils::tests::concepts