From 1dedcb258f9fe4c99fa21c6edd28efe3a2bce6a7 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 5 Dec 2024 19:29:56 -0800 Subject: Use gridDim --- julia/julia.cu | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/julia/julia.cu b/julia/julia.cu index f3ecb80..ed7b00a 100644 --- a/julia/julia.cu +++ b/julia/julia.cu @@ -39,7 +39,7 @@ __device__ int julia(int width, int height, int x, int y) { return 1; } -__global__ void juliaMain(int width, int height, Pixel* image) { +__global__ void juliaMain(Pixel* image) { const int x = blockIdx.x; const int y = blockIdx.y; @@ -47,9 +47,9 @@ __global__ void juliaMain(int width, int height, Pixel* image) { constexpr Pixel juliaColour{228, 192, 135}; const Pixel pixel = - julia(width, height, x, y) == 1 ? juliaColour : background; + julia(gridDim.x, gridDim.y, x, y) == 1 ? juliaColour : background; - image[y * width + x] = pixel; + image[y * gridDim.x + x] = pixel; } bool write_pbm(const Pixel* image, int width, int height, const char* path) { @@ -85,7 +85,7 @@ int main(int argc, const char** argv) { goto cleanup; } - juliaMain<<>>(width, height, image_dev); + juliaMain<<>>(image_dev); if (cudaMemcpy( image_host, image_dev, image_size_bytes, cudaMemcpyDeviceToHost) != -- cgit v1.2.3