Skip to content

Release v1.6.2

Choose a tag to compare

@github-actions github-actions released this 22 Nov 14:23
· 4 commits to main since this release

Fixed

  • Critical: Cancellable barrier deadlock: Fixed multiple race conditions and deadlocks in __kmpc_cancel_barrier implementation
    • 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 cancel includes an implicit cancellation point and causes immediate exit (per OpenMP specification)
    • Solution:
      1. Modified __kmpc_cancel_barrier to 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
      2. Added cleanup logic for early exit scenario to prevent state pollution between tests

Technical Details

  • Modified files:
    • src/kmp_barrier.h (NEW): Shared header containing BarrierState struct and global variable declarations
    • src/kmp_barrier.cpp: Removed static from barrier_states and barrier_map_lock definitions, 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 once guard

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.js

Optionally, 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

⚠️ IMPORTANT: You MUST include the -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency flag. See the README for more details.