Commit acbdf359 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Ensstat: test tasking.

parent 1767199e
......@@ -68,11 +68,11 @@ typedef struct
static
void *ensstat_func(void *xarg)
void *ensstat_func(void *ensarg)
{
cdo_omp_set_num_threads(ompNumThreads);
if ( CDO_task ) cdo_omp_set_num_threads(ompNumThreads);
ensstat_arg_t *arg = (ensstat_arg_t*) xarg;
ensstat_arg_t *arg = (ensstat_arg_t*) ensarg;
int nfiles = arg->nfiles;
ens_file_t *ef = arg->ef;
field_type *field = arg->field;
......@@ -132,7 +132,7 @@ void *ensstat_func(void *xarg)
void *Ensstat(void *argument)
{
void *task = cdo_task_new();
void *task = CDO_task ? cdo_task_new() : NULL;
ensstat_arg_t ensstat_arg;
int nrecs0;
......@@ -307,9 +307,15 @@ void *Ensstat(void *argument)
ensstat_arg.ef = ef;
ensstat_arg.varID = varID;
ensstat_arg.levelID = levelID;
ensstat_func(&ensstat_arg);
//cdo_task_start(task, ensstat_func, &ensstat_arg);
//cdo_task_wait(task);
if ( task )
{
cdo_task_start(task, ensstat_func, &ensstat_arg);
cdo_task_wait(task);
}
else
{
ensstat_func(&ensstat_arg);
}
}
tsID++;
......@@ -336,7 +342,7 @@ void *Ensstat(void *argument)
for ( int i = 0; i < ompNumThreads; i++ ) if ( field[i].ptr ) Free(field[i].ptr);
if ( field ) Free(field);
cdo_task_delete(task);
if ( task ) cdo_task_delete(task);
cdoFinish();
......
......@@ -61,17 +61,9 @@ void *cdo_task(void *task)
{
pthread_cond_wait(&(task_info->work_cond), &(task_info->work_mtx));
if ( DIE == task_info->state )
{
// kill thread
break;
}
if ( DIE == task_info->state ) break; // kill thread
if ( IDLE == task_info->state )
{
// accidental wake-up
continue;
}
if ( IDLE == task_info->state ) continue; // accidental wake-up
// do blocking task
//printf("<worker> JOB start\n");
......@@ -102,10 +94,7 @@ void cdo_task_start(void *task, void *(*task_routine)(void *), void *task_arg)
// ensure worker is waiting
#if defined(HAVE_LIBPTHREAD)
if ( CDO_task )
{
pthread_mutex_lock(&(task_info->work_mtx));
}
if ( CDO_task ) pthread_mutex_lock(&(task_info->work_mtx));
#endif
// set job information & state
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment