aboutsummaryrefslogtreecommitdiff
path: root/src/allocator.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-04-28 18:42:07 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-04-28 18:42:07 +0200
commitf0d35eb314ac52e4ec0f45f150de3d5224610c3b (patch)
tree6d6d1eb8481e5bdc8741e3ec5826933ca1b0ddc6 /src/allocator.py
parent3fce1d3f3c616eae0c319050276072932dd04d83 (diff)
downloadallocbench-f0d35eb314ac52e4ec0f45f150de3d5224610c3b.tar.gz
allocbench-f0d35eb314ac52e4ec0f45f150de3d5224610c3b.zip
add bumptr allocator implementation
Diffstat (limited to 'src/allocator.py')
-rw-r--r--src/allocator.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/allocator.py b/src/allocator.py
index 4e40ebf..04710c1 100644
--- a/src/allocator.py
+++ b/src/allocator.py
@@ -1,5 +1,6 @@
import copy
from datetime import datetime
+import inspect
import os
import shutil
import subprocess
@@ -8,6 +9,7 @@ import sys
import src.globalvars
from src.util import *
+
library_path = ""
for l in subprocess.run(["ldconfig", "-v"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@@ -26,6 +28,7 @@ class Allocator_Sources (object):
self.name = name
self.dir = os.path.join(srcdir, self.name)
self.retrieve_cmds = retrieve_cmds
+ self.patchdir = os.path.join("src/allocators/", self.name)
self.prepare_cmds = prepare_cmds
self.reset_cmds = reset_cmds
@@ -70,7 +73,7 @@ class Allocator_Sources (object):
print_status("Patching", self.name, "...")
for patch in patches:
- with open(patch, "rb") as f:
+ with open(patch.format(patchdir=self.patchdir), "rb") as f:
p = subprocess.run("patch -p1", shell=True, cwd=cwd,
stderr=subprocess.PIPE, stdout=stdout,
input=f.read())
@@ -106,8 +109,7 @@ class Allocator (object):
with open(buildtimestamp_file, "r") as f:
timestamp = datetime.fromtimestamp(float(f.read()))
- # print(globals())
- modtime = os.stat(os.path.realpath(src.globalvars.allocators_file)).st_mtime
+ modtime = os.stat(inspect.getfile(self.__class__)).st_mtime
modtime = datetime.fromtimestamp(modtime)
build_needed = timestamp < modtime
@@ -170,3 +172,5 @@ def patch_alloc(name, alloc, patches, **kwargs):
return new_alloc
+
+bumpptr = Allocator("bumpptr", LD_PRELOAD=os.path.join(builddir, "bumpptr_alloc.so"), color="C8")