Skip to content

Commit

Permalink
Fix noOpenmp build
Browse files Browse the repository at this point in the history
  • Loading branch information
James Osborn committed Jun 13, 2024
1 parent cca9f02 commit 34c4aec
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/base/omp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import os
when defined(noOpenmp):
static: echo "OpenMP disabled"
template omp_set_num_threads*(x: cint) = discard
template omp_get_num_threads*(): cint = 1
template omp_get_max_threads*(): cint = 1
template omp_get_thread_num*(): cint = 0
template ompPragma(p:string):untyped = discard
template ompBlock*(p:string; body:untyped):untyped =
template omp_get_num_threads*(): cint = cint 1
template omp_get_max_threads*(): cint = cint 1
template omp_get_thread_num*(): cint = cint 0
template ompPragma(p:string) = discard
template ompBlock*(p:string; body:untyped) =
block:
body
else:
Expand All @@ -24,11 +24,11 @@ else:
proc omp_get_max_threads*(): cint {.omp.}
proc omp_get_thread_num*(): cint {.omp.}
#proc forceOmpOn() {.omp.}
template ompPragma(p:string):untyped =
template ompPragma(p:string) =
#forceOmpOn()
#{. emit:["#pragma omp ", p] .}
{. emit:["_Pragma(\"omp ", p, "\")"] .}
template ompBlock*(p:string; body:untyped):untyped =
template ompBlock*(p:string; body:untyped) =
#{. emit:"#pragma omp " & p .}
#{. emit:"{ /* Inserted by ompBlock " & p & " */".}
#{. emit:["#pragma omp ", p] .}
Expand All @@ -39,14 +39,14 @@ else:

template ompBarrier* = ompPragma("barrier")

template ompParallel*(body:untyped):untyped =
template ompParallel*(body:untyped) =
ompBlock("parallel"):
if(omp_get_thread_num()!=0):
setupForeignThreadGc()
body
template ompMaster*(body:untyped):untyped = ompBlock("master", body)
template ompSingle*(body:untyped):untyped = ompBlock("single", body)
template ompCritical*(body:untyped):untyped = ompBlock("critical", body)
template ompMaster*(body:untyped) = ompBlock("master", body)
template ompSingle*(body:untyped) = ompBlock("single", body)
template ompCritical*(body:untyped) = ompBlock("critical", body)

when isMainModule:
proc test =
Expand Down

0 comments on commit 34c4aec

Please sign in to comment.