blitzpp / blitz

Blitz++ Multi-Dimensional Array Library for C++
https://github.com/blitzpp/blitz/wiki
Other
402 stars 83 forks source link

OpenMP atomic support suggestion #156

Open WalterZimmer314 opened 4 years ago

WalterZimmer314 commented 4 years ago

We noticed some time ago that OpenMP scaling is not too well, and found out it can be improved significantly by implementing the synchronization via OpenMP atomic instructions. There are several ways to implement locking inside Blitz and it was not clear to me how to implement the changes in a general way, so I can only provide a patch of what we did. It would be great if someone could have a look and (suggests how to) implement it in a more general way.

Having a derived class for read only data which doesn't need synchronisation is #another issue...

blitz-memblock.h-patch.txt

slayoo commented 4 years ago

Thanks!

Probably, we should reuse the existing BZ_THREADSAFE_USE_OPENMP macro?

See ```blitz.hpp''': https://github.com/blitzpp/blitz/blob/master/blitz/blitz.h#L158

 #elif defined (_OPENMP)
#define BZ_THREADSAFE_USE_OPENMP

which then would be used to conditionally declare something alike BZ_MUTEX_UNLOCK but for refcount increments/decrements?