-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add and use parallelisation abstraction
- Loading branch information
1 parent
1bfa55b
commit bc62339
Showing
3 changed files
with
38 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef PARALLEL_H_ | ||
#define PARALLEL_H_ | ||
|
||
#if defined(HAVE_LIBDISPATCH) && defined(HAVE_BLOCKS) | ||
|
||
#include <dispatch/dispatch.h> | ||
|
||
#define PARALLEL_LOOP_START(i,n) \ | ||
dispatch_apply(size_t(n), DISPATCH_APPLY_AUTO, ^(size_t i) { | ||
#define PARALLEL_LOOP_END }); | ||
|
||
#elif _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_END } | ||
|
||
#else | ||
|
||
#define PARALLEL_LOOP_START(i,n) \ | ||
for (size_t i=0; i<size_t(n); i++) { | ||
#define PARALLEL_LOOP_END } | ||
|
||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters