Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break possible deadlock on lockstep execution #819

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include <stdlib.h>
#include "ompvv.h"

#define N 1024

#pragma omp requires atomic_default_mem_order(acq_rel)

int test_target_requires_atomic_acq_rel() {
Expand All @@ -25,15 +23,20 @@ int test_target_requires_atomic_acq_rel() {
int x = 0, y = 0;
int errors = 0;

#pragma omp target parallel num_threads(2) map(tofrom: x, y, errors)
#pragma omp target parallel num_threads(2) map(tofrom: x, y, errors)
{
int thrd = omp_get_thread_num();
int tmp = 0;
if (thrd == 0) {
x = 10;
#pragma omp atomic write
y = 1;
} else {
int tmp = 0;
#pragma omp atomic read
tmp = y;
}
if (thrd != 0) {
tmp = 0;
while (tmp == 0) {
#pragma omp atomic read
tmp = y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ int test_target_requires_atomic_relaxed() {
#pragma omp target parallel num_threads(2) map(tofrom: x, y, errors)
{
int thrd = omp_get_thread_num();
int tmp = 0;
if (thrd == 0) {
x = 10;
#pragma omp flush
#pragma omp atomic write
y = 1;
} else {
int tmp = 0;
#pragma omp atomic read
tmp = y;
}

if (thrd != 0 ) {
tmp = 0;
while (tmp == 0) {
#pragma omp atomic read
tmp = y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ int test_target_atomic_seq_cst() {
#pragma omp target parallel num_threads(2) map(tofrom: x, y, errors)
{
int thrd = omp_get_thread_num();
int tmp = 0;
if (thrd == 0) {
x = 10;
#pragma omp atomic write
y = 1;
} else {
int tmp = 0;
#pragma omp atomic read
y = tmp;
}

if (thrd != 0) {
while (tmp == 0) {
#pragma omp atomic read
tmp = y;
Expand Down