Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions omp4py/runtime/parallelism.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ def omp_parallel(num: pyint, f: typing.Callable[[], None], cvars: controlvars.Co
task.cvars.dataenv = task.cvars.dataenv.__copy__()
task.cvars.dataenv.thread_num = num
thread.current().set_parallel(task).set_task(task)
f()
barrier.task_barrier(task)
thread.current().pop_task()
try:
f()
Comment on lines +17 to +18
finally:
barrier.task_barrier(task)
thread.current().pop_task()


def parallel_run(f: typing.Callable[[], None], c_if: bool, c_message: str, c_nthreads: tuple[pyint, ...],
Expand Down
22 changes: 22 additions & 0 deletions test/basic/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,25 @@ def test_parallel_copyin():
assert sorted(q.queue) == [2, 2]

################################################


################################################


def parallel_raise_exception():
with omp("parallel num_threads(2)"):
raise ValueError("Intentional parallel test exception")


def parallel_subsequent_region(q: Queue):
with omp("parallel num_threads(2)"):
q.put(omp_get_thread_num())


def test_parallel_exception_cleanup():
with pytest.raises(ValueError, match="Intentional parallel test exception"):
omp(parallel_raise_exception)()

q = Queue()
omp(parallel_subsequent_region)(q)
assert sorted(q.queue) == [0, 1]