-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from uliegecsm/concepts-view
concepts(core): additional concepts for the `Kokkos::View`
- Loading branch information
Showing
18 changed files
with
211 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,15 +1,35 @@ | ||
#ifndef KOKKOS_UTILS_CONCEPTS_VIEW_HPP | ||
#define KOKKOS_UTILS_CONCEPTS_VIEW_HPP | ||
|
||
#include <concepts> | ||
|
||
#include "Kokkos_View.hpp" | ||
|
||
#include "kokkos-utils/impl/type_traits.hpp" | ||
|
||
namespace Kokkos::utils::concepts | ||
{ | ||
|
||
//! Concept to specify that a type is a @c Kokkos::View. | ||
//! Specify that a type is a @ref Kokkos::View. | ||
template <typename T> | ||
concept View = Kokkos::is_view_v<T>; | ||
|
||
//! Specify that a type is a @ref Kokkos::View of given rank @p Rank. | ||
template <typename T, std::size_t Rank> | ||
concept ViewOfRank = View<T> && T::rank == Rank; | ||
|
||
//! Specify that a type is a modifiable @ref Kokkos::View. | ||
template <typename T> | ||
concept ModifiableView = View<T> && ! std::is_const_v<typename T::value_type>; | ||
|
||
//! Specify that a type is a @ref Kokkos::View with value type @p ValueType. | ||
template <typename T, typename ValueType> | ||
concept ViewOf = View<T> && std::same_as<typename T::value_type, ValueType>; | ||
|
||
//! Specify that a type is a @ref Kokkos::View, whose value type is an instance of a given class template @p U. | ||
template <typename T, template <typename...> class U> | ||
concept ViewOfInstanceOf = View<T> && impl::InstanceOf<typename T::value_type, U>; | ||
|
||
} // namespace Kokkos::utils::concepts | ||
|
||
#endif // KOKKOS_UTILS_CONCEPTS_VIEW_HPP |
This file contains 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,34 @@ | ||
#ifndef KOKKOS_UTILS_IMPL_TYPE_TRAITS_HPP | ||
#define KOKKOS_UTILS_IMPL_TYPE_TRAITS_HPP | ||
|
||
#include <type_traits> | ||
|
||
/** | ||
* @brief This namespace provides extensions to the @c type_traits standard header. | ||
* | ||
* References: | ||
* * https://en.cppreference.com/w/cpp/header/type_traits | ||
*/ | ||
namespace Kokkos::utils::impl | ||
{ | ||
|
||
/** | ||
* @name Check if a type is an instantiation of a given class template. | ||
* | ||
* References: | ||
* * https://indii.org/blog/is-type-instantiation-of-template/ | ||
*/ | ||
///@{ | ||
template <class T, template <typename...> class U> | ||
inline constexpr bool is_instance_of_v = std::false_type{}; | ||
|
||
template <template <typename...> class U, typename... Vs> | ||
inline constexpr bool is_instance_of_v<U<Vs...>, U> = std::true_type{}; | ||
|
||
template <typename T, template <typename...> class U> | ||
concept InstanceOf = is_instance_of_v<T, U>; | ||
///@} | ||
|
||
} // namespace Kokkos::utils::impl | ||
|
||
#endif // KOKKOS_UTILS_IMPL_TYPE_TRAITS_HPP |
This file contains 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 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 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 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 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 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 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,4 @@ | ||
### TEST : type_traits ### | ||
add_one_test( | ||
TEST_NAME type_traits | ||
) |
Oops, something went wrong.