Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _IntType = int>
class binomial_distribution
{
static_assert(__libcpp_random_is_valid_inttype<_IntType>, "IntType must be a supported integer type");
static_assert(__cccl_random_is_valid_inttype<_IntType>, "IntType must be a supported integer type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class cauchy_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class chi_squared_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class exponential_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class extreme_value_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class fisher_f_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class gamma_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _IntType = int>
class geometric_distribution
{
static_assert(__libcpp_random_is_valid_inttype<_IntType>, "IntType must be a supported integer type");
static_assert(__cccl_random_is_valid_inttype<_IntType>, "IntType must be a supported integer type");

public:
// types
Expand Down
34 changes: 17 additions & 17 deletions libcudacxx/include/cuda/std/__random/is_valid.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
// cv-unqualified and is one of float, double, or long double.

template <class>
inline constexpr bool __libcpp_random_is_valid_realtype = false;
inline constexpr bool __cccl_random_is_valid_realtype = false;

template <>
inline constexpr bool __libcpp_random_is_valid_realtype<float> = true;
inline constexpr bool __cccl_random_is_valid_realtype<float> = true;
template <>
inline constexpr bool __libcpp_random_is_valid_realtype<double> = true;
inline constexpr bool __cccl_random_is_valid_realtype<double> = true;
#if _CCCL_HAS_LONG_DOUBLE()
template <>
inline constexpr bool __libcpp_random_is_valid_realtype<long double> = true;
inline constexpr bool __cccl_random_is_valid_realtype<long double> = true;
#endif // _CCCL_HAS_LONG_DOUBLE()

// [rand.req.genl]/1.5:
Expand All @@ -55,32 +55,32 @@ inline constexpr bool __libcpp_random_is_valid_realtype<long double> = true;
// unsigned int, unsigned long, or unsigned long long.

template <class>
inline constexpr bool __libcpp_random_is_valid_inttype = false;
inline constexpr bool __cccl_random_is_valid_inttype = false;
template <> // extension
inline constexpr bool __libcpp_random_is_valid_inttype<int8_t> = true;
inline constexpr bool __cccl_random_is_valid_inttype<int8_t> = true;
template <>
inline constexpr bool __libcpp_random_is_valid_inttype<short> = true;
inline constexpr bool __cccl_random_is_valid_inttype<short> = true;
template <>
inline constexpr bool __libcpp_random_is_valid_inttype<int> = true;
inline constexpr bool __cccl_random_is_valid_inttype<int> = true;
template <>
inline constexpr bool __libcpp_random_is_valid_inttype<long> = true;
inline constexpr bool __cccl_random_is_valid_inttype<long> = true;
template <>
inline constexpr bool __libcpp_random_is_valid_inttype<long long> = true;
inline constexpr bool __cccl_random_is_valid_inttype<long long> = true;
template <> // extension
inline constexpr bool __libcpp_random_is_valid_inttype<uint8_t> = true;
inline constexpr bool __cccl_random_is_valid_inttype<uint8_t> = true;
template <>
inline constexpr bool __libcpp_random_is_valid_inttype<unsigned short> = true;
inline constexpr bool __cccl_random_is_valid_inttype<unsigned short> = true;
template <>
inline constexpr bool __libcpp_random_is_valid_inttype<unsigned int> = true;
inline constexpr bool __cccl_random_is_valid_inttype<unsigned int> = true;
template <>
inline constexpr bool __libcpp_random_is_valid_inttype<unsigned long> = true;
inline constexpr bool __cccl_random_is_valid_inttype<unsigned long> = true;
template <>
inline constexpr bool __libcpp_random_is_valid_inttype<unsigned long long> = true;
inline constexpr bool __cccl_random_is_valid_inttype<unsigned long long> = true;
#if _CCCL_HAS_INT128()
template <> // extension
inline constexpr bool __libcpp_random_is_valid_inttype<__int128_t> = true;
inline constexpr bool __cccl_random_is_valid_inttype<__int128_t> = true;
template <> // extension
inline constexpr bool __libcpp_random_is_valid_inttype<__uint128_t> = true;
inline constexpr bool __cccl_random_is_valid_inttype<__uint128_t> = true;
#endif // _CCCL_HAS_INT128()

// [rand.req.urng]/3:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class lognormal_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _IntType = int>
class negative_binomial_distribution
{
static_assert(__libcpp_random_is_valid_inttype<_IntType>, "IntType must be a supported integer type");
static_assert(__cccl_random_is_valid_inttype<_IntType>, "IntType must be a supported integer type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class normal_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _IntType = int>
class poisson_distribution
{
static_assert(__libcpp_random_is_valid_inttype<_IntType>, "IntType must be a supported integer type");
static_assert(__cccl_random_is_valid_inttype<_IntType>, "IntType must be a supported integer type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class student_t_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class __independent_bits_engine
template <class _IntType = int>
class uniform_int_distribution
{
static_assert(__libcpp_random_is_valid_inttype<_IntType>, "IntType must be a supported integer type");
static_assert(__cccl_random_is_valid_inttype<_IntType>, "IntType must be a supported integer type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class uniform_real_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _CCCL_BEGIN_NAMESPACE_CUDA_STD
template <class _RealType = double>
class weibull_distribution
{
static_assert(__libcpp_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");
static_assert(__cccl_random_is_valid_realtype<_RealType>, "RealType must be a supported floating-point type");

public:
// types
Expand Down
1 change: 1 addition & 0 deletions libcudacxx/include/cuda/std/__random_
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <cuda/std/__random/extreme_value_distribution.h>
#include <cuda/std/__random/fisher_f_distribution.h>
#include <cuda/std/__random/gamma_distribution.h>
#include <cuda/std/__random/generate_canonical.h>
#include <cuda/std/__random/geometric_distribution.h>
#include <cuda/std/__random/linear_congruential_engine.h>
#include <cuda/std/__random/lognormal_distribution.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
//

#include <cuda/std/__random_>
#include <cuda/std/array>
#include <cuda/std/cassert>
#include <cuda/std/numeric>

#include "test_macros.h"

template <class T>
__host__ __device__ void test()
{
cuda::std::array<T, 100> data;
cuda::std::philox4x64 g{};
for (auto& v : data)
{
v = cuda::std::generate_canonical<T, cuda::std::numeric_limits<T>::digits>(g);
assert(v >= T(0) && v < T(1));
}
auto mean = cuda::std::accumulate(data.begin(), data.end(), T(0)) / data.size();
assert(mean > T(0.4) && mean < T(0.6));
}

int main(int, char**)
{
test<float>();
test<double>();
return 0;
}
Loading