refactor iperf conf to human readable

This commit is contained in:
quackerd 2022-11-22 13:58:33 +01:00
parent e85928e3f5
commit 933e9708f3
2 changed files with 210 additions and 221 deletions

View File

@ -8,7 +8,11 @@ import numpy as np
import libpar as par
import libtc as tc
import iperfconf as ic
# definitions
file_dir : str = os.path.dirname(os.path.realpath(__file__))
root_dir : str = os.path.join(file_dir,"..")
LOG_FILEPATH = "/iperflogs"
BIN_PATH = "/iperftls"
MLG_PATH = "/numam/build/bin/memloadgen"
@ -17,278 +21,149 @@ SSL_CERT = "/certs/server.crt"
SSL_PKEY = "/certs/server.key"
SERVER_PORT_START = 8050
MEMLOAD_BLKSZ = 1024*1024*64
RUNS=5
RUNS=3
MILAN_CPULIST : ic.CPUList = ic.CPUList([64, 64])
ICELAKE_CPULIST : ic.CPUList = ic.CPUList([48, 48])
# paths
file_dir : str = os.path.dirname(os.path.realpath(__file__))
root_dir : str = os.path.join(file_dir,"..")
# Shared Arguments
NUM_CORES = 12
NUM_CLIENTS = 3
# KTLS
KTLS_ARGS = [(False, False, False),
(True, False, False),
(False, True, False),
(False, True, True),
(True, True, True)]
class Conf:
def __init__(self, server, clients, server_dat, clients_dat, clients_affinity, affinity, sendfile, tls, ktls, memloadgen, filepath, odirect):
self.affinity = affinity
self.ktls = ktls
self.sendfile = sendfile
self.tls = tls
self.odirect = odirect
self.memloadgen = memloadgen
self.filepath = filepath
self.server = server
self.clients = clients
self.server_dat = server_dat
self.clients_dat = clients_dat
self.clients_affinity = clients_affinity
# MEMLOADGEN
MEMLOADGEN_ARGS_ICELAKE = []
for i in range(0, 100, 10):
MEMLOADGEN_ARGS_ICELAKE.append([f"{ICELAKE_CPULIST.get_cpulist_by_offset(domain = 1, offset = 3, num = NUM_CORES, stride = 4)}.0.{i}",
f"{ICELAKE_CPULIST.get_cpulist_by_offset(domain = 0, offset = 3, num = NUM_CORES, stride = 4)}.1.{i}"])
MEMLOADGEN_ARGS_ICELAKE.append(None)
def to_string(self):
return f"server.{self.server[0]}_affinity.{self.affinity}_sendfile.{self.sendfile}_tls.{self.tls}_ktls.{self.ktls}_memloadgen.{False if self.memloadgen == None else (self.memloadgen[0].split('.')[2])}_filepath.{self.filepath.replace('/','-')}_odirect.{self.odirect}"
class ArgTypes:
def __init__(self):
self.all = [[]]
def add_arg(self, arg : list[list[any]]):
new_all = []
for val in arg:
for exst in self.all:
tmp = exst.copy()
tmp.extend(val)
new_all.append(tmp)
self.all = new_all
def get_fields(self) -> list[list[any]]:
return self.all
MEMLOADGEN_ARGS_MILAN = []
for i in range(0, 100, 10):
MEMLOADGEN_ARGS_MILAN.append([f"{MILAN_CPULIST.get_cpulist_by_offset(domain = 1, offset = 3, num = NUM_CORES, stride = 4)}.0.{i}",
f"{MILAN_CPULIST.get_cpulist_by_offset(domain = 0, offset = 3, num = NUM_CORES, stride = 4)}.1.{i}"])
MEMLOADGEN_ARGS_MILAN.append(None)
# client thread affinity
CLIENT_ASSIGNMENTS = ic.distribute_threads(NUM_CORES, 1, NUM_CLIENTS, 2)
CLIENT_AFFINITY = []
for i in range(NUM_CLIENTS):
CLIENT_AFFINITY.append(ic.list_to_comma_delimited(CLIENT_ASSIGNMENTS[i]))
# server thread affinity
ICELAKE_SERVER_AFFINITY_SOCKET0 = ICELAKE_CPULIST.get_cpulist_by_offset(domain = 0, offset = 1, num = NUM_CORES, stride = 4)
ICELAKE_SERVER_AFFINITY_SOCKET1 = ICELAKE_CPULIST.get_cpulist_by_offset(domain = 1, offset = 1, num = NUM_CORES, stride = 4)
MILAN_SERVER_AFFINITY_SOCKET0 = MILAN_CPULIST.get_cpulist_by_offset(domain = 0, offset = 1, num = NUM_CORES, stride = 4)
MILAN_SERVER_AFFINITY_SOCKET1= MILAN_CPULIST.get_cpulist_by_offset(domain = 1, offset = 1, num = NUM_CORES, stride = 4)
# file system
FILE_PATHS = ["/tmpfs/large_file_#p"]
class CPUList:
def __init__(self, cores : list[int]):
self._cores = cores
self._total_cores = np.sum(cores)
self._offset_lookup : list[int] = []
for i in range(len(cores)):
self._offset_lookup.append(0)
if (i == 0):
self._offset_lookup[i] = 0
else:
self._offset_lookup[i] = self._offset_lookup[i-1] + cores[i-1]
def get_all_cores(self) -> int:
return self._total_cores
def get_cores_in_domain(self, domain : int) -> int:
return self._cores[domain]
def cores_to_cpulist(self, cores : list[int]) -> str:
ret = ""
for i in range(len(cores)):
if (i > 0):
ret += ","
ret += str(cores[i])
return ret
def get_cpulist_by_offset(self, domain : int, offset : int, num : int, stride : int) -> str:
ret = self.get_cores_by_offset(domain, offset, num, stride)
return self.cores_to_cpulist(ret)
def get_cores_by_offset(self, domain : int, offset : int, num : int, stride : int) -> list[int]:
ret = []
offset = offset + self._offset_lookup[domain]
for _ in range(num):
ret.append(offset)
offset = offset + stride
return ret
MILAN_CPULIST : CPUList = CPUList([64, 64])
ICELAKE_CPULIST : CPUList = CPUList([48, 48])
# print(MILAN_CPULIST.get_cpustr_domain(1, 1, int(MILAN_CPULIST.get_cores(1) / 2), 1))
# print(ICELAKE_CPULIST.get_cpustr_domain(1, 1, int(ICELAKE_CPULIST.get_cores(1) / 2), 1))
# print(MILAN_CPULIST.get_cpustr_domain(0, 0, int(MILAN_CPULIST.get_cores(0) / 2), 1))
# print(ICELAKE_CPULIST.get_cpustr_domain(0, 0, int(ICELAKE_CPULIST.get_cores(0) / 2), 1))
# exit()
def distribute_threads(num_threads : int, offset : int, num_clients : int, hyperthreads : bool = True):
stride = 1
if hyperthreads:
stride = 2
client_strs : list[list[int]] = []
for i in range(0, num_clients):
client_strs.append([])
for i in range(0, num_threads):
cur_client = i % num_clients
lst = client_strs[cur_client]
if (len(lst) == 0):
lst.append(offset)
else:
lst.append(lst[-1] + stride)
return client_strs
def list_to_comma_delimited(list : list[any]):
ret = ""
for i in range(0, len(list)):
if (i > 0):
ret += ","
ret += str(list[i])
return ret
num_cores = 12
all_args : list[ArgTypes] = []
arg_types : ArgTypes = ArgTypes()
# args start
all_args : list[ic.ArgTypes] = []
arg_types : ic.ArgTypes = ic.ArgTypes()
#server
arg_types.add_arg([[["icelake2-int.rcs.uwaterloo.ca"]]])
arg_types.add_arg(["icelake2-int.rcs.uwaterloo.ca"])
#clients
arg_types.add_arg([[["icelake1-int.rcs.uwaterloo.ca", "milan2-int.rcs.uwaterloo.ca", "milan1-int.rcs.uwaterloo.ca"]]])
arg_types.add_arg(["icelake1-int.rcs.uwaterloo.ca", "milan2-int.rcs.uwaterloo.ca", "milan1-int.rcs.uwaterloo.ca"])
#server_dat
arg_types.add_arg([[["192.168.100.102"]]])
arg_types.add_arg(["192.168.100.102"])
#clients_dat
arg_types.add_arg([[["192.168.100.101", "192.168.100.104", "192.168.100.103"]]])
arg_types.add_arg(["192.168.100.101", "192.168.100.104", "192.168.100.103"])
#clients_affinity
assignments = distribute_threads(num_cores, 1, 3)
arg_types.add_arg([[[list_to_comma_delimited(assignments[0]),
list_to_comma_delimited(assignments[1]),
list_to_comma_delimited(assignments[2])]]])
arg_types.add_arg(CLIENT_AFFINITY)
# affinity
# arg_types.add_arg([[ICELAKE_CPULIST.get_cpustr_domain(domain = 0, offset = 1, num = num_cores)],
# [ICELAKE_CPULIST.get_cpustr_domain(domain = 1, offset = 1, num = num_cores)]])
arg_types.add_arg([[ICELAKE_CPULIST.get_cpulist_by_offset(domain = 0, offset = 1, num = num_cores, stride = 4)],
[ICELAKE_CPULIST.get_cpulist_by_offset(domain = 1, offset = 1, num = num_cores, stride = 4)]])
arg_types.add_arg(ICELAKE_SERVER_AFFINITY_SOCKET0, ICELAKE_SERVER_AFFINITY_SOCKET1)
# sendfile/tls/ktls
arg_types.add_arg([
[False, False, False],
[True, False, False],
[False, True, False],
[False, True, True],
[True, True, True],
])
arg_types.add_args(*KTLS_ARGS)
# memloadgen
arg_types.add_arg([[[f"{ICELAKE_CPULIST.get_cpulist_by_offset(domain = 1, offset = 3, num = num_cores, stride = 4)}.0.0",
f"{ICELAKE_CPULIST.get_cpulist_by_offset(domain = 0, offset = 3, num = num_cores, stride = 4)}.1.0"]],
[[f"{ICELAKE_CPULIST.get_cpulist_by_offset(domain = 1, offset = 3, num = num_cores, stride = 4)}.0.50",
f"{ICELAKE_CPULIST.get_cpulist_by_offset(domain = 0, offset = 3, num = num_cores, stride = 4)}.1.50"]],
[None]] )
arg_types.add_arg(*MEMLOADGEN_ARGS_ICELAKE)
# filepath
arg_types.add_arg([["/tmpfs/large_file_#p"], ["/mnt/zroot/large_file_#p"]])
arg_types.add_arg(*FILE_PATHS)
# ODIRECT
arg_types.add_arg([[False]])
arg_types.add_arg(False)
all_args.append(arg_types)
arg_types : ArgTypes = ArgTypes()
arg_types : ic.ArgTypes = ic.ArgTypes()
#server
arg_types.add_arg([[["icelake1-int.rcs.uwaterloo.ca"]]])
arg_types.add_arg(["icelake1-int.rcs.uwaterloo.ca"])
#clients
arg_types.add_arg([[["icelake2-int.rcs.uwaterloo.ca", "milan2-int.rcs.uwaterloo.ca", "milan1-int.rcs.uwaterloo.ca"]]])
arg_types.add_arg(["icelake2-int.rcs.uwaterloo.ca", "milan2-int.rcs.uwaterloo.ca", "milan1-int.rcs.uwaterloo.ca"])
#server_dat
arg_types.add_arg([[["192.168.100.101"]]])
arg_types.add_arg(["192.168.100.101"])
#clients_dat
arg_types.add_arg([[["192.168.100.102", "192.168.100.104", "192.168.100.103"]]])
arg_types.add_arg(["192.168.100.102", "192.168.100.104", "192.168.100.103"])
#clients_affinity
assignments = distribute_threads(num_cores, 1, 3)
arg_types.add_arg([[[list_to_comma_delimited(assignments[0]),
list_to_comma_delimited(assignments[1]),
list_to_comma_delimited(assignments[2])]]])
arg_types.add_arg(CLIENT_AFFINITY)
# affinity
arg_types.add_arg([[ICELAKE_CPULIST.get_cpulist_by_offset(domain = 0, offset = 1, num = num_cores, stride = 4)]])
arg_types.add_arg(ICELAKE_SERVER_AFFINITY_SOCKET0)
# sendfile/tls/ktls
arg_types.add_arg([
[False, False, False],
[True, False, False],
[False, True, False],
[False, True, True],
[True, True, True],
])
arg_types.add_args(*KTLS_ARGS)
# memloadgen
arg_types.add_arg([[[f"{ICELAKE_CPULIST.get_cpulist_by_offset(domain = 1, offset = 3, num = num_cores, stride = 4)}.0.0",
f"{ICELAKE_CPULIST.get_cpulist_by_offset(domain = 0, offset = 3, num = num_cores, stride = 4)}.1.0"]],
[[f"{ICELAKE_CPULIST.get_cpulist_by_offset(domain = 1, offset = 3, num = num_cores, stride = 4)}.0.50",
f"{ICELAKE_CPULIST.get_cpulist_by_offset(domain = 0, offset = 3, num = num_cores, stride = 4)}.1.50"]],
[None]] )
arg_types.add_arg(*MEMLOADGEN_ARGS_ICELAKE)
# filepath
arg_types.add_arg([["/tmpfs/large_file_#p"], ["/mnt/zroot/large_file_#p"]])
arg_types.add_arg(*FILE_PATHS)
# ODIRECT
arg_types.add_arg([[False]])
arg_types.add_arg(False)
all_args.append(arg_types)
arg_types : ArgTypes = ArgTypes()
arg_types : ic.ArgTypes = ic.ArgTypes()
#server
arg_types.add_arg([[["milan1-int.rcs.uwaterloo.ca"]]])
arg_types.add_arg(["milan1-int.rcs.uwaterloo.ca"])
#clients
arg_types.add_arg([[["icelake2-int.rcs.uwaterloo.ca", "milan2-int.rcs.uwaterloo.ca", "icelake1-int.rcs.uwaterloo.ca"]]])
arg_types.add_arg(["icelake2-int.rcs.uwaterloo.ca", "milan2-int.rcs.uwaterloo.ca", "icelake1-int.rcs.uwaterloo.ca"])
#server_dat
arg_types.add_arg([[["192.168.100.103"]]])
arg_types.add_arg(["192.168.100.103"])
#clients_dat
arg_types.add_arg([[["192.168.100.102", "192.168.100.104", "192.168.100.101"]]])
arg_types.add_arg(["192.168.100.102", "192.168.100.104", "192.168.100.101"])
#clients_affinity
assignments = distribute_threads(num_cores, 1, 3)
arg_types.add_arg([[[list_to_comma_delimited(assignments[0]),
list_to_comma_delimited(assignments[1]),
list_to_comma_delimited(assignments[2])]]])
arg_types.add_arg(CLIENT_AFFINITY)
# affinity
arg_types.add_arg([[MILAN_CPULIST.get_cpulist_by_offset(domain = 0, offset = 1, num = num_cores, stride = 4)]])
arg_types.add_arg(MILAN_SERVER_AFFINITY_SOCKET0)
# sendfile/tls/ktls
arg_types.add_arg([
[False, False, False],
[True, False, False],
[False, True, False],
[False, True, True],
[True, True, True],
])
arg_types.add_args(*KTLS_ARGS)
# memloadgen
arg_types.add_arg([[[f"{MILAN_CPULIST.get_cpulist_by_offset(domain = 1, offset = 3, num = num_cores, stride = 4)}.0.0",
f"{MILAN_CPULIST.get_cpulist_by_offset(domain = 0, offset = 3, num = num_cores, stride = 4)}.1.0"]],
[[f"{MILAN_CPULIST.get_cpulist_by_offset(domain = 1, offset = 3, num = num_cores, stride = 4)}.0.50",
f"{MILAN_CPULIST.get_cpulist_by_offset(domain = 0, offset = 3, num = num_cores, stride = 4)}.1.50"]],
[None]] )
arg_types.add_arg(*MEMLOADGEN_ARGS_MILAN)
# filepath
arg_types.add_arg([["/mnt/zroot/large_file_#p"], ["/tmpfs/large_file_#p"]])
arg_types.add_arg(*FILE_PATHS)
# ODIRECT
arg_types.add_arg([[False]])
arg_types.add_arg(False)
all_args.append(arg_types)
arg_types : ArgTypes = ArgTypes()
arg_types : ic.ArgTypes = ic.ArgTypes()
#server
arg_types.add_arg([[["milan2-int.rcs.uwaterloo.ca"]]])
arg_types.add_arg(["milan2-int.rcs.uwaterloo.ca"])
#clients
arg_types.add_arg([[["icelake2-int.rcs.uwaterloo.ca", "milan1-int.rcs.uwaterloo.ca", "icelake1-int.rcs.uwaterloo.ca"]]])
arg_types.add_arg(["icelake2-int.rcs.uwaterloo.ca", "milan1-int.rcs.uwaterloo.ca", "icelake1-int.rcs.uwaterloo.ca"])
#server_dat
arg_types.add_arg([[["192.168.100.104"]]])
arg_types.add_arg(["192.168.100.104"])
#clients_dat
arg_types.add_arg([[["192.168.100.102", "192.168.100.103", "192.168.100.101"]]])
arg_types.add_arg(["192.168.100.102", "192.168.100.103", "192.168.100.101"])
#clients_affinity
assignments = distribute_threads(num_cores, 1, 3)
arg_types.add_arg([[[list_to_comma_delimited(assignments[0]),
list_to_comma_delimited(assignments[1]),
list_to_comma_delimited(assignments[2])]]])
arg_types.add_arg(CLIENT_AFFINITY)
# affinity
arg_types.add_arg([[MILAN_CPULIST.get_cpulist_by_offset(domain = 0, offset = 1, num = num_cores, stride = 4)],
[MILAN_CPULIST.get_cpulist_by_offset(domain = 1, offset = 1, num = num_cores, stride = 4)]])
arg_types.add_arg(MILAN_SERVER_AFFINITY_SOCKET0, MILAN_SERVER_AFFINITY_SOCKET1)
# sendfile/tls/ktls
arg_types.add_arg([
[False, False, False],
[True, False, False],
[False, True, False],
[False, True, True],
[True, True, True],
])
arg_types.add_args(*KTLS_ARGS)
# memloadgen
arg_types.add_arg([[[f"{MILAN_CPULIST.get_cpulist_by_offset(domain = 1, offset = 3, num = num_cores, stride = 4)}.0.0",
f"{MILAN_CPULIST.get_cpulist_by_offset(domain = 0, offset = 3, num = num_cores, stride = 4)}.1.0"]],
[[f"{MILAN_CPULIST.get_cpulist_by_offset(domain = 1, offset = 3, num = num_cores, stride = 4)}.0.50",
f"{MILAN_CPULIST.get_cpulist_by_offset(domain = 0, offset = 3, num = num_cores, stride = 4)}.1.50"]],
[None]] )
arg_types.add_arg(*MEMLOADGEN_ARGS_MILAN)
# filepath
arg_types.add_arg([["/mnt/zroot/large_file_#p"], ["/tmpfs/large_file_#p"]])
arg_types.add_arg(*FILE_PATHS)
# ODIRECT
arg_types.add_arg([[False]])
arg_types.add_arg(False)
all_args.append(arg_types)
def parse_comma_list(input : str):
return input.split(",")
def run_setup_cmd(conf : Conf, cmd : str):
def run_setup_cmd(conf : ic.Conf, cmd : str):
ssrv : list[tuple[str, sp.Popen]] = []
tc.log_print(f"Running command on {conf.server[0]}...")
ssrv.append((conf.server[0], tc.remote_exec(conf.server, cmd, blocking=False, check=False)[0]))
@ -304,10 +179,11 @@ def run_setup_cmd(conf : Conf, cmd : str):
else:
print(f"\n{ p[0] } succeeded\n")
def setup_all(conf : Conf):
def setup_all(conf : ic.Conf):
setup_cmd : str = f'''
sudo pkg install -y openssl-devel vim curl wget gmake cmake openssl-devel llvm gcc rsync pkgconf isal-kmod ktls_isa-l_crypto-kmod;
sudo pkg remove -y iperf iperf3;
sudo kldload -n isal; sudo kldload -n ktls_intel-isa-l;
sudo rm -rf { BIN_PATH };
sudo mkdir -p { BIN_PATH };
sudo git clone https://git.quacker.org/d/iperf3-tls { BIN_PATH };
@ -348,7 +224,7 @@ def setup_all(conf : Conf):
''')
def stop_all(conf : Conf, clients_only = False):
def stop_all(conf : ic.Conf, clients_only = False):
# stop clients
tc.log_print("Stopping clients...")
tc.remote_exec(conf.clients, "sudo killall -9 iperf3; sudo killall -9 memloadgen", check=False)
@ -357,7 +233,7 @@ def stop_all(conf : Conf, clients_only = False):
tc.log_print("Stopping server...")
tc.remote_exec(conf.server, "sudo killall -9 iperf3; sudo killall -9 memloadgen", check=False)
def prepare_logdir(conf : Conf):
def prepare_logdir(conf : ic.Conf):
tc.log_print("Preparing server log directory...")
prep_cmd = "sudo rm -rf " + LOG_FILEPATH
tc.log_print(prep_cmd)
@ -369,7 +245,7 @@ def prepare_logdir(conf : Conf):
tc.log_print(prep_cmd)
tc.remote_exec(conf.server, prep_cmd, check=True)
def run_exp(conf : Conf):
def run_exp(conf : ic.Conf):
stop_all(conf)
while True:
prepare_logdir(conf)
@ -489,7 +365,7 @@ def run_exp(conf : Conf):
if flush_netresult(conf):
break
def flush_netresult(conf : Conf) -> bool:
def flush_netresult(conf : ic.Conf) -> bool:
tc.log_print("Keeping results...")
# copy log directory back to machine
log_output = tc.get_odir()
@ -546,11 +422,11 @@ def main():
tc.set_ssh_user("oscar")
output_dirname = "run"
confs : list[Conf] = []
confs : list[ic.Conf] = []
for argtype in all_args:
args = argtype.get_fields()
for arg in args:
confs.append(Conf(*arg))
confs.append(ic.Conf(*arg))
options = getopt.getopt(sys.argv[1:], 'sS')[0]
for opt, arg in options:
@ -566,9 +442,9 @@ def main():
tc.log_print(cpcmd)
sp.check_call(cpcmd, shell=True)
print(f"{len(confs)} configs to run:")
for conf in confs:
print(conf.to_string())
print(conf.to_string(verbose=True))
print(f"{len(confs)} configs ({RUNS} * {len(confs)} = {RUNS * len(confs)} runs) scheduled:")
for conf in confs:
for i in range(0, RUNS):

113
scripts/libs/iperfconf.py Normal file
View File

@ -0,0 +1,113 @@
import numpy as np
class Conf:
def __init__(self, server, clients, server_dat, clients_dat, clients_affinity, affinity, sendfile, tls, ktls, memloadgen, filepath, odirect):
self.affinity = affinity
self.ktls = ktls
self.sendfile = sendfile
self.tls = tls
self.odirect = odirect
self.memloadgen = memloadgen
self.filepath = filepath
self.server = server
self.clients = clients
self.server_dat = server_dat
self.clients_dat = clients_dat
self.clients_affinity = clients_affinity
def to_string(self, verbose = False):
ret = f"server.{self.server[0]}_affinity.{self.affinity}_sendfile.{self.sendfile}_tls.{self.tls}_ktls.{self.ktls}_"
if verbose:
ret += f"memloadgen.{False if self.memloadgen == None else (self.memloadgen[0] + '+' + self.memloadgen[1])}"
else:
ret += f"memloadgen.{False if self.memloadgen == None else (self.memloadgen[0].split('.')[2])}"
ret += f"_filepath.{self.filepath.replace('/','-')}_odirect.{self.odirect}"
return ret
class ArgTypes:
def __init__(self):
self.all = [[]]
def add_arg(self, *arg : any):
new_all = []
for val in arg:
for exst in self.all:
tmp = exst.copy()
tmp.append(val)
new_all.append(tmp)
self.all = new_all
def add_args(self, *args : tuple[any]):
new_all = []
for arg in args:
for exst in self.all:
tmp = exst.copy()
for val in arg:
tmp.append(val)
new_all.append(tmp)
self.all = new_all
def get_fields(self) -> list[list[any]]:
return self.all
class CPUList:
def __init__(self, cores : list[int]):
self._cores = cores
self._total_cores = np.sum(cores)
self._offset_lookup : list[int] = []
for i in range(len(cores)):
self._offset_lookup.append(0)
if (i == 0):
self._offset_lookup[i] = 0
else:
self._offset_lookup[i] = self._offset_lookup[i-1] + cores[i-1]
def get_all_cores(self) -> int:
return self._total_cores
def get_cores_in_domain(self, domain : int) -> int:
return self._cores[domain]
def cores_to_cpulist(self, cores : list[int]) -> str:
ret = ""
for i in range(len(cores)):
if (i > 0):
ret += ","
ret += str(cores[i])
return ret
def get_cpulist_by_offset(self, domain : int, offset : int, num : int, stride : int) -> str:
ret = self.get_cores_by_offset(domain, offset, num, stride)
return self.cores_to_cpulist(ret)
def get_cores_by_offset(self, domain : int, offset : int, num : int, stride : int) -> list[int]:
ret = []
offset = offset + self._offset_lookup[domain]
for _ in range(num):
ret.append(offset)
offset = offset + stride
return ret
def distribute_threads(num_threads : int, offset : int, num_clients : int, stride : int):
client_strs : list[list[int]] = []
for i in range(0, num_clients):
client_strs.append([])
for i in range(0, num_threads):
cur_client = i % num_clients
lst = client_strs[cur_client]
if (len(lst) == 0):
lst.append(offset)
else:
lst.append(lst[-1] + stride)
return client_strs
def list_to_comma_delimited(list : list[any]):
ret = ""
for i in range(0, len(list)):
if (i > 0):
ret += ","
ret += str(list[i])
return ret