will push to unison

This commit is contained in:
Brett Weiland 2024-05-09 01:27:55 -05:00
parent 882999e591
commit 51a8923eb3
7 changed files with 104 additions and 30 deletions

View File

@ -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

BIN
bruh

Binary file not shown.

BIN
build/main.o Normal file

Binary file not shown.

18
kernel.cu Normal file
View File

@ -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;
}

23
main.c
View File

@ -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;
}

41
main.cu
View File

@ -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;
}

View File

@ -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/*