diff --git a/examples/mkplots_tasks.m b/examples/mkplots_tasks.m index 757e96c1c36ba9f40b895ca93b3d5a89cdb12cc9..5b53886245739cd0f0bf42ab4d546e7c26aa962b 100644 --- a/examples/mkplots_tasks.m +++ b/examples/mkplots_tasks.m @@ -84,7 +84,7 @@ print -depsc2 tasks_qr_dynamic.eps -%% Plot the tiled Barnes-Hutt tasks +%% Plot the tiled Barnes-Hut tasks %% Plot the task timelines for tasks allocation % Load the data @@ -112,7 +112,7 @@ hold off; xlabel('time (ms)'); ylabel('core ID'); set(gca,'YTick',1:(max(tasks(:,1))+1)) -title('Barnes-Hutt tasks'); +title('Barnes-Hut tasks'); axis([ 0 , max( tasks(:,3) + tasks(:,4) ) , -0.5 , nr_cores-0.5 ]); % Print this plot diff --git a/examples/test.c b/examples/test.c index ffb04df2112c5cfb58b94f5765c49cf99013e024..ee91a807a3b6e2044634902cb3ae211da7bb1f11 100644 --- a/examples/test.c +++ b/examples/test.c @@ -62,7 +62,7 @@ void matmul ( int m , int n , int k , double *a , int lda , double *b , int ldb void test2 ( int m , int n , int k , int nr_threads ) { int i, j, kk, qid, data[3], *d, tid, rid; - struct sched s; + struct qsched s; struct task *t; double *a, *b, *c, *res, err = 0.0, irm = 1.0/RAND_MAX; ticks tic_task, toc_task, tic_ref, toc_ref; @@ -72,8 +72,8 @@ void test2 ( int m , int n , int k , int nr_threads ) { "C_ij = A_i: * B_:j, with tasks for each k where C_ij += A_ik*B_kj." ); /* Init the sched. */ - bzero( &s , sizeof(struct sched) ); - sched_init( &s , nr_threads , m * n ); + bzero( &s , sizeof(struct qsched) ); + qsched_init( &s , nr_threads , m * n ); /* Allocate the matrices. */ if ( ( a = (double *)malloc( sizeof(double) * m * k * 32 * 32 ) ) == NULL || @@ -93,17 +93,17 @@ void test2 ( int m , int n , int k , int nr_threads ) { /* Build a task for each tile of the matrix c. */ for ( i = 0 ; i < m ; i++ ) for ( j = 0 ; j < n ; j++ ) { - rid = sched_addres( &s , -1 ); + rid = qsched_addres( &s , -1 ); data[0] = i; data[1] = j; for ( kk = 0 ; kk < k ; kk++ ) { data[2] = kk; - tid = sched_newtask( &s , 1 , 0 , 0 , data , 3*sizeof(int) , 1 ); - sched_addlock( &s , tid , rid ); + tid = qsched_newtask( &s , 1 , task_flag_none , data , 3*sizeof(int) , 1 ); + qsched_addlock( &s , tid , rid ); } } /* Prepare the sched for execution. */ - sched_prepare( &s ); + qsched_prepare( &s ); /* Parallel loop. */ tic_task = getticks(); @@ -117,13 +117,13 @@ void test2 ( int m , int n , int k , int nr_threads ) { while ( 1 ) { /* Get a task, break if unsucessful. */ - if ( ( t = sched_gettask( &s , qid ) ) == NULL ) + if ( ( t = qsched_gettask( &s , qid ) ) == NULL ) break; /* Decode and execute the task. */ switch ( t->type ) { case 1: - d = sched_getdata( &s , t ); + d = qsched_getdata( &s , t ); // message( "thread %i working on block [ %i , %i ] with k=%i, lock[0]=%i." , qid , d[0] , d[1] , d[2] , t->locks[0] ); fflush(stdout); matmul( 32 , 32 , 32 , &a[ d[2]*32*m*32 + d[0]*32 ] , m*32 , &b[ k*32*d[1]*32 + d[2]*32 ] , k*32 , &c[ d[0]*32 + m*32*d[1]*32 ] , m*32 ); break; @@ -132,7 +132,7 @@ void test2 ( int m , int n , int k , int nr_threads ) { } /* Clean up afterwards. */ - sched_done( &s , t ); + qsched_done( &s , t ); } /* main loop. */ @@ -158,7 +158,7 @@ void test2 ( int m , int n , int k , int nr_threads ) { } */ /* Clean up. */ - sched_free( &s ); + qsched_free( &s ); free( a ); free( b ); free( c ); @@ -177,7 +177,7 @@ void test2 ( int m , int n , int k , int nr_threads ) { void test1 ( int m , int n , int k , int nr_threads ) { int i, j, qid, data[2], *d, tid, rid; - struct sched s; + struct qsched s; struct task *t; double *a, *b, *c, *res, err = 0.0, irm = 1.0/RAND_MAX; ticks tic_task, toc_task, tic_ref, toc_ref; @@ -187,8 +187,8 @@ void test1 ( int m , int n , int k , int nr_threads ) { "C_ij = A_i: * B_:j, with a single task per C_ij." ); /* Init the sched. */ - bzero( &s , sizeof(struct sched) ); - sched_init( &s , nr_threads , m * n ); + bzero( &s , sizeof(struct qsched) ); + qsched_init( &s , nr_threads , m * n ); /* Allocate the matrices. */ if ( ( a = (double *)malloc( sizeof(double) * m * k * 32 * 32 ) ) == NULL || @@ -209,13 +209,13 @@ void test1 ( int m , int n , int k , int nr_threads ) { for ( i = 0 ; i < m ; i++ ) for ( j = 0 ; j < n ; j++ ) { data[0] = i; data[1] = j; - rid = sched_addres( &s , -1 ); - tid = sched_newtask( &s , 1 , 0 , 0 , data , 2*sizeof(int) , 1 ); - sched_addlock( &s , tid , rid ); + rid = qsched_addres( &s , -1 ); + tid = qsched_newtask( &s , 1 , task_flag_none , data , 2*sizeof(int) , 1 ); + qsched_addlock( &s , tid , rid ); } /* Prepare the sched for execution. */ - sched_prepare( &s ); + qsched_prepare( &s ); /* Parallel loop. */ tic_task = getticks(); @@ -229,13 +229,13 @@ void test1 ( int m , int n , int k , int nr_threads ) { while ( 1 ) { /* Get a task, break if unsucessful. */ - if ( ( t = sched_gettask( &s , qid ) ) == NULL ) + if ( ( t = qsched_gettask( &s , qid ) ) == NULL ) break; /* Decode and execute the task. */ switch ( t->type ) { case 1: - d = sched_getdata( &s , t ); + d = qsched_getdata( &s , t ); // message( "thread %i working on block [ %i , %i ]." , qid , d[0] , d[1] ); fflush(stdout); matmul( 32 , 32 , k*32 , &a[ d[0]*32 ] , m*32 , &b[ k*32*d[1]*32 ] , k*32 , &c[ d[0]*32 + m*32*d[1]*32 ] , m*32 ); break; @@ -244,7 +244,7 @@ void test1 ( int m , int n , int k , int nr_threads ) { } /* Clean up afterwards. */ - sched_done( &s , t ); + qsched_done( &s , t ); } /* main loop. */ @@ -270,7 +270,7 @@ void test1 ( int m , int n , int k , int nr_threads ) { } */ /* Clean up. */ - sched_free( &s ); + qsched_free( &s ); free( a ); free( b ); free( c ); diff --git a/examples/test_bh.c b/examples/test_bh.c index bba2ad98d4a8afc69a72d34a3bf48cd429b3c088..c2dbefb54b887bae9c9f4509ee722a027655d926 100644 --- a/examples/test_bh.c +++ b/examples/test_bh.c @@ -104,7 +104,7 @@ struct cell *cell_get ( ) { cell_pool = cell_pool->progeny[0]; /* Clean up a few things. */ - res->res = sched_res_none; + res->res = qsched_res_none; /* Return the cell. */ return res; @@ -121,7 +121,7 @@ struct cell *cell_get ( ) { * @param s The #sched to store the resources. */ -void cell_split ( struct cell *c , struct sched *s ) { +void cell_split ( struct cell *c , struct qsched *s ) { int i, j, k, count = c->count; struct part temp, *parts = c->parts; @@ -130,11 +130,11 @@ void cell_split ( struct cell *c , struct sched *s ) { double pivot[3]; /* Add a resource for this cell if it doesn't have one yet. */ - if ( c->res == sched_res_none ) - c->res = sched_addres( s , sched_res_none ); + if ( c->res == qsched_res_none ) + c->res = qsched_addres( s , qsched_res_none ); /* Attach a center-of-mass task to the cell. */ - c->com_tid = sched_newtask( s , task_type_com , 0 , 0 , &c , sizeof(struct cell *) , 1 ); + c->com_tid = qsched_newtask( s , task_type_com , task_flag_none , &c , sizeof(struct cell *) , 1 ); /* Does this cell need to be split? */ if ( count > cell_maxparts ) { @@ -152,7 +152,7 @@ void cell_split ( struct cell *c , struct sched *s ) { cp->h[0] = c->h[0]/2; cp->h[1] = c->h[1]/2; cp->h[2] = c->h[2]/2; - cp->res = sched_addres( s , c->res ); + cp->res = qsched_addres( s , c->res ); if ( k & 4 ) cp->loc[0] += cp->h[0]; if ( k & 2 ) @@ -223,7 +223,7 @@ void cell_split ( struct cell *c , struct sched *s ) { /* Link the COM tasks. */ for ( k = 0 ; k < 8 ; k++ ) - sched_addunlock( s , c->progeny[k]->com_tid , c->com_tid ); + qsched_addunlock( s , c->progeny[k]->com_tid , c->com_tid ); } /* does the cell need to be split? */ @@ -483,7 +483,7 @@ void iact_self ( struct cell *c ) { * @param cj The second #cell. */ -void create_tasks ( struct sched *s , struct cell *ci , struct cell *cj ) { +void create_tasks ( struct qsched *s , struct cell *ci , struct cell *cj ) { int j, k, tid; struct cell *data[2]; @@ -519,10 +519,10 @@ void create_tasks ( struct sched *s , struct cell *ci , struct cell *cj ) { data[0] = ci; data[1] = NULL; /* Create the task. */ - tid = sched_newtask( s , task_type_self , 0 , 0 , data , sizeof(struct cell *) * 2 , ci->count*ci->count/2 ); + tid = qsched_newtask( s , task_type_self , task_flag_none , data , sizeof(struct cell *) * 2 , ci->count*ci->count/2 ); /* Add the resource. */ - sched_addlock( s , tid , ci->res ); + qsched_addlock( s , tid , ci->res ); } @@ -559,15 +559,15 @@ void create_tasks ( struct sched *s , struct cell *ci , struct cell *cj ) { /* Interact ci's parts with cj as a cell. */ data[0] = ci; data[1] = cj; - tid = sched_newtask( s , task_type_pair_pc , 0 , 0 , data , sizeof(struct cell *) * 2 , ci->count ); - sched_addlock( s , tid , ci->res ); - sched_addunlock( s , cj->com_tid , tid ); + tid = qsched_newtask( s , task_type_pair_pc , task_flag_none , data , sizeof(struct cell *) * 2 , ci->count ); + qsched_addlock( s , tid , ci->res ); + qsched_addunlock( s , cj->com_tid , tid ); /* Interact cj's parts with ci as a cell. */ data[0] = cj; data[1] = ci; - tid = sched_newtask( s , task_type_pair_pc , 0 , 0 , data , sizeof(struct cell *) * 2 , ci->count ); - sched_addlock( s , tid , cj->res ); - sched_addunlock( s , ci->com_tid , tid ); + tid = qsched_newtask( s , task_type_pair_pc , task_flag_none , data , sizeof(struct cell *) * 2 , ci->count ); + qsched_addlock( s , tid , cj->res ); + qsched_addunlock( s , ci->com_tid , tid ); } @@ -578,16 +578,16 @@ void create_tasks ( struct sched *s , struct cell *ci , struct cell *cj ) { data[0] = ci; data[1] = cj; /* Create the task. */ - tid = sched_newtask( s , task_type_pair , 0 , 0 , data , sizeof(struct cell *) * 2 , ci->count*cj->count ); + tid = qsched_newtask( s , task_type_pair , task_flag_none , data , sizeof(struct cell *) * 2 , ci->count*cj->count ); /* Add the resources. */ - sched_addlock( s , tid , ci->res ); - sched_addlock( s , tid , cj->res ); + qsched_addlock( s , tid , ci->res ); + qsched_addlock( s , tid , cj->res ); /* Depend on the COMs in case this task recurses. */ if ( ci->split || cj->split ) { - sched_addunlock( s , ci->com_tid , tid ); - sched_addunlock( s , cj->com_tid , tid ); + qsched_addunlock( s , ci->com_tid , tid ); + qsched_addunlock( s , cj->com_tid , tid ); } } @@ -611,10 +611,10 @@ void test_bh ( int N , int nr_threads ) { int k; struct cell *root; struct part *parts; - struct sched s; + struct qsched s; /* Initialize the scheduler. */ - sched_init( &s , nr_threads , 1000 ); + qsched_init( &s , nr_threads , 1000 ); /* Init and fill the particle array. */ if ( ( parts = (struct part *)malloc( sizeof(struct part) * N ) ) == NULL ) @@ -642,7 +642,7 @@ void test_bh ( int N , int nr_threads ) { create_tasks( &s , root , NULL ); /* Prepare the scheduler. */ - sched_prepare( &s ); + qsched_prepare( &s ); /* Parallel loop. */ #pragma omp parallel @@ -659,11 +659,11 @@ void test_bh ( int N , int nr_threads ) { while ( 1 ) { /* Get a task, break if unsucessful. */ - if ( ( t = sched_gettask( &s , qid ) ) == NULL ) + if ( ( t = qsched_gettask( &s , qid ) ) == NULL ) break; /* Get the task's data. */ - d = sched_getdata( &s , t ); + d = qsched_getdata( &s , t ); /* Decode and execute the task. */ switch ( t->type ) { @@ -684,7 +684,7 @@ void test_bh ( int N , int nr_threads ) { } /* Clean up afterwards. */ - sched_done( &s , t ); + qsched_done( &s , t ); } /* main loop. */ diff --git a/examples/test_qr.c b/examples/test_qr.c index 5594cfa12751ec89fdbb0b25e8ddaf505136c2e0..260ea3bf9a2cc3897b1818688a69b6c763cb932d 100644 --- a/examples/test_qr.c +++ b/examples/test_qr.c @@ -396,7 +396,7 @@ void test_qr ( int m , int n , int nr_threads ) { int k, j, i; double *A, *A_orig, *tau; - struct sched s; + struct qsched s; int *tid, *rid, tid_new; int data[3]; @@ -422,7 +422,7 @@ void test_qr ( int m , int n , int nr_threads ) { printf( "];\n" ); */ /* Initialize the scheduler. */ - sched_init( &s , nr_threads , m*n ); + qsched_init( &s , nr_threads , m*n ); /* Allocate and init the task ID and resource ID matrix. */ if ( ( tid = (int *)malloc( sizeof(int) * m * n ) ) == NULL || @@ -430,7 +430,7 @@ void test_qr ( int m , int n , int nr_threads ) { error( "Failed to allocate tid/rid matrix." ); for ( k = 0 ; k < m * n ; k++ ) { tid[k] = -1; - rid[k] = sched_addres( &s , -1 ); + rid[k] = qsched_addres( &s , -1 ); } /* Build the tasks. */ @@ -438,21 +438,21 @@ void test_qr ( int m , int n , int nr_threads ) { /* Add kth corner task. */ data[0] = k; data[1] = k; data[2] = k; - tid_new = sched_newtask( &s , task_DGEQRF , 0 , 0 , data , sizeof(int)*3 , 2 ); - sched_addlock( &s , tid_new , rid[ k*m + k ] ); + tid_new = qsched_newtask( &s , task_DGEQRF , task_flag_none , data , sizeof(int)*3 , 2 ); + qsched_addlock( &s , tid_new , rid[ k*m + k ] ); if ( tid[ k*m + k ] != -1 ) - sched_addunlock( &s , tid[ k*m + k ] , tid_new ); + qsched_addunlock( &s , tid[ k*m + k ] , tid_new ); tid[ k*m + k ] = tid_new; /* Add column tasks on kth row. */ for ( j = k+1 ; j < n ; j++ ) { data[0] = k; data[1] = j; data[2] = k; - tid_new = sched_newtask( &s , task_DLARFT , 0 , 0 , data , sizeof(int)*3 , 3 ); - sched_addlock( &s , tid_new , rid[ j*m + k ] ); - sched_adduse( &s , tid_new , rid[ k*m + k ] ); - sched_addunlock( &s , tid[ k*m + k ] , tid_new ); + tid_new = qsched_newtask( &s , task_DLARFT , task_flag_none , data , sizeof(int)*3 , 3 ); + qsched_addlock( &s , tid_new , rid[ j*m + k ] ); + qsched_adduse( &s , tid_new , rid[ k*m + k ] ); + qsched_addunlock( &s , tid[ k*m + k ] , tid_new ); if ( tid[ j*m + k ] != -1 ) - sched_addunlock( &s , tid[ j*m + k ] , tid_new ); + qsched_addunlock( &s , tid[ j*m + k ] , tid_new ); tid[ j*m + k ] = tid_new; } @@ -461,25 +461,25 @@ void test_qr ( int m , int n , int nr_threads ) { /* Add the row taks for the kth column. */ data[0] = i; data[1] = k; data[2] = k; - tid_new = sched_newtask( &s , task_DTSQRF , 0 , 0 , data , sizeof(int)*3 , 3 ); - sched_addlock( &s , tid_new , rid[ k*m + i ] ); - sched_adduse( &s , tid_new , rid[ k*m + k ] ); - sched_addunlock( &s , tid[ k*m + (i-1) ] , tid_new ); + tid_new = qsched_newtask( &s , task_DTSQRF , task_flag_none , data , sizeof(int)*3 , 3 ); + qsched_addlock( &s , tid_new , rid[ k*m + i ] ); + qsched_adduse( &s , tid_new , rid[ k*m + k ] ); + qsched_addunlock( &s , tid[ k*m + (i-1) ] , tid_new ); if ( tid[ k*m + i ] != -1 ) - sched_addunlock( &s , tid[ k*m + i ] , tid_new ); + qsched_addunlock( &s , tid[ k*m + i ] , tid_new ); tid[ k*m + i ] = tid_new; /* Add the inner tasks. */ for ( j = k+1 ; j < n ; j++ ) { data[0] = i; data[1] = j; data[2] = k; - tid_new = sched_newtask( &s , task_DSSRFT , 0 , 0 , data , sizeof(int)*3 , 5 ); - sched_addlock( &s , tid_new , rid[ j*m + i ] ); - sched_adduse( &s , tid_new , rid[ k*m + i ] ); - sched_adduse( &s , tid_new , rid[ j*m + k ] ); - sched_addunlock( &s , tid[ k*m + i ] , tid_new ); - sched_addunlock( &s , tid[ j*m + k ] , tid_new ); + tid_new = qsched_newtask( &s , task_DSSRFT , task_flag_none , data , sizeof(int)*3 , 5 ); + qsched_addlock( &s , tid_new , rid[ j*m + i ] ); + qsched_adduse( &s , tid_new , rid[ k*m + i ] ); + qsched_adduse( &s , tid_new , rid[ j*m + k ] ); + qsched_addunlock( &s , tid[ k*m + i ] , tid_new ); + qsched_addunlock( &s , tid[ j*m + k ] , tid_new ); if ( tid[ j*m + i ] != -1 ) - sched_addunlock( &s , tid[ j*m + i ] , tid_new ); + qsched_addunlock( &s , tid[ j*m + i ] , tid_new ); tid[ j*m + i ] = tid_new; } @@ -488,7 +488,7 @@ void test_qr ( int m , int n , int nr_threads ) { } /* build the tasks. */ /* Prepare the scheduler. */ - sched_prepare( &s ); + qsched_prepare( &s ); /* Parallel loop. */ #pragma omp parallel @@ -505,11 +505,11 @@ void test_qr ( int m , int n , int nr_threads ) { while ( 1 ) { /* Get a task, break if unsucessful. */ - if ( ( t = sched_gettask( &s , qid ) ) == NULL ) + if ( ( t = qsched_gettask( &s , qid ) ) == NULL ) break; /* Get the task's data. */ - d = sched_getdata( &s , t ); + d = qsched_getdata( &s , t ); i = d[0]; j = d[1]; k = d[2]; /* Decode and execute the task. */ @@ -531,7 +531,7 @@ void test_qr ( int m , int n , int nr_threads ) { } /* Clean up afterwards. */ - sched_done( &s , t ); + qsched_done( &s , t ); } /* main loop. */