From 476ef08e4b67de2d86fde81de852bdd36e9620d1 Mon Sep 17 00:00:00 2001 From: James Osborn Date: Fri, 6 Dec 2024 10:40:26 -0600 Subject: [PATCH] move PerfInfo --- src/base/profile.nim | 16 ++++++++++++++++ src/gauge/fat7l.nim | 10 +++++----- src/gauge/fat7lderiv.nim | 8 +++++--- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/base/profile.nim b/src/base/profile.nim index de7ca62..455e399 100644 --- a/src/base/profile.nim +++ b/src/base/profile.nim @@ -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) diff --git a/src/gauge/fat7l.nim b/src/gauge/fat7l.nim index 9fdaea1..1a11024 100644 --- a/src/gauge/fat7l.nim +++ b/src/gauge/fat7l.nim @@ -1,10 +1,6 @@ import base import layout -#import gauge -#import strUtils - -type PerfInfo* = object - flops*: float +export PerfInfo type Fat7lCoefs* = object oneLink*: float @@ -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) diff --git a/src/gauge/fat7lderiv.nim b/src/gauge/fat7lderiv.nim index f77b309..a579e4f 100644 --- a/src/gauge/fat7lderiv.nim +++ b/src/gauge/fat7lderiv.nim @@ -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] @@ -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 @@ -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