Sha256: ed8dcebe96c7a7702404444bdfaae6555173d7993831cef34828c3b636d7a7d1

Contents?: true

Size: 755 Bytes

Versions: 20

Compression:

Stored size: 755 Bytes

Contents

#ifndef CUMO_UINT_MACRO_KERNEL_H
#define CUMO_UINT_MACRO_KERNEL_H

#include "xint_macro_kernel.h"

#define m_abs(x)     (x)
#define m_sign(x)    (((x)==0) ? 0:1)

__host__ __device__ static inline dtype int_reciprocal(dtype x) {
    switch (x) {
    case 1:
        return 1;
    case 0:
        return 0; // as CUDA kernel 1/0 results in 0.
        //rb_raise(rb_eZeroDivError, "divided by 0");
    default:
        return 0;
    }
}

__device__ static dtype pow_int(dtype x, int p)
{
    dtype r = m_one;
    switch(p) {
    case 0: return 1;
    case 1: return x;
    case 2: return x*x;
    case 3: return x*x*x;
    }
    while (p) {
        if (p&1) r *= x;
        x *= x;
        p >>= 1;
    }
    return r;
}

#endif // CUMO_UINT_MACRO_KERNEL_H

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
cumo-0.4.3 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.4.2 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.4.1 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.4.0 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.3.5 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.3.4 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.3.3 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.3.2 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.3.1 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.3.0 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.3.0.pre1 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.2.5 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.2.4 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.2.3 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.2.2 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.2.1 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.2.0 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.1.2 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.1.1 ext/cumo/include/cumo/types/uint_macro_kernel.h
cumo-0.1.0 ext/cumo/include/cumo/types/uint_macro_kernel.h