--- a/BooPHF.h +++ b/BooPHF.h @@ -704,7 +704,7 @@ //atomically return old val and set to 1 uint64_t atomic_test_and_set(uint64_t pos) { - uint64_t oldval = __sync_fetch_and_or (_bitArray + (pos >> 6), (uint64_t) (1ULL << (pos & 63)) ); + uint64_t oldval = __atomic_fetch_or (_bitArray + (pos >> 6), (uint64_t) (1ULL << (pos & 63)), __ATOMIC_SEQ_CST); return ( oldval >> (pos & 63 ) ) & 1; } @@ -725,14 +725,14 @@ { assert(pos<_size); //_bitArray [pos >> 6] |= (1ULL << (pos & 63) ) ; - __sync_fetch_and_or (_bitArray + (pos >> 6ULL), (1ULL << (pos & 63)) ); + __atomic_fetch_or (_bitArray + (pos >> 6ULL), (1ULL << (pos & 63)), __ATOMIC_SEQ_CST); } //set bit pos to 0 void reset(uint64_t pos) { //_bitArray [pos >> 6] &= ~(1ULL << (pos & 63) ) ; - __sync_fetch_and_and (_bitArray + (pos >> 6ULL), ~(1ULL << (pos & 63) )); + __atomic_fetch_and (_bitArray + (pos >> 6ULL), ~(1ULL << (pos & 63) ), __ATOMIC_SEQ_CST); } //return value of last rank @@ -1045,7 +1045,7 @@ void pthread_processLevel( std::vector & buffer , std::shared_ptr shared_it, std::shared_ptr until_p, int i) { uint64_t nb_done =0; - int tid = __sync_fetch_and_add (&_nb_living, 1); + int tid = __atomic_fetch_add (&_nb_living, 1, __ATOMIC_SEQ_CST); auto until = *until_p; uint64_t inbuff =0; @@ -1098,7 +1098,7 @@ if(_fastmode && i == _fastModeLevel) { - uint64_t idxl2 = __sync_fetch_and_add(& _idxLevelsetLevelFastmode,1); + uint64_t idxl2 = __atomic_fetch_add(& _idxLevelsetLevelFastmode,1, __ATOMIC_SEQ_CST); //si depasse taille attendue pour setLevelFastmode, fall back sur slow mode mais devrait pas arriver si hash ok et proba avec nous if(idxl2>= setLevelFastmode.size()) _fastmode = false; @@ -1110,7 +1110,7 @@ if(i == _nb_levels-1) //stop cascade here, insert into exact hash { - uint64_t hashidx = __sync_fetch_and_add (& _hashidx, 1); + uint64_t hashidx = __atomic_fetch_add (& _hashidx, 1, __ATOMIC_SEQ_CST); pthread_mutex_lock(&_mutex); //see later if possible to avoid this, mais pas bcp item vont la // calc rank de fin precedent level qq part, puis init hashidx avec ce rank, direct minimal, pas besoin inser ds bitset et rank