Skip to content

Commit f3ac17b

Browse files
authored
Fix up reduction/ atomic (#84)
1 parent 1dbe87a commit f3ac17b

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

func/omp/repeated_reduce.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool doReduce()
5555
if (counts[t] != chunkSize) {
5656
printf(
5757
"Loop count for thread %i: %i != %i\n", t, counts[t], chunkSize);
58-
return false;
58+
success = false;
5959
}
6060
}
6161

@@ -64,15 +64,15 @@ bool doReduce()
6464

6565
if (reducedA != expectedFinalReducedA) {
6666
printf("reducedA %i != %i\n", reducedA, expectedFinalReducedA);
67-
return false;
67+
success = false;
6868
}
6969

7070
if (reducedB != expectedFinalReducedB) {
7171
printf("reducedB %i != %i\n", reducedB, expectedFinalReducedB);
72-
return false;
72+
success = false;
7373
}
7474

75-
return true;
75+
return success;
7676
}
7777

7878
int main(int argc, char* argv[])

func/omp/simple_atomic.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ int main()
1010

1111
#pragma omp parallel num_threads(nThreads) default(none) shared(counter)
1212
{
13-
// NOTE - it appears OpenMP doesn't actually support compiling the
14-
// atomic pragma to anything useful in wasm, so we have to replace with
15-
// our own custom stuff
1613
FAASM_ATOMIC_INCR_BY(counter, omp_get_thread_num());
1714
}
1815

libfaasm/faasm/shared_mem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ extern "C"
4646
} \
4747
__faasm_sm_critical_local_end();
4848

49+
// It appears OpenMP just ignores the atomic pragma, so we have to replace with
50+
// our own custom stuff
4951
#define FAASM_ATOMIC_INCR(var) \
5052
__faasm_sm_reduce((void*)&(var), FAASM_TYPE_INT, FAASM_OP_SUM, 1); \
5153
FAASM_CRITICAL_LOCAL(var++)

0 commit comments

Comments
 (0)