Repository navigation
Release v1.6.2
Fixed
- Critical: Cancellable barrier deadlock: Fixed multiple race conditions and deadlocks in
__kmpc_cancel_barrierimplementation- Problem 1 (Barrier deadlock): When Thread 0 called
#pragma omp cancel parallel, it exited immediately, but other threads continued waiting at the barrier expecting all threads to arrive → deadlock - Problem 2 (State pollution): Barrier state was not cleaned up when threads exited early due to cancellation, causing subsequent tests to encounter corrupted state (e.g.,
arrived = -2) → hang - Root cause: Incorrect understanding of OpenMP cancellation semantics -
#pragma omp cancelincludes an implicit cancellation point and causes immediate exit (per OpenMP specification) - Solution:
- Modified
__kmpc_cancel_barrierto handle three scenarios:- Cancellation active BEFORE barrier → exit immediately without waiting, Thread 0 cleans up barrier state
- Cancellation occurs DURING barrier wait → decrement arrived count, broadcast to wake other threads, exit
- No cancellation → normal barrier synchronization
- Added cleanup logic for early exit scenario to prevent state pollution between tests
- Modified
- Problem 1 (Barrier deadlock): When Thread 0 called
Technical Details
- Modified files:
- src/kmp_barrier.h (NEW): Shared header containing
BarrierStatestruct and global variable declarations - src/kmp_barrier.cpp: Removed
staticfrombarrier_statesandbarrier_map_lockdefinitions, include kmp_barrier.h - src/kmp_cancel.cpp: Include kmp_barrier.h, implement three-scenario cancellable barrier with cleanup logic
- src/platform.h: Added
#pragma onceguard
- src/kmp_barrier.h (NEW): Shared header containing
Build Date: 2025-11-22 14:23:54 UTC
Commit: 606fb15
Installation
Download libsimpleomp.a and link it when building your Emscripten project:
emcc your_code.c -fopenmp -pthread \
-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency \
libsimpleomp.a -o output.jsOptionally, download omp.h to use the OpenMP Runtime API:
emcc your_code.c -I/path/to/include -fopenmp -pthread \
-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency \
libsimpleomp.a -o output.js-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency flag. See the README for more details.