From ede4ea70bbbb1b9ace28f22a9c820ff9aba06018 Mon Sep 17 00:00:00 2001 From: Vindaar Date: Sun, 16 Jun 2024 19:02:25 +0200 Subject: [PATCH] add minor docstring and add note about OpenMP compilation --- scinim/fuse_loops.nim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scinim/fuse_loops.nim b/scinim/fuse_loops.nim index 8e44b4c..3355880 100644 --- a/scinim/fuse_loops.nim +++ b/scinim/fuse_loops.nim @@ -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)