diff options
Diffstat (limited to 'tests/linalg_test.cu')
-rw-r--r-- | tests/linalg_test.cu | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/linalg_test.cu b/tests/linalg_test.cu new file mode 100644 index 0000000..13d2ed0 --- /dev/null +++ b/tests/linalg_test.cu @@ -0,0 +1,84 @@ +//-*-c-*- + +extern "C" +{ + +__global__ void add(float3 *a, float3 *b, float3 *dest) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + dest[idx] = a[idx] + b[idx]; +} + +__global__ void addequal(float3 *a, float3 *b) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + a[idx] += b[idx]; +} + +__global__ void sub(float3 *a, float3 *b, float3 *dest) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + dest[idx] = a[idx] - b[idx]; +} + +__global__ void subequal(float3 *a, float3 *b) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + a[idx] -= b[idx]; +} + +__global__ void addfloat(float3 *a, float c, float3 *dest) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + dest[idx] = a[idx] + c; +} + +__global__ void addfloatequal(float3 *a, float c) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + a[idx] += c; +} + +__global__ void subfloat(float3 *a, float c, float3 *dest) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + dest[idx] = a[idx] - c; +} + +__global__ void subfloatequal(float3 *a, float c) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + a[idx] -= c; +} + +__global__ void mulfloat(float3 *a, float c, float3 *dest) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + dest[idx] = a[idx]*c; +} + +__global__ void mulfloatequal(float3 *a, float c) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + a[idx] *= c; +} + +__global__ void divfloat(float3 *a, float c, float3 *dest) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + dest[idx] = a[idx]/c; +} + +__global__ void divfloatequal(float3 *a, float c) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + a[idx] /= c; +} + +__global__ void dot(float3 *a, float3 *b, float* dest) +{ + int idx = blockIdx.x*blockDim.x + threadIdx.x; + dest[idx] = dot(a[idx],b[idx]); +} + +} // extern "c" |