Skip to content

Commit

Permalink
Also abstract out continue statements, which need to be return in blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jonclayden committed Mar 18, 2024
1 parent bc62339 commit 1e73bb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Distancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Array<double> * Distancer::run ()

// If no parabolas have been placed, there's nothing else to do
if (vertices.empty())
continue;
PARALLEL_LOOP_CONTINUE

// Step back over the data, replacing each element with the value
// of the lowest parabola at that location
Expand Down
5 changes: 4 additions & 1 deletion src/Parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@

#define PARALLEL_LOOP_START(i,n) \
dispatch_apply(size_t(n), DISPATCH_APPLY_AUTO, ^(size_t i) {
#define PARALLEL_LOOP_CONTINUE return;
#define PARALLEL_LOOP_END });

#elif _OPENMP
#elif defined(_OPENMP)

#include <omp.h>

#define PARALLEL_LOOP_START(i,n) \
_Pragma("omp parallel for") \
for (size_t i=0; i<size_t(n); i++) {
#define PARALLEL_LOOP_CONTINUE continue;
#define PARALLEL_LOOP_END }

#else

#define PARALLEL_LOOP_START(i,n) \
for (size_t i=0; i<size_t(n); i++) {
#define PARALLEL_LOOP_CONTINUE continue;
#define PARALLEL_LOOP_END }

#endif
Expand Down

0 comments on commit 1e73bb4

Please sign in to comment.