#!/usr/bin/python import os import copy import sys import string import pwd import smtplib import socket import time import itertools import multiprocessing from run.executable.executable import Executable test_mode = False email_notification = True def run_exp(nsamples, ncpu, numa_args, wss, wcycle, sleep_range_ms, walk, do_pollute, do_huge_pages, do_uncache_pages): fstub = 'pmo' fstub += '_host='+socket.gethostname().split('.')[0] fstub += '_ncpu='+str(ncpu) fstub += '_wss='+str(wss) fstub += '_wcycle='+str(wcycle) fstub += '_smin='+str(sleep_range_ms[0]*1000) fstub += '_smax='+str(sleep_range_ms[1]*1000) fstub += '_polluters='+str(do_pollute) fstub += '_hpages='+str(do_huge_pages) fstub += '_upages='+str(do_uncache_pages) fstub += '_walk='+walk filename = fstub + '.csv' if os.path.exists(filename): return polluters = [] if do_pollute: for i in range(multiprocessing.cpu_count()): if numa_args: # number of CPUs in one of two NUMA nodes if ncpu == 6: if i < 6: numa_hack = ['--cpunodebind=0', '--interleave=0'] else: numa_hack = ['--cpunodebind=1', '--interleave=1'] else: numa_hack = ['--cpunodebind=0,1', '--interleave=0,1'] args = copy.deepcopy(numa_hack) args.append('memthrash') else: args = [] args.append('-m') args.append(str(i)) if numa_args: polluters.append(Executable('numactl', args)) else: polluters.append(Executable('memthrash', args)) if numa_args: args = copy.deepcopy(numa_args) args.append('cache_cost') else: args = [] args.append('-m') args.append(str(ncpu)) args.append('-c') args.append(str(nsamples)) args.append('-s') args.append(str(wss)) args.append('-w') args.append(str(wcycle)) if do_huge_pages: args.append('-h') if do_uncache_pages: args.append('-u') # cache_cost wants time in microseconds args.append('-x') args.append(str(sleep_range_ms[0]*1000)) args.append('-y') args.append(str(sleep_range_ms[1]*1000)) if walk == 'rand': args.append('-r') args.append('-o') args.append(filename) if numa_args: probe = Executable('numactl', args) else: probe = Executable('cache_cost', args) if not test_mode: if do_pollute: for p in polluters: p.execute() time.sleep(10) probe.execute() probe.wait() for p in polluters: p.kill() for p in polluters: p.wait(False) else: print 'Process commands and arguments: ' if do_pollute: for p in polluters: print str(p) print str(probe) def send_email(_to, _msg): user = pwd.getpwuid(os.getuid())[0] host = socket.gethostname() _from = "%s@%s" % (user, host) _body = "\r\n".join(["From: %s" % _from, "To: %s" % _to, "Subject: Test Completed!", "", "{}"]) mail = smtplib.SMTP("localhost") mail.sendmail(_from, [_to], _body.format(_msg)) mail.quit() def main(argv): nsamples = 5000 # We may need to test different NUMA node configurations # according to memory interleaving across the NUMA topology. # # For non-numa systems, do "<#cpu>: []" # Ex., for a 4-CPU non-numa system: "4: []" # # NOTE: Must update NUMA hack in run_exp() for memthrash # for your configuration. # # todo: configure numa args for system automatically ncpu_and_numa_args = { 24: [] } wss_kb = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 3072, 4096, 8192, 12288, 16384] write_cycle = [16, 4, 2] # write_cycle = [0] sleep_range_ms = [0,50] # uncache = [False, True] uncache = [False] huge_pages = [False] pollute = [False, True] # walk = ['seq', 'rand'] walk = ['seq'] # disable rt throttling in linux scheduler os.system("echo -1 > /proc/sys/kernel/sched_rt_runtime_us") for ncpu, numa_args in ncpu_and_numa_args.iteritems(): for u in uncache: for h in huge_pages: if u == True and h == True: # skip invalid combo continue for wcycle in write_cycle: for w in walk: for p in pollute: for wss in wss_kb: run_exp(nsamples, ncpu, numa_args, wss, wcycle, sleep_range_ms, w, p, h, u) if email_notification: to = "gelliott@cs.unc.edu" msg = "Cache Ovh Collection Complete!" send_email(to, msg) if __name__ == "__main__": os.environ['PATH'] += ':../liblitmus' os.environ['PATH'] += ':../cache-ovh' if 'LD_LIBRARY_PATH' not in os.environ: os.environ['LD_LIBRARY_PATH'] = '' os.environ['LD_LIBRARY_PATH'] += ':../liblitmus' main(sys.argv[1:])