Added test script
parent
16498d57e4
commit
25cda17921
|
@ -18,11 +18,13 @@ push:
|
|||
run_remote:
|
||||
@test -n "$(ngpus)" || (echo "ngpus is not set"; exit 1)
|
||||
@test -n "$(ntasks)" || (echo "ntasks is not set"; exit 1)
|
||||
@test -n "$(width)" || (echo "width is not set"; exit 1)
|
||||
@test -n "$(height)" || (echo "height is not set"; exit 1)
|
||||
|
||||
@echo "Compiling..."
|
||||
ssh nsc 'cd $(DESTINATION); make clean;$(MODULE_LOAD); make $(PROGRAM_NAME)'
|
||||
@echo "Running on $(ngpus) GPUs with $(ntasks) tasks"
|
||||
ssh nsc '$(MODULE_LOAD); srun --reservation=fri --ntasks=$(ntasks) -G$(ngpus) $(DESTINATION)/$(PROGRAM_NAME)'
|
||||
ssh nsc '$(MODULE_LOAD); srun --reservation=fri --ntasks=$(ntasks) -G$(ngpus) $(DESTINATION)/$(PROGRAM_NAME) $(width) $(height)'
|
||||
|
||||
download_output:
|
||||
rsync -a --progress nsc:$(DESTINATION)/mandelbrot.png .
|
||||
|
|
17
dn8/cuda.cu
17
dn8/cuda.cu
|
@ -7,13 +7,13 @@
|
|||
|
||||
#include "helper_cuda.h"
|
||||
|
||||
#define BLOCK_SIZE 4
|
||||
#define BLOCK_SIZE 16
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
|
||||
|
||||
__global__ void printGPU(unsigned char *img, int width, int height, int channels)
|
||||
__global__ void mandelbrotGPU(unsigned char *img, int width, int height, int channels)
|
||||
{
|
||||
|
||||
int global_X = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
|
@ -44,7 +44,6 @@ __global__ void printGPU(unsigned char *img, int width, int height, int channels
|
|||
x = xtemp;
|
||||
iter++;
|
||||
}
|
||||
//izracunamo barvo (magic: http://linas.org/art-gallery/escape/smooth.html)
|
||||
color = 1.0 + iter - log(log(sqrt(x*x + y * y))) / log(2.0);
|
||||
color = (8 * max * color) / max_iteration;
|
||||
if (color > max)
|
||||
|
@ -61,11 +60,15 @@ __global__ void printGPU(unsigned char *img, int width, int height, int channels
|
|||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
// take params
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
// first argument is width
|
||||
int width = atoi(argv[1]);
|
||||
// second argument is height
|
||||
int height = atoi(argv[2]);
|
||||
|
||||
int width = 1024;
|
||||
int height = 1024;
|
||||
int channels = 4;
|
||||
|
||||
size_t data_size = width * height * channels * sizeof(unsigned char);
|
||||
|
@ -88,7 +91,7 @@ int main(void)
|
|||
cudaEventRecord(start);
|
||||
|
||||
// Zazenemo funkcijo na GPE
|
||||
printGPU<<<gridSize, blockSize>>>(img_d, width, height, channels);
|
||||
mandelbrotGPU<<<gridSize, blockSize>>>(img_d, width, height, channels);
|
||||
|
||||
// Copy image to host
|
||||
checkCudaErrors(cudaMemcpy(img_h, img_d, data_size, cudaMemcpyDeviceToHost));
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 995 KiB |
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# create array of numbers
|
||||
WIDTHS=( 640 800 1600 1920 3840 )
|
||||
HEIGHTS=( 480 600 900 1080 2160 )
|
||||
GPUS=(1 2 4)
|
||||
|
||||
# loop through WIDTHS
|
||||
for WIDTH in "${WIDTHS[@]}"
|
||||
do
|
||||
# loop through HEIGHTS
|
||||
for HEIGHT in "${HEIGHTS[@]}"
|
||||
do
|
||||
# loop through GPUS
|
||||
for GPU in "${GPUS[@]}"
|
||||
do
|
||||
ret=$(make run_remote ntasks=1 ngpus=$GPU width=$WIDTH height=$HEIGHT | grep time | awk '{print $7}')
|
||||
echo "Finished $WIDTH x $HEIGHT with $GPU GPUs --> time: $ret milliseconds"
|
||||
done
|
||||
done
|
||||
done
|
Loading…
Reference in New Issue