Skip to content

Commit

Permalink
add minor docstring and add note about OpenMP compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vindaar committed Jun 16, 2024
1 parent 19370f2 commit c7ccd4b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scinim/fuse_loops.nim
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,24 @@ proc fuseLoopImpl(ompStr: string, body: NimNode): NimNode =
echo result.repr

macro fuseLoops*(body: untyped): untyped =
## Fuses all loops inside the body of the macro, unless they are annotated with
## `nofuse`.
result = fuseLoopImpl("", body)

macro fuseLoops*(ompStr: untyped{lit}, body: untyped): untyped =
## Fuses all loops inside the body of the macro, unless they are annotated with
## `nofuse`.
##
## This version supports handing a string to be passed to OpenMP, i.e.
## `fuseLoops("parallelFor"): body`
##
## Note: To utilize OpenMP, you may have to compile with
## `--passC:"-fopenmp" --passL:"-lgomp"`
## (at least for GCC. For Clang the commands differ slightly I believe).
##
## There is also a chance you either have to compile with
## `--exceptions:quirky`
## or using the C++ backend, due to the C backend producing `goto` statements
## inside the loops, which lead to C compiler errors when combined with
## OpenMP.
result = fuseLoopImpl(ompStr.strVal, body)

0 comments on commit c7ccd4b

Please sign in to comment.