Improved multicore and division

This commit is contained in:
José Carlos Cuevas 2013-08-30 18:51:32 +02:00
parent 77a2ed295a
commit 04eec8827a
8 changed files with 13 additions and 7 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -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!

1
main.c
View file

@ -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;

View file

@ -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

Binary file not shown.

BIN
test

Binary file not shown.