//===----------------------------------------------------------------------===// // // 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) 2024 NVIDIA CORPORATION & AFFILIATES. // //===----------------------------------------------------------------------===// // #include #include #include #include "test_macros.h" template __host__ __device__ void test_log(T value) { using ret = cuda::std::conditional_t, double, T>; static_assert(cuda::std::is_same_v, ""); assert(cuda::std::log(value) == ret{0}); } template __host__ __device__ void test_log10(T value) { using ret = cuda::std::conditional_t, double, T>; static_assert(cuda::std::is_same_v, ""); assert(cuda::std::log10(value) == ret{0}); } template __host__ __device__ void test_ilogb(T value) { static_assert(cuda::std::is_same_v, ""); assert(cuda::std::ilogb(value) == 0); } template __host__ __device__ void test_log1p(T value) { using ret = cuda::std::conditional_t, double, T>; static_assert(cuda::std::is_same_v, ""); assert(cuda::std::log1p(value - value) == ret{0}); } template __host__ __device__ void test_log2(T value) { using ret = cuda::std::conditional_t, double, T>; static_assert(cuda::std::is_same_v, ""); assert(cuda::std::log2(value) == ret{0}); } template __host__ __device__ void test_logb(T value) { using ret = cuda::std::conditional_t, double, T>; static_assert(cuda::std::is_same_v, ""); assert(cuda::std::logb(value) == ret{0}); } template __host__ __device__ void test(T value) { test_log(value); test_log10(value); test_ilogb(value); test_log1p(value); test_log2(value); test_logb(value); } __host__ __device__ void test(float value) { test(value); test(value); #if _CCCL_HAS_LONG_DOUBLE() test(value); #endif // _CCCL_HAS_LONG_DOUBLE() #if _LIBCUDACXX_HAS_NVFP16() test<__half>(__float2half(value)); #endif // _LIBCUDACXX_HAS_NVFP16() #if _LIBCUDACXX_HAS_NVBF16() test<__nv_bfloat16>(__float2bfloat16(value)); #endif // _LIBCUDACXX_HAS_NVBF16() test(static_cast(value)); test(static_cast(value)); test(static_cast(value)); test(static_cast(value)); test(static_cast(value)); test(static_cast(value)); test(static_cast(value)); } __global__ void test_global_kernel(float* value) { test(*value); } int main(int, char**) { volatile float value = 1.0f; test(value); return 0; }