Skip to content

Commit

Permalink
Malloc trim after each harness
Browse files Browse the repository at this point in the history
Change-Id: Ie1275ce096cca59a38e17215f1aa86032e7c6eca
  • Loading branch information
Jeffwhen committed Feb 5, 2023
1 parent dd76be4 commit 866ea0b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/tpu_perf/precision_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def writerow(self, *args, **kw_args):
self.writer.writerow(*args, **kw_args)
self.fd.flush()

import ctypes
def malloc_trim():
try:
ctypes.CDLL('libc.so.6').malloc_trim(0)
except OSError as err:
logging.error(f'{err}')

class Runner:
def __init__(self):
self.stat_files = dict()
Expand Down Expand Up @@ -43,6 +50,7 @@ def get_csv(stats):
logging.warning(f'{bmodel} does not exist')
continue
stats = harness(tree, config, args)
malloc_trim()
name = [f'{config["name"]}-{args["name"]}']
get_csv(stats).writerow(name + [
f'{v:.2%}' if type(v) == float else str(v)
Expand Down

0 comments on commit 866ea0b

Please sign in to comment.