Issue #451 part 2a - Enable OpenMP parallelization for CopyValues in SelfHosting.cpp

This commit is contained in:
ownedbywuigi 2026-04-25 09:49:36 +01:00
commit d8c48d6830
2 changed files with 21 additions and 4 deletions

View file

@ -1492,9 +1492,22 @@ CopyValues(SharedMem<To*> dest, SharedMem<From*> src, uint32_t count)
using namespace jit;
for (; count > 0; count--) {
AtomicOperations::storeSafeWhenRacy(dest++,
To(AtomicOperations::loadSafeWhenRacy(src++)));
#if defined(_OPENMP)
const int64_t openMpCount = int64_t(count);
if (openMpCount >= (1 << 14)) {
#pragma omp parallel for default(none) shared(dest, src, openMpCount) schedule(static)
for (int64_t i = 0; i < openMpCount; i++) {
uint32_t index = uint32_t(i);
AtomicOperations::storeSafeWhenRacy(dest + index,
To(AtomicOperations::loadSafeWhenRacy(src + index)));
}
return;
}
#endif
for (uint32_t i = 0; i < count; i++) {
AtomicOperations::storeSafeWhenRacy(dest + i,
To(AtomicOperations::loadSafeWhenRacy(src + i)));
}
}