diff --git a/CMakeLists.txt b/CMakeLists.txt index 9468659..6c841d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,8 @@ target_sources( include/kokkos-utils/concepts/MemorySpace.hpp include/kokkos-utils/concepts/Space.hpp include/kokkos-utils/concepts/View.hpp + + include/kokkos-utils/impl/type_traits.hpp ) target_include_directories( diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index d4e6525..18d7ed4 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,4 +1,4 @@ -#--- Find Doxygen. +#---- Find Doxygen. string(JSON Doxygen_REQUIRED_VERSION GET "${VERSION_JSON}" dependencies doxygen value) find_package( @@ -7,16 +7,28 @@ find_package( REQUIRED ) +#---- Fetch Kokkos tag file. Note that the Kokkos project does not generate a tag file, but Trilinos does. +set(KOKKOS_TAG_FILE "${CMAKE_CURRENT_BINARY_DIR}/Kokkos.tag") +set(KOKKOS_TAG_FILE_URL "https://docs.trilinos.org/dev/packages/common/tag_files/kokkos.tag") +message(STATUS "Fetching Kokkos tag file with ${KOKKOS_TAG_FILE_URL} and storing it to ${KOKKOS_TAG_FILE}.") +file(DOWNLOAD ${KOKKOS_TAG_FILE_URL} ${KOKKOS_TAG_FILE} STATUS fetch_kokkos_tag_file_status) +list(GET fetch_kokkos_tag_file_status 0 fetch_kokkos_tag_file_status_return_code) +if(NOT fetch_kokkos_tag_file_status_return_code EQUAL 0) + message(FATAL_ERROR "An error occurred while fetching tag file for package Kokkos with ${KOKKOS_TAG_FILE_URL} (${fetch_kokkos_tag_file_status}).") +endif() + #---- Our 'homepage' is the README file. set(HOMEPAGE_MD ${CMAKE_SOURCE_DIR}/README.md) #---- Doxygen settings. set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${HOMEPAGE_MD}) set(DOXYGEN_TIMESTAMP YES) +set(DOXYGEN_EXTRACT_ALL YES) set(DOXYGEN_WARN_AS_ERROR YES) set(DOXYGEN_SOURCE_BROWSER YES) set(DOXYGEN_WARN_IF_UNDOCUMENTED NO) set(DOXYGEN_GENERATE_TAGFILE "${CMAKE_CURRENT_BINARY_DIR}/html/${CMAKE_PROJECT_NAME}.tag") +set(DOXYGEN_TAGFILES "${KOKKOS_TAG_FILE}") #---- Extract files for documentation. get_target_property(KokkosUtils_TARGET_FILES_FOR_DOC KokkosUtils INTERFACE_SOURCES) @@ -38,4 +50,5 @@ doxygen_add_docs( # Files NOT added to the global property KokkosUtils_FILES_FOR_DOC ${CMAKE_SOURCE_DIR}/docs/tests.dox + ${CMAKE_SOURCE_DIR}/tests/main.cpp ) diff --git a/include/kokkos-utils/atomics/InsertOp.hpp b/include/kokkos-utils/atomics/InsertOp.hpp index 745e040..521887c 100644 --- a/include/kokkos-utils/atomics/InsertOp.hpp +++ b/include/kokkos-utils/atomics/InsertOp.hpp @@ -11,7 +11,7 @@ namespace Kokkos::utils::atomics /** * @brief Insert an element in a view at a specific index using @c Kokkos::atomic_min. * - * To be used with *e.g.* @c Kokkos::UnorderedMap::insert. + * To be used with *e.g.* @ref Kokkos::UnorderedMap::insert. */ struct InsertMin { diff --git a/include/kokkos-utils/concepts/DualView.hpp b/include/kokkos-utils/concepts/DualView.hpp index 3b13394..6e7b259 100644 --- a/include/kokkos-utils/concepts/DualView.hpp +++ b/include/kokkos-utils/concepts/DualView.hpp @@ -6,7 +6,7 @@ namespace Kokkos::utils::concepts { -//! Concept to specify that a type is a @c Kokkos::DualView. +//! Specify that a type is a @c Kokkos::DualView. template concept DualView = Kokkos::is_dual_view_v; diff --git a/include/kokkos-utils/concepts/ExecutionSpace.hpp b/include/kokkos-utils/concepts/ExecutionSpace.hpp index abba344..29693bc 100644 --- a/include/kokkos-utils/concepts/ExecutionSpace.hpp +++ b/include/kokkos-utils/concepts/ExecutionSpace.hpp @@ -6,7 +6,7 @@ namespace Kokkos::utils::concepts { -//! Concept to specify that a type is a @c Kokkos execution space. +//! Specify that a type is a @ref Kokkos execution space. template concept ExecutionSpace = Kokkos::is_execution_space_v; diff --git a/include/kokkos-utils/concepts/MemorySpace.hpp b/include/kokkos-utils/concepts/MemorySpace.hpp index 9ddb56b..9bef5b1 100644 --- a/include/kokkos-utils/concepts/MemorySpace.hpp +++ b/include/kokkos-utils/concepts/MemorySpace.hpp @@ -6,7 +6,7 @@ namespace Kokkos::utils::concepts { -//! Concept to specify that a type is a @c Kokkos memory space. +//! Specify that a type is a @ref Kokkos memory space. template concept MemorySpace = Kokkos::is_memory_space_v; diff --git a/include/kokkos-utils/concepts/Space.hpp b/include/kokkos-utils/concepts/Space.hpp index ded207b..13fb881 100644 --- a/include/kokkos-utils/concepts/Space.hpp +++ b/include/kokkos-utils/concepts/Space.hpp @@ -6,7 +6,7 @@ namespace Kokkos::utils::concepts { -//! Concept to specify that a type is a @c Kokkos space. +//! Specify that a type is a @ref Kokkos space. template concept Space = Kokkos::is_space::value; diff --git a/include/kokkos-utils/concepts/View.hpp b/include/kokkos-utils/concepts/View.hpp index ec2d101..0025290 100644 --- a/include/kokkos-utils/concepts/View.hpp +++ b/include/kokkos-utils/concepts/View.hpp @@ -1,15 +1,35 @@ #ifndef KOKKOS_UTILS_CONCEPTS_VIEW_HPP #define KOKKOS_UTILS_CONCEPTS_VIEW_HPP +#include + #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 concept View = Kokkos::is_view_v; +//! Specify that a type is a @ref Kokkos::View of given rank @p Rank. +template +concept ViewOfRank = View && T::rank == Rank; + +//! Specify that a type is a modifiable @ref Kokkos::View. +template +concept ModifiableView = View && ! std::is_const_v; + +//! Specify that a type is a @ref Kokkos::View with value type @p ValueType. +template +concept ViewOf = View && std::same_as; + +//! Specify that a type is a @ref Kokkos::View, whose value type is an instance of a given class template @p U. +template class U> +concept ViewOfInstanceOf = View && impl::InstanceOf; + } // namespace Kokkos::utils::concepts #endif // KOKKOS_UTILS_CONCEPTS_VIEW_HPP diff --git a/include/kokkos-utils/impl/type_traits.hpp b/include/kokkos-utils/impl/type_traits.hpp new file mode 100644 index 0000000..3382284 --- /dev/null +++ b/include/kokkos-utils/impl/type_traits.hpp @@ -0,0 +1,34 @@ +#ifndef KOKKOS_UTILS_IMPL_TYPE_TRAITS_HPP +#define KOKKOS_UTILS_IMPL_TYPE_TRAITS_HPP + +#include + +/** + * @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 U> +inline constexpr bool is_instance_of_v = std::false_type{}; + +template