custom qlen as parameter
This commit is contained in:
parent
692a69a9c4
commit
8704b182c3
5 changed files with 23 additions and 12 deletions
|
@ -3,4 +3,4 @@
|
||||||
/* Lance le benchmark avec mandelbrot (TP10)
|
/* Lance le benchmark avec mandelbrot (TP10)
|
||||||
*
|
*
|
||||||
* Renvoie le temps d'exécution */
|
* Renvoie le temps d'exécution */
|
||||||
double benchmark_mandelbrot(int, int);
|
double benchmark_mandelbrot(int, int, int);
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
/* Lance le benchmark avec quicksort (fournis)
|
/* Lance le benchmark avec quicksort (fournis)
|
||||||
*
|
*
|
||||||
* Renvoie le temps d'exécution */
|
* Renvoie le temps d'exécution */
|
||||||
double benchmark_quicksort(int, int);
|
double benchmark_quicksort(int, int, int);
|
||||||
|
|
10
src/main.c
10
src/main.c
|
@ -11,13 +11,14 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int serial = 0;
|
int serial = 0;
|
||||||
int nthreads = -1;
|
int nthreads = -1;
|
||||||
|
int qlen = -1;
|
||||||
|
|
||||||
int quicksort = 0;
|
int quicksort = 0;
|
||||||
int mandelbrot = 0;
|
int mandelbrot = 0;
|
||||||
double delay;
|
double delay;
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
while((opt = getopt(argc, argv, "qmst:")) != -1) {
|
while((opt = getopt(argc, argv, "qmst:n:")) != -1) {
|
||||||
if(opt < 0) {
|
if(opt < 0) {
|
||||||
goto usage;
|
goto usage;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +36,9 @@ main(int argc, char *argv[])
|
||||||
case 't':
|
case 't':
|
||||||
nthreads = atoi(optarg);
|
nthreads = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
qlen = atoi(optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
goto usage;
|
goto usage;
|
||||||
}
|
}
|
||||||
|
@ -44,9 +48,9 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if(quicksort) {
|
if(quicksort) {
|
||||||
delay = benchmark_quicksort(serial, nthreads);
|
delay = benchmark_quicksort(serial, nthreads, qlen);
|
||||||
} else if(mandelbrot) {
|
} else if(mandelbrot) {
|
||||||
delay = benchmark_mandelbrot(serial, nthreads);
|
delay = benchmark_mandelbrot(serial, nthreads, qlen);
|
||||||
} else {
|
} else {
|
||||||
goto usage;
|
goto usage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,15 +175,19 @@ draw_serial(unsigned int *image)
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
benchmark_mandelbrot(int serial, int nthreads)
|
benchmark_mandelbrot(int serial, int nthreads, int qlen)
|
||||||
{
|
{
|
||||||
unsigned int *image;
|
unsigned int *image;
|
||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
double delay;
|
double delay;
|
||||||
int rc;
|
int rc;
|
||||||
int size = WIDTH * HEIGHT;
|
int n = WIDTH * HEIGHT;
|
||||||
|
|
||||||
if(!(image = malloc(WIDTH * HEIGHT * sizeof(unsigned int)))) {
|
if(qlen <= 0) {
|
||||||
|
qlen = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(image = malloc(n * sizeof(unsigned int)))) {
|
||||||
perror("Image allocation");
|
perror("Image allocation");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +197,7 @@ benchmark_mandelbrot(int serial, int nthreads)
|
||||||
if(serial) {
|
if(serial) {
|
||||||
draw_serial(image);
|
draw_serial(image);
|
||||||
} else {
|
} else {
|
||||||
rc = sched_init(nthreads, size, draw,
|
rc = sched_init(nthreads, qlen, draw,
|
||||||
new_mandelbrot_args(image, 0, 0, WIDTH, HEIGHT));
|
new_mandelbrot_args(image, 0, 0, WIDTH, HEIGHT));
|
||||||
assert(rc >= 0);
|
assert(rc >= 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ quicksort(void *closure, struct scheduler *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
benchmark_quicksort(int serial, int nthreads)
|
benchmark_quicksort(int serial, int nthreads, int qlen)
|
||||||
{
|
{
|
||||||
int *a;
|
int *a;
|
||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
|
@ -113,6 +113,10 @@ benchmark_quicksort(int serial, int nthreads)
|
||||||
int rc;
|
int rc;
|
||||||
int n = 10 * 1024 * 1024;
|
int n = 10 * 1024 * 1024;
|
||||||
|
|
||||||
|
if(qlen <= 0) {
|
||||||
|
qlen = (n + 127) / 128;
|
||||||
|
}
|
||||||
|
|
||||||
a = malloc(n * sizeof(int));
|
a = malloc(n * sizeof(int));
|
||||||
|
|
||||||
unsigned long long s = 0;
|
unsigned long long s = 0;
|
||||||
|
@ -126,8 +130,7 @@ benchmark_quicksort(int serial, int nthreads)
|
||||||
if(serial) {
|
if(serial) {
|
||||||
quicksort_serial(a, 0, n - 1);
|
quicksort_serial(a, 0, n - 1);
|
||||||
} else {
|
} else {
|
||||||
rc = sched_init(nthreads, (n + 127) / 128, quicksort,
|
rc = sched_init(nthreads, qlen, quicksort, new_args(a, 0, n - 1));
|
||||||
new_args(a, 0, n - 1));
|
|
||||||
assert(rc >= 0);
|
assert(rc >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue