summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-01-22 13:09:29 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-01-22 13:09:29 +0100
commitda973be545d6da3b2d42023f96bcfd79f751eba9 (patch)
treeb1b86be33ff9e65e6979a0a3a04a391338311f5b /tests
parentc4923c47ffc2309fc3844be80ee0d8392e2fad2b (diff)
downloadcrep-da973be545d6da3b2d42023f96bcfd79f751eba9.tar.gz
Add CUDA grammar
Diffstat (limited to 'tests')
-rw-r--r--tests/test.cu26
-rw-r--r--tests/test.cuh19
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/test.cu b/tests/test.cu
new file mode 100644
index 0000000..9bd49d4
--- /dev/null
+++ b/tests/test.cu
@@ -0,0 +1,26 @@
+#include <stdio.h>
+
+__global__ void vectorAdd(const float *A, const float *B, float *C, int numElements) {
+ int i = blockDim.x * blockIdx.x + threadIdx.x;
+ if (i < numElements) {
+ C[i] = A[i] + B[i];
+ }
+}
+
+__device__ int get_thread_id() {
+ return threadIdx.x;
+}
+
+__host__ void init_vectors(float *A, float *B, int n) {
+ for (int i = 0; i < n; ++i) {
+ A[i] = rand() / (float)RAND_MAX;
+ B[i] = rand() / (float)RAND_MAX;
+ }
+}
+
+int main(void) {
+ int numElements = 50000;
+ size_t size = numElements * sizeof(float);
+ printf("[Vector addition of %d elements]\n", numElements);
+ return 0;
+}
diff --git a/tests/test.cuh b/tests/test.cuh
new file mode 100644
index 0000000..895f183
--- /dev/null
+++ b/tests/test.cuh
@@ -0,0 +1,19 @@
+#ifndef TEST_CUH
+#define TEST_CUH
+
+struct Point {
+ float x;
+ float y;
+ float z;
+};
+
+class Dim3 {
+public:
+ int x;
+ int y;
+ int z;
+};
+
+__device__ void device_func() {}
+
+#endif