/*! \brief create a loop descriptor * * \return only one thread per loop will get 'true' (single like behaviour) */ bool create ( nanos_ws_desc_t **wsd, nanos_ws_info_t *info ) { nanos_ws_info_loop_t *loop_info = (nanos_ws_info_loop_t *) info; bool single = false; *wsd = myThread->getTeamWorkSharingDescriptor( &single ); if ( single ) { (*wsd)->data = NEW WorkSharingLoopInfo(); int num_threads = myThread->getTeam()->getFinalSize(); ((WorkSharingLoopInfo *)(*wsd)->data)->lowerBound = loop_info->lower_bound; ((WorkSharingLoopInfo *)(*wsd)->data)->upperBound = loop_info->upper_bound; ((WorkSharingLoopInfo *)(*wsd)->data)->loopStep = loop_info->loop_step; int chunk_size = std::max(1,loop_info->chunk_size); ((WorkSharingLoopInfo *)(*wsd)->data)->chunkSize = chunk_size; int niters = (((loop_info->upper_bound - loop_info->lower_bound) / loop_info->loop_step ) + 1 ); int chunks = niters / chunk_size; if ( niters % chunk_size != 0 ) chunks++; ((WorkSharingLoopInfo *)(*wsd)->data)->numOfChunks = 0; while ( niters > 0 ) { niters = niters - std::max( niters/(2*num_threads), chunk_size); ((WorkSharingLoopInfo *)(*wsd)->data)->numOfChunks++; } ((WorkSharingLoopInfo *)(*wsd)->data)->currentChunk = 0; memoryFence(); (*wsd)->ws = this; // Once 'ws' field has a value, any other thread can use the structure } // wait until worksharing descriptor is initialized while ( (*wsd)->ws == NULL ) {;} return single; }
inline void DependableObject::disableSubmission() { _needsSubmission = false; #ifdef HAVE_NEW_GCC_ATOMIC_OPS __atomic_store_n(&_submitted, false, __ATOMIC_RELEASE); #else _submitted = false; memoryFence(); #endif }
inline void DependableObject::submitted() { #ifdef HAVE_NEW_GCC_ATOMIC_OPS __atomic_store_n(&_submitted, true, __ATOMIC_RELEASE); #else _submitted = true; #endif enableSubmission(); #ifdef HAVE_NEW_GCC_ATOMIC_OPS #else memoryFence(); #endif }
inline SyncLockBlock::~SyncLockBlock ( ) { memoryFence(); }
inline SyncLockBlock::SyncLockBlock ( Lock & lock ) : LockBlock(lock) { memoryFence(); }
inline void DependenciesDomain::unlock ( ) { memoryFence(); _lock.release(); }
inline void DependenciesDomain::lock ( ) { _lock.acquire(); memoryFence(); }