Skip to content

Commit

Permalink
move PerfInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Dec 6, 2024
1 parent 235ed88 commit 476ef08
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
16 changes: 16 additions & 0 deletions src/base/profile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ getOptimPragmas()

const noTicToc {.boolDefine.} = false

type PerfInfo* = object
count*: int
flops*: float
secs*: float
template clear*(pi: var PerfInfo) =
pi.count = 0.0
pi.flops = 0.0
pi.secs = 0.0
template `+=`*(r: var PerfInfo, x: PerfInfo) =
r.count += x.count
r.flops += x.flops
r.secs += x.secs
proc `$`*(pi: PerfInfo): string =
result = system.`$`(pi)
result &= &" {1e-9*pi.flops/pi.secs:.2f} Gflops"

type TicType* = distinct int64
template getTics*: TicType = TicType(getMonoTime().ticks)
template nsec*(t:TicType):int64 = int64(t)
Expand Down
10 changes: 5 additions & 5 deletions src/gauge/fat7l.nim
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import base
import layout
#import gauge
#import strUtils

type PerfInfo* = object
flops*: float
export PerfInfo

type Fat7lCoefs* = object
oneLink*: float
Expand Down Expand Up @@ -168,6 +164,10 @@ proc makeImpLinks*(info: var PerfInfo, fl: auto, gf: auto, coef: auto,
#info.final_flop = nflop*QDP_sites_on_node;
#info.status = QOP_SUCCESS;
toc()
inc info.count
info.flops += nflop * gf[0].l.localGeom.prod
info.secs += getElapsedTime()

proc makeImpLinks*(info: var PerfInfo, fl: auto, gf: auto, coef: auto) =
makeImpLinks(info, fl, gf, coef, fl, gf, 0.0)

Expand Down
8 changes: 5 additions & 3 deletions src/gauge/fat7lderiv.nim
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,8 @@ proc fat7lderiv(perf: var PerfInfo, gauge: auto, deriv: auto,
#info->status = QOP_SUCCESS;

when isMainModule:
import qex
import physics/qcdTypes
import gauge
import qex, physics/qcdTypes
import strformat
qexInit()
#var defaultGaugeFile = "l88.scidac"
let defaultLat = @[8,8,8,8]
Expand Down Expand Up @@ -324,7 +323,9 @@ when isMainModule:
echo g.plaq
echo g2.plaq
makeImpLinks(info, fl, g, coef)
echo info
makeImpLinks(info, fl2, g2, coef)
echo info
echo fl.plaq
echo fl2.plaq
#echo ll.plaq
Expand All @@ -335,6 +336,7 @@ when isMainModule:
#echo pow(1.0+6.0+6.0*4.0+6.0*4.0*2.0+6.0,4)/6.0

fat7lderiv(info, g, fd, coef, dg)
echo info
for mu in 0..3:
dfl[mu] := fl2[mu] - fl[mu]
echo dfl[mu].norm2
Expand Down

0 comments on commit 476ef08

Please sign in to comment.