Skip to content

Commit

Permalink
make profiling use allocShared
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Jul 25, 2024
1 parent f31c1b2 commit c6a86cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/base/profile.nim
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ proc newList[T](len:int32 = 0):List[T] {.noinit.} =
result.len = len
result.cap = cap
if cap > 0:
result.data = cast[ptr UncheckedArray[T]](alloc(sizeof(T)*cap))
result.data = cast[ptr UncheckedArray[T]](allocShared(sizeof(T)*cap))
listChangeLen[T](cap)
else:
result.data = nil
proc newListOfCap[T](cap:int32):List[T] {.noinit.} =
result.len = 0
result.cap = cap
if cap > 0:
result.data = cast[ptr UncheckedArray[T]](alloc(sizeof(T)*cap))
result.data = cast[ptr UncheckedArray[T]](allocShared(sizeof(T)*cap))
listChangeLen[T](cap)
else:
result.data = nil
Expand All @@ -92,16 +92,16 @@ proc setLen[T](ls:var List[T], len:int32) =
if cap0 == 0:
cap = 1
while cap < len: cap *= 2
ls.data = cast[ptr UncheckedArray[T]](alloc(sizeof(T)*cap.int))
ls.data = cast[ptr UncheckedArray[T]](allocShared(sizeof(T)*cap.int))
else:
while cap < len: cap *= 2
ls.data = cast[ptr UncheckedArray[T]](realloc(ls.data, sizeof(T)*cap.int))
ls.data = cast[ptr UncheckedArray[T]](reallocShared(ls.data, sizeof(T)*cap.int))
ls.cap = cap
listChangeLen[T](int32(cap-cap0))
ls.len = len
proc free[T](ls:var List[T]) =
if ls.cap > 0:
dealloc(ls.data)
deallocShared(ls.data)
listChangeLen[T](-ls.cap)
ls.len = 0
ls.cap = 0
Expand Down
3 changes: 2 additions & 1 deletion src/experimental/stagag.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2098,5 +2098,6 @@ if outfn != "":
echo "Saving gauge field to file: ", outfn
let err = g.saveGauge outfn

#echoTimers()
if intParam("prof",0) != 0:
echoTimers()
qexFinalize()

0 comments on commit c6a86cc

Please sign in to comment.