diff --git a/.Makefile.swp b/.Makefile.swp deleted file mode 100644 index ca472e6..0000000 Binary files a/.Makefile.swp and /dev/null differ diff --git a/.mandel_classic.c.swp b/.mandel_classic.c.swp index a715f0d..59426f6 100644 Binary files a/.mandel_classic.c.swp and b/.mandel_classic.c.swp differ diff --git a/.mandelbrot_kernel.cl.swp b/.mandelbrot_kernel.cl.swp deleted file mode 100644 index 8db853b..0000000 Binary files a/.mandelbrot_kernel.cl.swp and /dev/null differ diff --git a/Makefile b/Makefile index 954d8c4..4245252 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,8 @@ CC=gcc SDLFLAGS=$(shell sdl-config --cflags) # Comment this line and uncomment the next to get Julia fractals -CFLAGS=-c -Wall -O2 $(SDLFLAGS) -# CFLAGS=-c -Wall -O2 -DJULIA $(SDLFLAGS) +# CFLAGS=-c -Wall -O2 $(SDLFLAGS) +CFLAGS=-c -Wall -O2 -DJULIA $(SDLFLAGS) # CFLAGS=-c -Wall -ggdb $(SDLFLAGS) # Libs! diff --git a/main.c b/main.c index 213c099..a99d0b6 100644 --- a/main.c +++ b/main.c @@ -42,7 +42,6 @@ int main(int argn, char **argv) { blue_scale[i] = 255 - i; } - // Load the kernel source code into the array source_str FILE *fp; char *source_str; diff --git a/mandel_classic.c b/mandel_classic.c index beabd01..4f9b0c0 100644 --- a/mandel_classic.c +++ b/mandel_classic.c @@ -243,6 +243,8 @@ int julia_point(int res_x, int res_y, int image_x, int image_y, float zoom, int } } + +// Splits the image in pieces and calls the corresponding algorithm void *thread_launcher(void *arguments) { piece_args *args; @@ -251,9 +253,13 @@ void *thread_launcher(void *arguments) int x,y, small_res_x, small_res_y, init_x, init_y, limit_x, limit_y; int iteration, split, piece_x, piece_y; - if(args->total_threads != 1) + if(args->total_threads > 2) { - split = args->total_threads / 2; + split = sqrt(args->total_threads); + } + else if (args->total_threads == 2) + { + split = 2; } else { @@ -311,9 +317,10 @@ int main(int argn, char **argv) int res_x = 800; int res_y = 600; - int number_threads = get_cpus(); + int number_cores = get_cpus(); + int number_threads = number_cores * number_cores; - printf("Number of threads autodetect: %d\n", number_threads); + printf("Number of CPUs/cores autodetected: %d\n", number_cores); #ifdef CACHE // Init our cached points diff --git a/mandelclassic b/mandelclassic index 389c684..3cebd92 100755 Binary files a/mandelclassic and b/mandelclassic differ diff --git a/test b/test index 4db960e..3c98183 100755 Binary files a/test and b/test differ