// SPDX-FileCopyrightText: Copyright (c) 2011-2025, NVIDIA CORPORATION. All rights reserved. // SPDX-License-Identifier: BSD-3-Clause #include #include #include #include #include #include #include #include namespace c2h::detail { template void gen_values_between(seed_t seed, ::cuda::std::span data, T min, T max) { const auto* dist = prepare_random_data(seed, data.size()); thrust::transform(device_policy, dist, dist + data.size(), data.begin(), random_to_item_t(min, max)); } template struct counter_to_cyclic_item_t { std::size_t n; template __device__ T operator()(CounterT id) { // This has to be a type for which extended floating point types like __nv_fp8_e5m2 provide an overload return static_cast(static_cast(static_cast(id) % n)); } }; template void gen_values_cyclic(modulo_t mod, ::cuda::std::span data) { thrust::tabulate(device_policy, data.begin(), data.end(), counter_to_cyclic_item_t{mod.get()}); } #define INSTANTIATE_RND(TYPE) \ template void gen_values_between(seed_t, ::cuda::std::span data, TYPE min, TYPE max) #define INSTANTIATE_MOD(TYPE) template void gen_values_cyclic(modulo_t, ::cuda::std::span data) #define INSTANTIATE(TYPE) \ INSTANTIATE_RND(TYPE); \ INSTANTIATE_MOD(TYPE) INSTANTIATE(std::uint8_t); INSTANTIATE(std::uint16_t); INSTANTIATE(std::uint32_t); INSTANTIATE(std::uint64_t); INSTANTIATE(std::int8_t); INSTANTIATE(std::int16_t); INSTANTIATE(std::int32_t); INSTANTIATE(std::int64_t); #if _CCCL_HAS_NVFP8() INSTANTIATE(__nv_fp8_e5m2); INSTANTIATE(__nv_fp8_e4m3); #endif // _CCCL_HAS_NVFP8() INSTANTIATE(float); INSTANTIATE(double); INSTANTIATE(cuda::std::complex); INSTANTIATE(cuda::std::complex); INSTANTIATE(bool); INSTANTIATE(char); #if TEST_HALF_T() INSTANTIATE(half_t); INSTANTIATE(__half); # if _CCCL_CTK_AT_LEAST(12, 2) INSTANTIATE(cuda::std::complex<__half>); # endif // _CCCL_CTK_AT_LEAST(12, 2) #endif // TEST_HALF_T() #if TEST_BF_T() INSTANTIATE(bfloat16_t); INSTANTIATE(__nv_bfloat16); # if _CCCL_CTK_AT_LEAST(12, 2) INSTANTIATE(cuda::std::complex<__nv_bfloat16>); # endif // _CCCL_CTK_AT_LEAST(12, 2) #endif // TEST_BF_T() #if TEST_INT128() INSTANTIATE(__int128_t); INSTANTIATE(__uint128_t); #endif // TEST_INT128() #undef INSTANTIATE_RND #undef INSTANTIATE_MOD #undef INSTANTIATE } // namespace c2h::detail