[OpenMP][host runtime] Fix indirect lock table race condition
The indirect lock table can exhibit a race condition during initializing and setting/unsetting locks. This occurs if the lock table is resized by one thread (during an omp_init_lock) and accessed (during an omp_set|unset_lock) by another thread. The test runtime/test/lock/omp_init_lock.c test exposed this issue and will fail if run enough times. This patch restructures the lock table so pointer/iterator validity is always kept. Instead of reallocating a single table to a larger size, the lock table begins preallocated to accommodate 8K locks. Each row of the table is allocated as needed with each row allowing 1K locks. If the 8K limit is reached for the initial table, then another table, capable of holding double the number of locks, is allocated and linked as the next table. The indices stored in the user's locks take this linked structure into account when finding the lock within the table. Differential Revision: https://reviews.llvm.org/D109725
Loading
Please register or sign in to comment