Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
device_double_functions.hpp198 linesDownload Raw Back to crt
1/*
2 * Copyright 1993-2017 NVIDIA Corporation.  All rights reserved.
3 *
4 * NOTICE TO LICENSEE:
5 *
6 * This source code and/or documentation ("Licensed Deliverables") are
7 * subject to NVIDIA intellectual property rights under U.S. and
8 * international Copyright laws.
9 *
10 * These Licensed Deliverables contained herein is PROPRIETARY and
11 * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12 * conditions of a form of NVIDIA software license agreement by and
13 * between NVIDIA and Licensee ("License Agreement") or electronically
14 * accepted by Licensee.  Notwithstanding any terms or conditions to
15 * the contrary in the License Agreement, reproduction or disclosure
16 * of the Licensed Deliverables to any third party without the express
17 * written consent of NVIDIA is prohibited.
18 *
19 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20 * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21 * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE.  IT IS
22 * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23 * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24 * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25 * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27 * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28 * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32 * OF THESE LICENSED DELIVERABLES.
33 *
34 * U.S. Government End Users.  These Licensed Deliverables are a
35 * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36 * 1995), consisting of "commercial computer software" and "commercial
37 * computer software documentation" as such terms are used in 48
38 * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39 * only as a commercial end item.  Consistent with 48 C.F.R.12.212 and
40 * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41 * U.S. Government End Users acquire the Licensed Deliverables with
42 * only those rights set forth herein.
43 *
44 * Any use of the Licensed Deliverables in individual and commercial
45 * software must include, in the user documentation and internal
46 * comments to the code, the above Disclaimer and U.S. Government End
47 * Users Notice.
48 */
49
50#if !defined(__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__)
51#if defined(_MSC_VER)
52#pragma message("crt/device_double_functions.hpp is an internal header file and must not be used directly.  Please use cuda_runtime_api.h or cuda_runtime.h instead.")
53#else
54#warning "crt/device_double_functions.hpp is an internal header file and must not be used directly.  Please use cuda_runtime_api.h or cuda_runtime.h instead."
55#endif
56#define __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
57#define __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_DOUBLE_FUNCTIONS_HPP__
58#endif
59
60#if !defined(__DEVICE_DOUBLE_FUNCTIONS_HPP__)
61#define __DEVICE_DOUBLE_FUNCTIONS_HPP__
62
63/*******************************************************************************
64*                                                                              *
65*                                                                              *
66*                                                                              *
67*******************************************************************************/
68
69#if defined(__cplusplus) && defined(__CUDACC__)
70
71/*******************************************************************************
72*                                                                              *
73*                                                                              *
74*                                                                              *
75*******************************************************************************/
76
77#if defined(__CUDACC_RTC__)
78#define __DEVICE_DOUBLE_FUNCTIONS_DECL__ __device__
79#else
80#define __DEVICE_DOUBLE_FUNCTIONS_DECL__ static __inline__ __device__
81#endif /* __CUDACC_RTC__ */
82
83#include "builtin_types.h"
84#include "device_types.h"
85#include "host_defines.h"
86
87/*******************************************************************************
88*                                                                              *
89*                                                                              *
90*                                                                              *
91*******************************************************************************/
92
93__DEVICE_DOUBLE_FUNCTIONS_DECL__ double fma(double a, double b, double c, enum cudaRoundMode mode)
94{
95  return mode == cudaRoundZero   ? __fma_rz(a, b, c) :
96         mode == cudaRoundPosInf ? __fma_ru(a, b, c) :
97         mode == cudaRoundMinInf ? __fma_rd(a, b, c) :
98                                   __fma_rn(a, b, c);
99}
100
101__DEVICE_DOUBLE_FUNCTIONS_DECL__ double dmul(double a, double b, enum cudaRoundMode mode)
102{
103  return mode == cudaRoundZero   ? __dmul_rz(a, b) :
104         mode == cudaRoundPosInf ? __dmul_ru(a, b) :
105         mode == cudaRoundMinInf ? __dmul_rd(a, b) :
106                                   __dmul_rn(a, b);
107}
108
109__DEVICE_DOUBLE_FUNCTIONS_DECL__ double dadd(double a, double b, enum cudaRoundMode mode)
110{
111  return mode == cudaRoundZero   ? __dadd_rz(a, b) :
112         mode == cudaRoundPosInf ? __dadd_ru(a, b) :
113         mode == cudaRoundMinInf ? __dadd_rd(a, b) :
114                                   __dadd_rn(a, b);
115}
116
117__DEVICE_DOUBLE_FUNCTIONS_DECL__ double dsub(double a, double b, enum cudaRoundMode mode)
118{
119  return mode == cudaRoundZero   ? __dsub_rz(a, b) :
120         mode == cudaRoundPosInf ? __dsub_ru(a, b) :
121         mode == cudaRoundMinInf ? __dsub_rd(a, b) :
122                                   __dsub_rn(a, b);
123}
124
125__DEVICE_DOUBLE_FUNCTIONS_DECL__ int double2int(double a, enum cudaRoundMode mode)
126{
127  return mode == cudaRoundNearest ? __double2int_rn(a) :
128         mode == cudaRoundPosInf  ? __double2int_ru(a) :
129         mode == cudaRoundMinInf  ? __double2int_rd(a) :
130                                    __double2int_rz(a);
131}
132
133__DEVICE_DOUBLE_FUNCTIONS_DECL__ unsigned int double2uint(double a, enum cudaRoundMode mode)
134{
135  return mode == cudaRoundNearest ? __double2uint_rn(a) :
136         mode == cudaRoundPosInf  ? __double2uint_ru(a) :
137         mode == cudaRoundMinInf  ? __double2uint_rd(a) :
138                                    __double2uint_rz(a);
139}
140
141__DEVICE_DOUBLE_FUNCTIONS_DECL__ long long int double2ll(double a, enum cudaRoundMode mode)
142{
143  return mode == cudaRoundNearest ? __double2ll_rn(a) :
144         mode == cudaRoundPosInf  ? __double2ll_ru(a) :
145         mode == cudaRoundMinInf  ? __double2ll_rd(a) :
146                                    __double2ll_rz(a);
147}
148
149__DEVICE_DOUBLE_FUNCTIONS_DECL__ unsigned long long int double2ull(double a, enum cudaRoundMode mode)
150{
151  return mode == cudaRoundNearest ? __double2ull_rn(a) :
152         mode == cudaRoundPosInf  ? __double2ull_ru(a) :
153         mode == cudaRoundMinInf  ? __double2ull_rd(a) :
154                                    __double2ull_rz(a);
155}
156
157__DEVICE_DOUBLE_FUNCTIONS_DECL__ double ll2double(long long int a, enum cudaRoundMode mode)
158{
159  return mode == cudaRoundZero   ? __ll2double_rz(a) :
160         mode == cudaRoundPosInf ? __ll2double_ru(a) :
161         mode == cudaRoundMinInf ? __ll2double_rd(a) :
162                                   __ll2double_rn(a);
163}
164
165__DEVICE_DOUBLE_FUNCTIONS_DECL__ double ull2double(unsigned long long int a, enum cudaRoundMode mode)
166{
167  return mode == cudaRoundZero   ? __ull2double_rz(a) :
168         mode == cudaRoundPosInf ? __ull2double_ru(a) :
169         mode == cudaRoundMinInf ? __ull2double_rd(a) :
170                                   __ull2double_rn(a);
171}
172
173__DEVICE_DOUBLE_FUNCTIONS_DECL__ double int2double(int a, enum cudaRoundMode mode)
174{
175  return (double)a;
176}
177
178__DEVICE_DOUBLE_FUNCTIONS_DECL__ double uint2double(unsigned int a, enum cudaRoundMode mode)
179{
180  return (double)a;
181}
182
183__DEVICE_DOUBLE_FUNCTIONS_DECL__ double float2double(float a, enum cudaRoundMode mode)
184{
185  return (double)a;
186}
187
188#undef __DEVICE_DOUBLE_FUNCTIONS_DECL__
189
190#endif /* __cplusplus && __CUDACC__ */
191
192#endif /* !__DEVICE_DOUBLE_FUNCTIONS_HPP__ */
193
194#if defined(__UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_DOUBLE_FUNCTIONS_HPP__)
195#undef __CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__
196#undef __UNDEF_CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS_DEVICE_DOUBLE_FUNCTIONS_HPP__
197#endif
198 
codekingpro/portable-devtools · Team Ai