From 0bdb7195de084a3e3c361f8274ee516b89c39e2f Mon Sep 17 00:00:00 2001 From: Martin Opat Date: Thu, 14 Nov 2024 12:17:09 +0100 Subject: [PATCH] Added a few clearing-up code tweaks --- test.cu => deprecated_test.cu | 0 hello_world.cu | 11 ----------- test_heavy.cu | 5 +++-- 3 files changed, 3 insertions(+), 13 deletions(-) rename test.cu => deprecated_test.cu (100%) diff --git a/test.cu b/deprecated_test.cu similarity index 100% rename from test.cu rename to deprecated_test.cu diff --git a/hello_world.cu b/hello_world.cu index d5941ee..a3b2c6a 100644 --- a/hello_world.cu +++ b/hello_world.cu @@ -1,25 +1,14 @@ #include #include -#define cudaCheckError() { \ - cudaError_t e = cudaGetLastError(); \ - if (e != cudaSuccess) { \ - printf("CUDA error %s:%d: %s\n", __FILE__, __LINE__, \ - cudaGetErrorString(e)); \ - exit(EXIT_FAILURE); \ - } \ -} - __global__ void hello_from_gpu() { printf("Hello from GPU!\n"); } int main() { hello_from_gpu<<<1, 1>>>(); - cudaCheckError(); cudaDeviceSynchronize(); - cudaCheckError(); // Reset device cudaDeviceReset(); diff --git a/test_heavy.cu b/test_heavy.cu index 8e9cd2c..2110eab 100644 --- a/test_heavy.cu +++ b/test_heavy.cu @@ -65,9 +65,10 @@ __global__ void renderKernel(unsigned char* framebuffer, Sphere* spheres, int nu Vec3 rayOrigin(0, 0, 0); Vec3 colCum(0, 0, 0); + double spp = static_cast(SAMPLES_PER_PIXEL); for (int sample = 0; sample < SAMPLES_PER_PIXEL; sample++) { - double u = (x + (sample / static_cast(SAMPLES_PER_PIXEL)) - WIDTH / 2.0) / WIDTH; - double v = (y + (sample / static_cast(SAMPLES_PER_PIXEL)) - HEIGHT / 2.0) / HEIGHT; + double u = (x + (sample / spp) - WIDTH / 2.0) / WIDTH; + double v = (y + (sample / spp) - HEIGHT / 2.0) / HEIGHT; Vec3 rayDir(u, v, 1.0); rayDir = rayDir.normalize();