-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
cuda::std::numeric_limits
for __half
and __nv_bfloat16
(
#3361) * implement `cuda::std::numeric_limits` for `__half` and `__nv_bfloat16`
- Loading branch information
Showing
36 changed files
with
563 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...est/libcudacxx/std/language.support/support.limits/limits/numeric.limits.members/common.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef NUMERIC_LIMITS_MEMBERS_COMMON_H | ||
#define NUMERIC_LIMITS_MEMBERS_COMMON_H | ||
|
||
// Disable all the extended floating point operations and conversions | ||
#define __CUDA_NO_HALF_CONVERSIONS__ 1 | ||
#define __CUDA_NO_HALF_OPERATORS__ 1 | ||
#define __CUDA_NO_BFLOAT16_CONVERSIONS__ 1 | ||
#define __CUDA_NO_BFLOAT16_OPERATORS__ 1 | ||
|
||
#include <cuda/std/limits> | ||
|
||
template <class T> | ||
__host__ __device__ bool float_eq(T x, T y) | ||
{ | ||
return x == y; | ||
} | ||
|
||
#if defined(_LIBCUDACXX_HAS_NVFP16) | ||
__host__ __device__ inline bool float_eq(__half x, __half y) | ||
{ | ||
return __heq(x, y); | ||
} | ||
#endif // _LIBCUDACXX_HAS_NVFP16 | ||
|
||
#if defined(_LIBCUDACXX_HAS_NVBF16) | ||
__host__ __device__ inline bool float_eq(__nv_bfloat16 x, __nv_bfloat16 y) | ||
{ | ||
return __heq(x, y); | ||
} | ||
#endif // _LIBCUDACXX_HAS_NVBF16 | ||
|
||
#endif // NUMERIC_LIMITS_MEMBERS_COMMON_H |
Oops, something went wrong.