MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / oneMinusGetHalf01

Function oneMinusGetHalf01

src/backend/cuda/kernel/random_engine.hpp:80–92  ·  view source on GitHub ↗

Generates rationals in (0, 1]

Source from the content-addressed store, hash-verified

78
79// Generates rationals in (0, 1]
80__device__ static __half oneMinusGetHalf01(uint num) {
81 // convert to ushort before the min operation
82 ushort v = min(max_int_before_infinity, ushort(num));
83#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 530
84 return (1.0f - __half2float(__hfma(__ushort2half_rn(v), HALF_FACTOR,
85 HALF_HALF_FACTOR)));
86#else
87 __half out = __ushort_as_half(0x3c00u) /*1.0h*/ -
88 __hfma(__ushort2half_rn(v), HALF_FACTOR, HALF_HALF_FACTOR);
89 if (__hisinf(out)) printf("val: %d ushort: %d\n", num, v);
90 return out;
91#endif
92}
93
94// Generates rationals in (0, 1]
95__device__ static __half getHalf01(uint num) {

Callers 2

writeOut128BytesFunction · 0.70
partialWriteOut128BytesFunction · 0.70

Calls 2

__hfmaFunction · 0.85
minFunction · 0.50

Tested by

no test coverage detected