Commit 29983947 authored by Sergi Mateo Bellido's avatar Sergi Mateo Bellido

Fixing dynamic and guided slicers

See #1246
parent 6c65b1c1
......@@ -57,25 +57,29 @@ bool SlicerDynamicFor::dequeue(nanos::WorkDescriptor* wd, nanos::WorkDescriptor*
{
bool retval = false;
//! nli represents the chunk of iterations pending to be executed
nanos_loop_info_t *nli = ( nanos_loop_info_t * ) wd->getData();
//! Compute next (chunk) lower bound
//! Compute next chunk upper bound
int64_t _upper = nli->lower + nli->chunk * nli->step - nli->step;
//! Computing empty iteration spaces in order to avoid infinite task generation
bool empty = (( nli->step > 0 ) && (nli->lower > nli->upper )) ? true : false;
empty = empty || (( nli->step < 0 ) && (nli->lower < nli->upper )) ? true : false;
if ( (_upper >= nli->upper) || empty ) {
bool empty = (( nli->step > 0 ) && (nli->lower > nli->upper )) ||
(( nli->step < 0 ) && (nli->lower < nli->upper ));
if (empty ||
(_upper >= nli->upper && nli->step > 0) ||
(_upper <= nli->upper && nli->step < 0)) {
*slice = wd; retval = true;
} else {
WorkDescriptor *nwd = NULL;
sys.duplicateWD( &nwd, wd );
nwd->untie();
// Advance the lower bound of the chunk of iterations pending to be executed
nli->lower = _upper + nli->step;
nli = ( nanos_loop_info_t * ) nwd->getData();
nli->upper = _upper;
nanos_loop_info_t *current_nli = ( nanos_loop_info_t * ) nwd->getData();
current_nli->upper = _upper;
sys.setupWD(*nwd, wd );
*slice = nwd;
......
......@@ -68,6 +68,7 @@ bool SlicerGuidedFor::dequeue(nanos::WorkDescriptor* wd, nanos::WorkDescriptor**
{
bool retval = false;
//! nli represents the chunk of iterations pending to be executed
nanos_loop_info_t *nli = ( nanos_loop_info_t * ) wd->getData();
int64_t _niters = ((( nli->upper - nli->lower) / nli->step ) + 1 );
......@@ -75,18 +76,20 @@ bool SlicerGuidedFor::dequeue(nanos::WorkDescriptor* wd, nanos::WorkDescriptor**
int64_t _upper = nli->lower + _chunk * nli->step ;
//! Computing empty iteration spaces to avoid infinite task generation
bool empty = (( nli->step > 0 ) && (nli->lower > nli->upper )) ? true : false;
empty = empty || (( nli->step < 0 ) && (nli->lower < nli->upper )) ? true : false;
if ( (_upper >= nli->upper) || empty ) {
bool empty = (( nli->step > 0 ) && (nli->lower > nli->upper )) ||
(( nli->step < 0 ) && (nli->lower < nli->upper ));
if (empty ||
(_upper >= nli->upper && nli->step > 0) ||
(_upper <= nli->upper && nli->step < 0)) {
*slice = wd; retval = true;
} else {
WorkDescriptor *nwd = NULL;
sys.duplicateWD( &nwd, wd );
// Advance the lower bound of the chunk of iterations pending to be executed
nli->lower = _upper + nli->step;
nli = ( nanos_loop_info_t * ) nwd->getData();
nli->upper = _upper;
nanos_loop_info_t *current_nli = ( nanos_loop_info_t * ) nwd->getData();
current_nli->upper = _upper;
sys.setupWD(*nwd, wd );
*slice = nwd;
......
Markdown is supported
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