summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Weiland <brett_weiland@gmail.com>2024-05-09 01:27:55 -0500
committerBrett Weiland <brett_weiland@gmail.com>2024-05-09 01:27:55 -0500
commit51a8923eb33ad53a36271b1e0b3489d033178337 (patch)
tree6c2017a8210f43848e338e6065e0964ee20cf115
parent882999e591ece292d5ddbc87020ba70b3d2d1658 (diff)
will push to unison
-rw-r--r--.gdb_history42
-rwxr-xr-xbruhbin17896 -> 0 bytes
-rw-r--r--build/main.obin0 -> 32680 bytes
-rw-r--r--kernel.cu18
-rw-r--r--main.c23
-rw-r--r--main.cu41
-rw-r--r--makefile10
7 files changed, 104 insertions, 30 deletions
diff --git a/.gdb_history b/.gdb_history
index 2f823ae..9cf0bf1 100644
--- a/.gdb_history
+++ b/.gdb_history
@@ -12,3 +12,45 @@ x *=image.data
print image
context
quit
+quit
+break main.c:27
+exit
+break main.cu:27
+r
+context
+exit()
+exit
+ls
+break main.cu:27
+r
+print image
+print image.data
+print *image.data
+print (uint32_t)image.data
+print (uint32_t)*image.data
+x 0x55555561a140
+print (uint32_t&)*image.data
+print (uint32_t)*image.data
+print (image.data
+print image.data
+x 0x55555561a140
+hexdump 0x55555561a140
+aquit
+quit
+break main.cu:27
+r
+print image.data
+print (uint32_t*)image.data
+print *((uint32_t*)image.data)
+print/x *((uint32_t*)image.data)
+next
+print/x *((uint32_t*)image.data)
+print image
+quit
+break main.cu:27
+r
+print image
+next
+print image
+hexdump 0x55555561a140
+quit
diff --git a/bruh b/bruh
deleted file mode 100755
index e25e187..0000000
--- a/bruh
+++ /dev/null
Binary files differ
diff --git a/build/main.o b/build/main.o
new file mode 100644
index 0000000..7add5ec
--- /dev/null
+++ b/build/main.o
Binary files differ
diff --git a/kernel.cu b/kernel.cu
new file mode 100644
index 0000000..c00056a
--- /dev/null
+++ b/kernel.cu
@@ -0,0 +1,18 @@
+#include <curand.h>
+#include <stdint.h>
+#include <stdio.h>
+#include "include/helper_math.h"
+
+__global__ void test_image(uint8_t *image) {
+ int2 unnormalized_coordinates = make_int2(blockDim.x, blockDim.y) * make_int2(blockIdx.x, blockIdx.y) + make_int2(threadIdx.x, threadIdx.y);
+ int2 img_res = make_int2(blockDim.x, blockDim.y) * make_int2(gridDim.x, gridDim.y);
+ size_t img_index = (unnormalized_coordinates.y * img_res.y) + unnormalized_coordinates.x;
+ //uint8_t pixel_val = (img_index / (img_res.x * img_res.y)) * 255;
+ uint8_t pixel_val = 0xff;
+ //if(img_index == 1) printf("%i\n", img_index);
+ print(img_index)
+ image[img_index] = 0xff;
+ image[img_index+1] = pixel_val;
+ image[img_index+2] = pixel_val;
+ image[img_index+3] = 0xff;
+}
diff --git a/main.c b/main.c
deleted file mode 100644
index b5dda5c..0000000
--- a/main.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <stdio.h>
-#include "raylib.h"
-
-int main() {
- const int size_x = 1920;
- const int size_y = 1080;
- Image image = GenImageColor(size_x, size_y, BLUE);
-
- InitWindow(size_x, size_y, "cuda teseteroni");
-
-
-
-
- if(!IsWindowFullscreen()) ToggleFullscreen();
-
- while(!WindowShouldClose()) {
- BeginDrawing();
- DrawTexture(LoadTextureFromImage(image), 0, 0, WHITE);
- EndDrawing();
- }
-
- return 0;
-}
diff --git a/main.cu b/main.cu
index 9063a8f..2b1b180 100644
--- a/main.cu
+++ b/main.cu
@@ -1,6 +1,39 @@
-#include "include/helper_math.h"
-__global__ void random_noise(double **image) {
- int2 unnormalized_coordinates = make_int2(blockDim.x, blockDim.y) * make_int2(blockIdx.x, blockIdx.y) + make_int2(threadIdx.x, threadIdx.y);
- int2 img_res = make_int2(blockDim.x, blockDim.y) * make_int2(gridDim.x, gridDim.y);//could move out of kernel for performance boost
+#include <stdio.h>
+#include <stdint.h>
+#include <cuda_runtime.h>
+#include <string.h>
+
+#include "raylib.h"
+
+__global__ void test_image(uint8_t *image);
+
+int main() {
+ const int size_x = 100;
+ const int size_y = 100;
+ uint8_t *image_d;
+ Image image = GenImageColor(size_x, size_y, BLUE);
+ SetTraceLogLevel(LOG_ERROR);
+
+ InitWindow(size_x, size_y, "cuda teseteroni");
+
+ cudaMalloc((void **)&image_d, 100 * 100 * 4);
+ test_image<<<1, dim3(3,3)>>>(image_d);
+ cudaDeviceSynchronize();
+ //for(;;);
+ //if(!IsWindowFullscreen()) ToggleFullscreen();
+
+ while(!WindowShouldClose()) {
+ cudaMemcpy(image.data, (void **)image_d, 100 * 100 * 4, cudaMemcpyDeviceToHost);
+ //memset(image.data, (int32_t)0x0000ff, 100 * 100 * 4);
+ BeginDrawing();
+ DrawTexture(LoadTextureFromImage(image), 0, 0, WHITE);
+ EndDrawing();
+ }
+
+
+
+
+
+ return 0;
}
diff --git a/makefile b/makefile
index c2e4c4e..b733c07 100644
--- a/makefile
+++ b/makefile
@@ -1,9 +1,13 @@
LIBS = -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
$CC = gcc
+INC = -I /opt/cuda/include
make:
- $(CC) $(LIBS) main.c -o build/main.o
- nvcc --compile main.cu -o build/kernel.o
- gcc -o indigo_worlds main.o kernel.o
+ nvcc $(LIBS) $(INC) --debug -c main.cu -o build/main.o
+ nvcc --device-debug --compile kernel.cu -o build/kernel.o
+ nvcc $(LIBS) -o build/indigo_worlds build/main.o build/kernel.o
+
+run:
+ build/indigo_worlds
clean:
rm -r build/*