Skip to content

Commit

Permalink
Split imperfect-loop-collapse into usm/non-usm variants
Browse files Browse the repository at this point in the history
This patch splits the smoke-fails/imperfect-loop-collapse test into two
variants, one of which does and one which doesn't need unified shared
memory (which is orthogonal to the main purpose of the test).  It also
fixes the HSA_XNACK setting for smoke-fails/imperfect-loop-collapse-usm
version, so both versions now work.
  • Loading branch information
jtb20 committed Jun 19, 2024
1 parent 86dc346 commit a73dea9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 7 deletions.
25 changes: 25 additions & 0 deletions test/smoke-fails/imperfect-loop-collapse-usm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include ../../Makefile.defs

TESTNAME = imperfect_loop_collapse_usm
TESTSRC_MAIN = imperfect_loop_collapse_usm.cpp
TESTSRC_AUX =
TESTSRC_ALL = $(TESTSRC_MAIN) $(TESTSRC_AUX)

CLANG ?= clang++
OMP_BIN = $(AOMP)/bin/$(CLANG)
CC = $(OMP_BIN) $(VERBOSE)

HSA_XNACK ?= 1
SUPPORTED = $(SUPPORTS_USM)

# Our "run" target gets overridden. Make sure we run with HSA_XNACK set
# appropriately.
RUNENV += HSA_XNACK=${HSA_XNACK}

#-ccc-print-phases
#"-\#\#\#"

include ../Makefile.rules

run:
HSA_XNACK=${HSA_XNACK} ./$(TESTNAME)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include<cstdio>

#define N 1024

#pragma omp requires unified_shared_memory

int main() {
double *a = new double[N*N];

#pragma omp parallel for collapse(2)
for(int i = 0; i < N; i++)
for(int j = 0; j < N; j++)
a[i*N+j] = (double) (i*N+j);

#pragma omp target teams distribute parallel for collapse(2)
for(int i = 0; i < N; i++) {
double k = i*3.14;
for(int j = 0; j < N; j++)
a[i*N+j] += k;
}

//check
int err = 0;
for(int i = 0; i < N; i++) {
double k = i*3.14;
for(int j = 0; j < N; j++)
if (a[i*N+j] != (double) (i*N+j) + k) {
err++;
printf("Error at (%d,%d): got %lf expected %lf\n", i, j, a[i*N+j], (double) (i*N+j) + k);
if (err > 10) return err;
}
}

return err;
}
5 changes: 1 addition & 4 deletions test/smoke-fails/imperfect-loop-collapse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ CLANG ?= clang++
OMP_BIN = $(AOMP)/bin/$(CLANG)
CC = $(OMP_BIN) $(VERBOSE)

HSA_XNACK ?= 1
SUPPORTED = $(SUPPORTS_USM)

#-ccc-print-phases
#"-\#\#\#"

include ../Makefile.rules

run:
HSA_XNACK=${HSA_XNACK} ./$(TESTNAME)
./$(TESTNAME)
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#define N 1024

#pragma omp requires unified_shared_memory

int main() {
double *a = new double[N*N];

Expand All @@ -12,7 +10,8 @@ int main() {
for(int j = 0; j < N; j++)
a[i*N+j] = (double) (i*N+j);

#pragma omp target teams distribute parallel for collapse(2)
#pragma omp target teams distribute parallel for collapse(2) \
map(tofrom: a[0:N*N])
for(int i = 0; i < N; i++) {
double k = i*3.14;
for(int j = 0; j < N; j++)
Expand Down

0 comments on commit a73dea9

Please sign in to comment.