23 #ifndef COMPAT_CUDA_CUDA_RUNTIME_H 24 #define COMPAT_CUDA_CUDA_RUNTIME_H 27 #define __global__ __attribute__((global)) 28 #define __device__ __attribute__((device)) 29 #define __device_builtin__ __attribute__((device_builtin)) 30 #define __align__(N) __attribute__((aligned(N))) 31 #define __inline__ __inline__ __attribute__((always_inline)) 33 #define max(a, b) ((a) > (b) ? (a) : (b)) 34 #define min(a, b) ((a) < (b) ? (a) : (b)) 35 #define abs(x) ((x) < 0 ? -(x) : (x)) 37 #define atomicAdd(a, b) (__atomic_fetch_add(a, b, __ATOMIC_SEQ_CST)) 57 typedef struct uint3 dim3;
66 unsigned char x, y, z,
w;
71 unsigned char x, y, z,
w;
80 #define GETCOMP(reg, comp) \ 81 asm("mov.u32 %0, %%" #reg "." #comp ";" : "=r"(tmp)); \ 84 #define GET(name, reg) static inline __device__ uint3 name() {\ 93 GET(getBlockIdx, ctaid)
94 GET(getBlockDim, ntid)
95 GET(getThreadIdx, tid)
98 #define blockIdx (getBlockIdx()) 99 #define blockDim (getBlockDim()) 100 #define threadIdx (getThreadIdx()) 103 #define make_uchar2(a, b) ((uchar2){.x = a, .y = b}) 104 #define make_ushort2(a, b) ((ushort2){.x = a, .y = b}) 105 #define make_uchar4(a, b, c, d) ((uchar4){.x = a, .y = b, .z = c, .w = d}) 106 #define make_ushort4(a, b, c, d) ((ushort4){.x = a, .y = b, .z = c, .w = d}) 109 #define TEX2D(type, ret) static inline __device__ void conv(type* out, unsigned a, unsigned b, unsigned c, unsigned d) {*out = (ret);} 111 TEX2D(
unsigned char,
a & 0xFF)
112 TEX2D(
unsigned short,
a & 0xFFFF)
123 unsigned ret1, ret2, ret3, ret4;
124 asm(
"tex.2d.v4.u32.f32 {%0, %1, %2, %3}, [%4, {%5, %6}];" :
125 "=r"(ret1),
"=r"(ret2),
"=r"(ret3),
"=r"(ret4) :
126 "l"(texObject),
"f"(x),
"f"(y));
127 conv(&ret, ret1, ret2, ret3, ret4);
static int conv(int samples, float **pcm, char *buf, int channels)
#define make_ushort2(a, b)
__device_builtin__ unsigned long long cudaTextureObject_t
static __device__ T tex2D(cudaTextureObject_t texObject, float x, float y)
#define make_uchar4(a, b, c, d)
#define __device_builtin__
#define make_uchar2(a, b)
#define make_ushort4(a, b, c, d)