Skip to content

Commit

Permalink
Merge branch 'devel' into wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Oct 18, 2023
2 parents baedec5 + ecaa358 commit a98047d
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 31 deletions.
8 changes: 4 additions & 4 deletions src/base/profile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,11 @@ type
Tstr = tuple
label: string
stats: string
template ppT(ts:RTInfoObjList, prefix = "-", total,overhead:int64 = 0, count:uint32 = 0, initIx = 0, showAbove = 0.0, showDropped = true):seq[Tstr] =
template ppT(ts: RTInfoObjList, prefix = "-", total = 0'i64, overhead = 0'i64,
count = 0'u32, initIx = 0, showAbove = 0.0, showDropped = true): seq[Tstr] =
ppT(List[RTInfoObj](ts), prefix, total, overhead, count, initIx, showAbove, showDropped)
proc ppT(ts:List[RTInfoObj], prefix = "-",
total,overhead:int64 = 0, count:uint32 = 0, initIx = 0,
showAbove = 0.0, showDropped = true):seq[Tstr] =
proc ppT(ts: List[RTInfoObj], prefix = "-", total = 0'i64, overhead = 0'i64,
count = 0'u32, initIx = 0, showAbove = 0.0, showDropped = true): seq[Tstr] =
proc markMissing(p:bool,str:string):string =
if p: "[" & str & "]"
else: str
Expand Down
1 change: 0 additions & 1 deletion src/base/wrapperTypes.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import macros
export macros
import stdUtils
import metaUtils
import strutils

Expand Down
6 changes: 3 additions & 3 deletions src/comms/comms.nim
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ export commsQmp
var commsNames = newSeq[string](0)
var commsInits = newSeq[proc():Comm{.nimcall.}](0)
var commsFinis = newSeq[proc(){.nimcall.}](0)
proc commsGet(): seq[string] =
proc commsGet*(): seq[string] =
commsNames
proc commsGet(s: string): Comm =
proc commsGet*(s: string): Comm =
for i in 0..<commsNames.len:
if commsNames[i] == s:
return commsInits[i]()
proc commsGet(ss: openArray[string]): Comm =
proc commsGet*(ss: openArray[string]): Comm =
for s in ss:
result = commsGet(s)
if result != nil:
Expand Down
1 change: 1 addition & 0 deletions src/comms/commsQmp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ proc commsInitQmp* =
var prv = QMP_THREAD_FUNNELED
#var prv = QMP_THREAD_SERIALIZED
let err = QMP_init_msg_passing(argc.addr, argv.addr, prv, prv.addr)
doAssert(err == QMP_SUCCESS)
#discard err
#myRank = int(QMP_get_node_number())
#nRanks = int(QMP_get_number_of_nodes())
Expand Down
6 changes: 3 additions & 3 deletions src/comms/gather.nim
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,17 @@ type GatherField[S,D] = object
dest: D
elemsize: int
vlen: int
template copy(gd: GatherField, d: pointer, s: SomeInteger) =
template copy(gd: GatherField, d: pointer, s: SomeInteger) {.used.} =
mixin evalType
type T = evalType(gd.src{s})
let p = cast[ptr T](d)
p[] := gd.src{s}
template copy(gd: GatherField, d: SomeInteger, s: pointer) =
template copy(gd: GatherField, d: SomeInteger, s: pointer) {.used.} =
mixin evalType
type T = evalType(gd.dest{d})
let p = cast[ptr T](s)
gd.dest{d} := p[]
template copy(gd: GatherField, d: SomeInteger, s: SomeInteger) =
template copy(gd: GatherField, d: SomeInteger, s: SomeInteger) {.used.} =
mixin evalType
gd.dest{d} := gd.src{s}
proc gather*[D,S:Field](c: Comm; gm: GatherMap; d: D, s: S) =
Expand Down
5 changes: 3 additions & 2 deletions src/comms/qmp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ static:
{. passL: qmpPassL .}
{. pragma: qmp, importc, header:"qmp.h" .}

type QMP_status_t{.qmp.} = enum
test
type QMP_status_t*{.qmp.} = object
var QMP_SUCCESS*{.qmp.}:QMP_status_t

type QMP_thread_level_t*{.qmp.} = enum
QMP_THREAD_SINGLE,
QMP_THREAD_FUNNELED,
Expand Down
4 changes: 1 addition & 3 deletions src/io/reader.nim
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import os

when defined(QioReader):
static: echo "using QIO reader"
import readerQio
export readerQio
else:
static: echo "using Qiolite reader"
static: echo "Using Qiolite reader"
import readerQiolite
export readerQiolite
4 changes: 1 addition & 3 deletions src/io/writer.nim
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import os

when defined(QioWriter):
static: echo "using QIO writer"
import writerQio
export writerQio
else:
static: echo "using Qiolite writer"
static: echo "Using Qiolite writer"
import writerQiolite
export writerQiolite
10 changes: 5 additions & 5 deletions src/layout/qshifts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ const
MAXTHREADS = 512

proc aalloc(n: SomeInteger): pointer =
let a = 64
let b = a + sizeof(ByteAddress)
let x = cast[ByteAddress](alloc(n+b))
let a = 64'u
let b = a + sizeof(uint).uint
let x = cast[uint](alloc(n.uint+b))
let y = a * ((x+b) div a)
let z = cast[ptr ByteAddress](y - sizeof(ByteAddress))
let z = cast[ptr uint](y - sizeof(uint).uint)
z[] = x
cast[pointer](y)

proc afree(y: pointer) =
let z = cast[ptr pointer](cast[ByteAddress](y) - sizeof(ByteAddress))
let z = cast[ptr pointer](cast[uint](y) - sizeof(uint).uint)
dealloc(z[])

proc prepareShiftBufsQ*(sb: openArray[ptr ShiftBufQ];
Expand Down
1 change: 0 additions & 1 deletion src/maths/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ template mindexed*[T,I](x: T, i: I): untyped =
#static: echo "mindexed not isWrapper"
var tIndexed = indexedX(getAlias x, i)
tIndexed
import strUtils
template obj(x:Indexed):untyped =
#static: echo "obj: ", $type(x)
#static: echo $type(x.indexedPtr)
Expand Down
2 changes: 1 addition & 1 deletion src/rng/distribution.nim
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type
alg: NormalAlgorithm
func `$`*(d: NormalDistribution): string =
result = $d.type & system.`$`(d)
func normalDistribution(mean = 0.0, stddev = 1.0, alg = naBoxMuller):
func normalDistribution*(mean = 0.0, stddev = 1.0, alg = naBoxMuller):
NormalDistribution =
result.mean = mean
result.stddev = stddev
Expand Down
2 changes: 1 addition & 1 deletion src/rng/milcrng.nim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const
MASK = 0x00FFFFFF'u32
NUMINTS = 0x01000000'u32
SCALE = 1.0'f32 / 0x01000000.float32
SCALE1 = 1.0'f32 / MASK.float32
#SCALE1 = 1.0'f32 / MASK.float32

#template maxInt*(x: RngMilc6): int = int(MASK)
template maxInt*(x: typedesc[RngMilc6]): int = int(MASK)
Expand Down
2 changes: 2 additions & 0 deletions src/rng/mrg32k3a.nim
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ proc seed*(prn: var MRG32k3a; sed,index: auto) =
defaultComm.broadcast(ss.addr, sizeof(ss))
seedIndep(prn, ss, index)

#[
proc next0(prn: var MRG32k3a): float {.inline.} =
## Return random integer uniform on [1,m1]
var p1,p2:float
Expand All @@ -149,6 +150,7 @@ proc next0(prn: var MRG32k3a): float {.inline.} =
result = p1 - p2 + m1
else:
result = p1 - p2
]#

proc next(prn: var MRG32k3a): int {.inline.} =
## Return random integer uniform on [1,m1]
Expand Down
8 changes: 8 additions & 0 deletions src/simd.nim
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,35 @@ template makeBinaryMixed(S,D,op) =

when declared(SimdS1):
template eval*(x: SimdS1): untyped = x
template toSingle*(x: typedesc[SimdS1Obj]): typedesc = SimdS1Obj
template toDouble*(x: typedesc[SimdS1Obj]): typedesc = SimdD1Obj
template toSingleImpl*(x: SimdS1Obj): untyped = x
template toDoubleImpl*(x: SimdS1Obj): untyped = convert(x, SimdD1Obj)
mapSimd(SimdS1, exp)
mapSimd(SimdS1, ln)

when declared(SimdD1):
template eval*(x: SimdD1): untyped = x
template toSingle*(x: typedesc[SimdD1Obj]): typedesc = SimdS1Obj
template toDouble*(x: typedesc[SimdD1Obj]): typedesc = SimdD1Obj
template toSingleImpl*(x: SimdD1Obj): untyped = convert(x, SimdS1Obj)
template toDoubleImpl*(x: SimdD1Obj): untyped = x
mapSimd(SimdD1, exp)
mapSimd(SimdD1, ln)

when declared(SimdS2):
template eval*(x: SimdS2): untyped = x
template toSingle*(x: typedesc[SimdS2Obj]): typedesc = SimdS2Obj
template toDouble*(x: typedesc[SimdS2Obj]): typedesc = SimdD2Obj
template toSingleImpl*(x: SimdS2Obj): untyped = x
template toDoubleImpl*(x: SimdS2Obj): untyped = convert(x, SimdD2Obj)
mapSimd(SimdS2, exp)
mapSimd(SimdS2, ln)

when declared(SimdD2):
template eval*(x: SimdD2): untyped = x
template toSingle*(x: typedesc[SimdD2Obj]): typedesc = SimdS2Obj
template toDouble*(x: typedesc[SimdD2Obj]): typedesc = SimdD2Obj
template toSingleImpl*(x: SimdD2Obj): untyped = convert(x, SimdS2Obj)
template toDoubleImpl*(x: SimdD2Obj): untyped = x
mapSimd(SimdD2, exp)
Expand Down
1 change: 1 addition & 0 deletions src/simd/simdWrap.nim
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ template p2s(f: untyped) {.dirty.} =
template p3(f: untyped) {.dirty.} =
template f*[T1,T2,T3](x: var Simd[T1], y: Simd[T2], z: Simd[T3]) =
mixin f
#static: echo $type(y.toPrec(numberType(T1)))
f(x[], y.toPrec(numberType(T1))[], z.toPrec(numberType(T1))[])

template p3s(f: untyped) {.dirty.} =
Expand Down
6 changes: 2 additions & 4 deletions src/simd/simdX86Ops.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{. deadCodeElim: on .}

import simdX86Types
import simdSse
import simdAvx
Expand Down Expand Up @@ -137,9 +135,9 @@ template basicDefs(T,F,N,P,S:untyped) {.dirty.} =
template assign1*(r: var T; x: SomeNumber) =
r = `P "_set1_" S`(F(x))
template assign*(r: var T; x: SomeNumber) = assign1(r, x)
template setX:untyped {.gensym.} = `P "_setr_" S`()
template setF(x):untyped {.gensym.} = F(x)
macro assign*(r:var T; x:varargs[SomeNumber]):auto =
template setX:auto {.gensym.} = `P "_setr_" S`()
template setF(x):auto {.gensym.} = F(x)
if x.len==1:
result = newCall(ident"assign1", r, x[0])
else:
Expand Down

0 comments on commit a98047d

Please sign in to comment.