Skip to content
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

add some simple utilities for manipulating lists of types #2370

Merged
merged 38 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
302ead2
fix the cudax `vector_add` sample
ericniebler Sep 4, 2024
321b94f
add some simple utilities for manipulating lists of types
ericniebler Sep 4, 2024
1982988
obey C++11 constexpr function rules in `aligned_storage`
ericniebler Sep 4, 2024
94fd59a
add `__type_cartesian_product`, `__type_remove`, and `__type_iota`
ericniebler Sep 5, 2024
db5ec7e
review feedback and compiler work-arounds
ericniebler Sep 5, 2024
7c321ff
work around old clang compiler bugs
ericniebler Sep 5, 2024
92743c8
work around more compiler bugs
ericniebler Sep 5, 2024
e47e27c
add missing host/device annotations to keep nvrtc happy
ericniebler Sep 6, 2024
32da9b7
try to placate msvc
ericniebler Sep 6, 2024
1aa29bb
fix typo
ericniebler Sep 6, 2024
5107f7d
Merge remote-tracking branch 'origin/main' into mini-meta-programming…
ericniebler Sep 6, 2024
e87085d
add `_CCCL_CUDACC_BELOW_12_0` config macro; use it in `type_list.h`
ericniebler Sep 6, 2024
7c13a3f
use a simpler and faster fall-back implementation of pack indexing
ericniebler Sep 6, 2024
bc4002b
Merge remote-tracking branch 'origin/main' into mini-meta-programming…
ericniebler Sep 6, 2024
cb8047d
replace variable template with a class template for the sake of C++11
ericniebler Sep 6, 2024
b9b16aa
add `_CCCL_PP_REPEAT` in a new `__cccl/preprocessor.h` header
ericniebler Sep 8, 2024
fde31b4
generalize `_CCCL_PP_REPEAT` macro; implement `__type_fold_[left|righ…
ericniebler Sep 9, 2024
fec8cc6
reformat
ericniebler Sep 9, 2024
4c80ec5
add missing type and alias attribute annotations
ericniebler Sep 9, 2024
1fc4f95
Merge remote-tracking branch 'origin/main' into mini-meta-programming…
ericniebler Sep 9, 2024
8fef688
add tests for the type-list utilities
ericniebler Sep 10, 2024
ad7cd10
try to make `__type_callable` acceptable to msvc
ericniebler Sep 10, 2024
e4b6cc3
add execution space annotations to functions to keep nvrtc happy
ericniebler Sep 10, 2024
ac95264
comment out `__type_callable` and `__type_defer` for now
ericniebler Sep 10, 2024
3d30fa0
[pre-commit.ci] auto code formatting
pre-commit-ci[bot] Sep 10, 2024
a2f2fef
Merge remote-tracking branch 'upstream/main' into mini-meta-programmi…
ericniebler Sep 10, 2024
a028fa5
Merge branch 'mini-meta-programming-library' of github.com:ericnieble…
ericniebler Sep 10, 2024
fd634fa
remove unneeded #include
ericniebler Sep 10, 2024
edc5eb4
formulate `__type_callable` such that nvcc-11 will accept it
ericniebler Sep 10, 2024
ed3e0d7
avoid the identifier `_C` which is #define-d somewhere
ericniebler Sep 10, 2024
255326f
prefer `cuda::std::size_t` over `std::size_t` in tests for NVRTC
ericniebler Sep 10, 2024
6ba0796
Merge branch 'mini-meta-programming-library' of github.com:ericnieble…
ericniebler Sep 10, 2024
c01fdd3
use a different formulation of `__type_call_indirect` for nvcc < 12.2
ericniebler Sep 10, 2024
0695756
Apply review comments
miscco Sep 11, 2024
fb84f7c
Revert "use a different formulation of `__type_call_indirect` for nvc…
ericniebler Sep 11, 2024
a7bb648
nvcc prior to 12.2 could not reliably do SFINAE during alias instanti…
ericniebler Sep 12, 2024
3583414
Merge remote-tracking branch 'origin/main' into mini-meta-programming…
ericniebler Sep 12, 2024
858368b
skip meta-programming SFINAE tests with the Intel compiler
ericniebler Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions cub/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ endif()
include("${CUB_SOURCE_DIR}/cmake/CPM.cmake")
CPMAddPackage("gh:catchorg/[email protected]")

option(METAL_BUILD_DOC OFF)
option(METAL_BUILD_EXAMPLES OFF)
option(METAL_BUILD_TESTS OFF)
CPMAddPackage("gh:brunocodutra/[email protected]")

CPMAddPackage(
NAME NVTX
GITHUB_REPOSITORY NVIDIA/NVTX
Expand Down Expand Up @@ -224,7 +219,6 @@ function(cub_add_test target_name_var test_name test_src cub_target launcher_id)
target_link_libraries(${config_c2run_target} PRIVATE
${cub_target}
${config_c2h_target}
Metal
Catch2::Catch2)
cub_clone_target_properties(${config_c2run_target} ${cub_target})
cub_configure_cuda_target(${config_c2run_target} RDC ${cdp_val})
Expand Down Expand Up @@ -264,7 +258,6 @@ function(cub_add_test target_name_var test_name test_src cub_target launcher_id)
target_link_libraries(${test_target} PRIVATE
${cub_target}
${config_c2h_target}
Metal
Catch2::Catch2
)
cub_clone_target_properties(${test_target} ${cub_target})
Expand Down
2 changes: 1 addition & 1 deletion cub/test/catch2_test_device_histogram.cu
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ CUB_TEST("DeviceHistogram::Histogram* basic use", "[histogram][device]", types)

// TODO(bgruber): float produces INFs in the HistogramRange test setup AND the HistogramEven implementation
// This test covers int32 and int64 arithmetic for bin computation
CUB_TEST("DeviceHistogram::Histogram* large levels", "[histogram][device]", metal::remove<types, float>)
CUB_TEST("DeviceHistogram::Histogram* large levels", "[histogram][device]", c2h::remove<types, float>)
{
using sample_t = c2h::get<0, TestType>;
using level_t = sample_t;
Expand Down
20 changes: 11 additions & 9 deletions cub/test/catch2_test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

#include "cuda/std/__cccl/diagnostic.h"
#include "test_util_vec.h"
#include <metal.hpp>

#if __CUDACC_VER_MAJOR__ == 11
_CCCL_NV_DIAG_SUPPRESS(177) // catch2 may contain unused variableds
Expand All @@ -60,31 +59,34 @@ namespace c2h
{

template <typename... Ts>
using type_list = metal::list<Ts...>;
using type_list = ::cuda::std::__type_list<Ts...>;

template <typename TypeList>
using size = metal::size<TypeList>;
using size = ::cuda::std::__type_list_size<TypeList>;

template <std::size_t Index, typename TypeList>
using get = metal::at<TypeList, metal::number<Index>>;
using get = ::cuda::std::__type_at_c<Index, TypeList>;

template <class... TypeLists>
using cartesian_product = metal::cartesian<TypeLists...>;
using cartesian_product = ::cuda::std::__type_cartesian_product<TypeLists...>;

template <typename T, T... Ts>
using enum_type_list = c2h::type_list<std::integral_constant<T, Ts>...>;

template <typename T0, typename T1>
using pair = metal::pair<T0, T1>;
using pair = ::cuda::std::__type_pair<T0, T1>;

template <typename P>
using first = metal::first<P>;
using first = ::cuda::std::__type_pair_first<P>;

template <typename P>
using second = metal::second<P>;
using second = ::cuda::std::__type_pair_second<P>;

template <std::size_t start, std::size_t size, std::size_t stride = 1>
using iota = metal::iota<metal::number<start>, metal::number<size>, metal::number<stride>>;
using iota = ::cuda::std::__type_iota<start, size, stride>;

template <typename TypeList, typename T>
using remove = ::cuda::std::__type_remove<TypeList, T>;

} // namespace c2h

Expand Down
2 changes: 1 addition & 1 deletion cub/test/catch2_test_iterator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

using scalar_types = c2h::type_list<std::int8_t, std::int16_t, std::int32_t, std::int64_t, float, double>;

using types = metal::append<
using types = ::cuda::std::__type_push_back<
scalar_types,
char2,
short2,
Expand Down
14 changes: 7 additions & 7 deletions cudax/samples/vector_add/vector.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public:
}

private:
void sync_host_to_device(stream_ref __str, detail::__param_kind __p) const
void sync_host_to_device(::cuda::stream_ref __str, detail::__param_kind __p) const
{
if (__dirty_)
{
Expand All @@ -78,7 +78,7 @@ private:
}
}

void sync_device_to_host(stream_ref __str, detail::__param_kind __p) const
void sync_device_to_host(::cuda::stream_ref __str, detail::__param_kind __p) const
{
if (__p != detail::__param_kind::_in)
{
Expand All @@ -94,7 +94,7 @@ private:
using __cv_vector = ::cuda::std::__maybe_const<_Kind == detail::__param_kind::_in, vector>;

public:
explicit __action(stream_ref __str, __cv_vector& __v) noexcept
explicit __action(::cuda::stream_ref __str, __cv_vector& __v) noexcept
: __str_(__str)
, __v_(__v)
{
Expand All @@ -116,25 +116,25 @@ private:
}

private:
stream_ref __str_;
::cuda::stream_ref __str_;
__cv_vector& __v_;
};

_CCCL_NODISCARD_FRIEND __action<detail::__param_kind::_inout>
__cudax_launch_transform(stream_ref __str, vector& __v) noexcept
__cudax_launch_transform(::cuda::stream_ref __str, vector& __v) noexcept
{
return __action<detail::__param_kind::_inout>{__str, __v};
}

_CCCL_NODISCARD_FRIEND __action<detail::__param_kind::_in>
__cudax_launch_transform(stream_ref __str, const vector& __v) noexcept
__cudax_launch_transform(::cuda::stream_ref __str, const vector& __v) noexcept
{
return __action<detail::__param_kind::_in>{__str, __v};
}

template <detail::__param_kind _Kind>
_CCCL_NODISCARD_FRIEND __action<_Kind>
__cudax_launch_transform(stream_ref __str, detail::__box<vector, _Kind> __b) noexcept
__cudax_launch_transform(::cuda::stream_ref __str, detail::__box<vector, _Kind> __b) noexcept
{
return __action<_Kind>{__str, __b.__val};
}
Expand Down
7 changes: 3 additions & 4 deletions libcudacxx/include/cuda/std/__mdspan/static_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include <cuda/std/__mdspan/macros.h>
#include <cuda/std/__mdspan/maybe_static_value.h>
#include <cuda/std/__mdspan/standard_layout_static_array.h>
#include <cuda/std/__mdspan/type_list.h>
#include <cuda/std/__type_traits/type_list.h>
#include <cuda/std/__utility/integer_sequence.h>
#include <cuda/std/array>
#include <cuda/std/cstddef>
Expand Down Expand Up @@ -123,9 +123,8 @@ class __partially_static_array_impl<
{
private:
template <size_t _Np>
using __base_n = typename __type_at<
_Np,
__type_list<__maybe_static_value<_Tp, _static_t, __values_or_sentinals, __sentinal, _Idxs>...>>::type;
using __base_n =
__type_index_c<_Np, __maybe_static_value<_Tp, _static_t, __values_or_sentinals, __sentinal, _Idxs>...>;

public:
static constexpr auto __size = sizeof...(_Idxs);
Expand Down
142 changes: 0 additions & 142 deletions libcudacxx/include/cuda/std/__mdspan/type_list.h

This file was deleted.

Loading
Loading