Skip to content

Commit

Permalink
OMP symbol mangling nim-lang/Nim#9365 and nim-lang/Nim#9366
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Oct 14, 2018
1 parent c81c14d commit 477927a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions laser/openmp/omp_mangling.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2018 Mamy André-Ratsimbazafy
# Distributed under the Apache v2 License (license terms are at http://www.apache.org/licenses/LICENSE-2.0).
# This file may not be copied, modified, or distributed except according to those terms.

# Compile-time name mangling for OpenMP thresholds
# Workaround https://github.com/nim-lang/Nim/issues/9365
# and https://github.com/nim-lang/Nim/issues/9366
import random
from strutils import toHex

var mangling_rng {.compileTime.} = initRand(0x1337DEEDBEAF)
var current_suffix {.compileTime.} = ""

proc omp_suffix*(genNew: static bool = false): static string =
## genNew:
## if false, return the last suffix
## else return a fresh one

if genNew:
current_suffix = mangling_rng.rand(high(uint32)).toHex
result = current_suffix

0 comments on commit 477927a

Please sign in to comment.