Skip to content

Commit

Permalink
Merge pull request #9 from uliegecsm/atomic-add
Browse files Browse the repository at this point in the history
concepts(containers): add concept for `Kokkos::DualView`
  • Loading branch information
romintomasetti authored Jun 20, 2024
2 parents c7938e7 + 14fd338 commit 7df67a4
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ target_sources(
KokkosUtils
INTERFACE
include/kokkos-utils/atomics/InsertOp.hpp

include/kokkos-utils/concepts/DualView.hpp
include/kokkos-utils/concepts/View.hpp
)

Expand Down
15 changes: 15 additions & 0 deletions include/kokkos-utils/concepts/DualView.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef KOKKOS_UTILS_CONCEPTS_DUALVIEW_HPP
#define KOKKOS_UTILS_CONCEPTS_DUALVIEW_HPP

#include "Kokkos_DualView.hpp"

namespace Kokkos::utils::concepts
{

//! Concept to specify that a type is a @c Kokkos::DualView.
template <typename T>
concept DualView = Kokkos::is_dual_view_v<T>;

} // namespace Kokkos::utils::concepts

#endif // KOKKOS_UTILS_CONCEPTS_DUALVIEW_HPP
5 changes: 5 additions & 0 deletions tests/concepts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### TEST : DualView ###
add_one_test(
TEST_NAME DualView
)

### TEST : View ###
add_one_test(
TEST_NAME View
Expand Down
42 changes: 42 additions & 0 deletions tests/concepts/test_DualView.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "gtest/gtest.h"

#include "kokkos-utils/concepts/DualView.hpp"
#include "kokkos-utils/concepts/View.hpp"

using execution_space = Kokkos::DefaultExecutionSpace;

/**
* @file
*
* @addtogroup unittests
*
* **Concepts related to @c Kokkos::DualView**
*
* This group of tests check the behavior of our concepts related to @c Kokkos::DualView.
*/

namespace Kokkos::utils::tests::concepts
{

//! @test Check that @ref Kokkos::utils::concepts::DualView works as expected.
TEST(concepts, DualView)
{
using dual_view_1d_t = Kokkos::DualView<int[5] , execution_space>;
using view_1d_t = Kokkos:: View<int[5] , execution_space>;
using dual_view_2d_t = Kokkos::DualView<int[5][5], execution_space>;
using view_2d_t = Kokkos:: View<int[5][5], execution_space>;

//! A @c Kokkos::DualView fulfills the concept.
static_assert(Kokkos::utils::concepts::DualView<dual_view_1d_t>);
static_assert(Kokkos::utils::concepts::DualView<dual_view_2d_t>);

//! A @c Kokkos::View does not fulfill the concept.
static_assert(! Kokkos::utils::concepts::DualView<view_1d_t>);
static_assert(! Kokkos::utils::concepts::DualView<view_2d_t>);

//! A @c Kokkos::DualView does not fulfill the @ref Kokkos::utils::concepts::View concept.
static_assert(! Kokkos::utils::concepts::View<dual_view_1d_t>);
static_assert(! Kokkos::utils::concepts::View<dual_view_2d_t>);
}

} // namespace Kokkos::utils::tests::concepts

0 comments on commit 7df67a4

Please sign in to comment.