summaryrefslogtreecommitdiff
path: root/Canvas/cuda/CalculateCanvasGPU.cu
diff options
context:
space:
mode:
authorAndrew Guschin <guschin.drew@gmail.com>2022-04-02 09:13:33 +0400
committerAndrew Guschin <guschin.drew@gmail.com>2022-04-02 09:13:33 +0400
commit806a1e093eeac8b426b20717c14260c9cb896798 (patch)
tree7b6e1a01958269ce78b9716461a9fa4c05d3dc5e /Canvas/cuda/CalculateCanvasGPU.cu
parent15ccb946f43283bfc91d80ddf012d9ae2a0333ed (diff)
Removed CUDA files and changed build system to premakeremake
Diffstat (limited to 'Canvas/cuda/CalculateCanvasGPU.cu')
-rw-r--r--Canvas/cuda/CalculateCanvasGPU.cu52
1 files changed, 0 insertions, 52 deletions
diff --git a/Canvas/cuda/CalculateCanvasGPU.cu b/Canvas/cuda/CalculateCanvasGPU.cu
deleted file mode 100644
index c8c6fad..0000000
--- a/Canvas/cuda/CalculateCanvasGPU.cu
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "CalculateCanvasGPU.h"
-
-__global__
-void calculate(unsigned char* canvas, int width, cuda_point* points, int nPoints)
-{
- int canvasX = blockIdx.x * blockDim.x + threadIdx.x;
- int canvasY = blockIdx.y * blockDim.y + threadIdx.y;
-
- int pathX, pathY;
- int length_squared;
- double f = 0;
-
- for (int i = 0; i < nPoints; i++)
- {
- pathX = points[i].x - canvasX;
- pathY = points[i].y - canvasY;
-
- length_squared = pathX * pathX + pathY * pathY;
- f += (1e5 * 20) / (float) length_squared;
- }
-
- int l = (int) f;
- if (l > 255) l = 255;
-
- canvas[canvasY * width * 3 + canvasX * 3 + 0] = l;
- canvas[canvasY * width * 3 + canvasX * 3 + 1] = 0;
- canvas[canvasY * width * 3 + canvasX * 3 + 2] = 0;
-}
-
-void generate_canvas(int width, int height, unsigned char* canvas, cuda_point* points, int nPoints)
-{
- const int canvasSize = width * height * 3 * sizeof(unsigned char);
- const int pointsSize = nPoints * sizeof(cuda_point);
-
- unsigned char* gpuCanvas;
- cuda_point* gpuPoints;
-
- cudaMalloc((void**) &gpuCanvas, canvasSize);
- cudaMalloc((void**) &gpuPoints, pointsSize);
-
- cudaMemcpy(gpuCanvas, canvas, canvasSize, cudaMemcpyHostToDevice);
- cudaMemcpy(gpuPoints, points, pointsSize, cudaMemcpyHostToDevice);
-
- dim3 threadsPerBlock(16, 16);
- dim3 numBlocks(width / threadsPerBlock.x, height / threadsPerBlock.y);
- calculate<<<numBlocks, threadsPerBlock>>>(gpuCanvas, width, gpuPoints, nPoints);
-
- cudaMemcpy(canvas, gpuCanvas, canvasSize, cudaMemcpyDeviceToHost);
-
- cudaFree(gpuCanvas);
- cudaFree(gpuPoints);
-}