CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
169 lines
4.8 KiB
C++
169 lines
4.8 KiB
C++
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test the ability of each <bit> function to be invoked
|
|
|
|
#include <cuda/std/bit>
|
|
#include <cuda/std/cstdint>
|
|
#include <cuda/std/type_traits>
|
|
|
|
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_MSC_VER) && _MSVC_LANG >= 201703L)
|
|
# define CPP17_PERFORM_INVOCABLE_TEST
|
|
#endif
|
|
|
|
class A
|
|
{};
|
|
enum E1 : unsigned char
|
|
{
|
|
rEd
|
|
};
|
|
enum class E2 : unsigned char
|
|
{
|
|
red
|
|
};
|
|
|
|
// rotr
|
|
struct i_rotr
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::rotr(x, 1U));
|
|
};
|
|
|
|
// rotl
|
|
struct i_rotl
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::rotl(x, 1U));
|
|
};
|
|
|
|
// popcount
|
|
struct i_popcount
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::popcount(x));
|
|
};
|
|
|
|
// countr_zero
|
|
struct i_countr_zero
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::countr_zero(x));
|
|
};
|
|
|
|
// countr_one
|
|
struct i_countr_one
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::countr_one(x));
|
|
};
|
|
|
|
// countl_zero
|
|
struct i_countl_zero
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::countl_zero(x));
|
|
};
|
|
|
|
// countl_one
|
|
struct i_countl_one
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::countl_one(x));
|
|
};
|
|
|
|
// bit_width
|
|
struct i_bit_width
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::bit_width(x));
|
|
};
|
|
|
|
// has_single_bit
|
|
struct i_has_single_bit
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::has_single_bit(x));
|
|
};
|
|
|
|
// bit_floor
|
|
struct i_bit_floor
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::bit_floor(x));
|
|
};
|
|
|
|
// bit_ceil
|
|
struct i_bit_ceil
|
|
{
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator()(T x) const -> decltype(cuda::std::bit_ceil(x));
|
|
};
|
|
|
|
template <typename L>
|
|
__host__ __device__ void test_invocable()
|
|
{
|
|
#if defined(CPP17_PERFORM_INVOCABLE_TEST)
|
|
static_assert(cuda::std::is_invocable_v<L, unsigned char>, "");
|
|
static_assert(cuda::std::is_invocable_v<L, unsigned int>, "");
|
|
static_assert(cuda::std::is_invocable_v<L, unsigned long>, "");
|
|
static_assert(cuda::std::is_invocable_v<L, unsigned long long>, "");
|
|
|
|
static_assert(cuda::std::is_invocable_v<L, uint8_t>, "");
|
|
static_assert(cuda::std::is_invocable_v<L, uint16_t>, "");
|
|
static_assert(cuda::std::is_invocable_v<L, uint32_t>, "");
|
|
static_assert(cuda::std::is_invocable_v<L, uint64_t>, "");
|
|
static_assert(cuda::std::is_invocable_v<L, size_t>, "");
|
|
|
|
static_assert(cuda::std::is_invocable_v<L, uintmax_t>, "");
|
|
static_assert(cuda::std::is_invocable_v<L, uintptr_t>, "");
|
|
|
|
static_assert(!cuda::std::is_invocable_v<L, int>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, signed int>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, long>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, long long>, "");
|
|
|
|
static_assert(!cuda::std::is_invocable_v<L, int8_t>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, int16_t>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, int32_t>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, int64_t>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, ptrdiff_t>, "");
|
|
|
|
static_assert(!cuda::std::is_invocable_v<L, bool>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, signed char>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, char16_t>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, char32_t>, "");
|
|
|
|
# if _CCCL_HAS_INT128()
|
|
static_assert(cuda::std::is_invocable_v<L, __uint128_t>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, __int128_t>, "");
|
|
# endif // _CCCL_HAS_INT128()
|
|
|
|
static_assert(!cuda::std::is_invocable_v<L, A, unsigned>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, E1, unsigned>, "");
|
|
static_assert(!cuda::std::is_invocable_v<L, E2, unsigned>, "");
|
|
#endif // defined(CPP17_PERFORM_INVOCABLE_TEST)
|
|
}
|
|
|
|
int main(int, char**)
|
|
{
|
|
{
|
|
test_invocable<i_rotr>();
|
|
test_invocable<i_rotl>();
|
|
test_invocable<i_popcount>();
|
|
test_invocable<i_countr_zero>();
|
|
test_invocable<i_countr_one>();
|
|
test_invocable<i_countl_zero>();
|
|
test_invocable<i_countl_one>();
|
|
test_invocable<i_bit_width>();
|
|
test_invocable<i_has_single_bit>();
|
|
test_invocable<i_bit_floor>();
|
|
test_invocable<i_bit_ceil>();
|
|
}
|
|
return 0;
|
|
}
|