Commit 11bb0fa4 authored by Philippe SWARTVAGHER's avatar Philippe SWARTVAGHER
Browse files

Refactor machine parsing and fix getting per-thread results with only comp alone

parent 32b2dbf9
......@@ -317,7 +317,7 @@ class FilesParser:
return results["without_comm"], results["with_comm"]
def _get_bw_time_per_thread_results(self, lines, op):
def _get_bw_time_per_thread_results(self, lines, op, nb_threads):
def line_to_dict(l):
words = l.strip().split()[-7:]
values = list(map(float, words[1:]))
......@@ -353,64 +353,56 @@ class FilesParser:
if "results per thread (with comm):" in lines[i]:
in_result_per_thread_with_comm = True
elif "results per thread (without comm):" in lines[i]:
assert(in_result_per_thread_with_comm)
in_result_per_thread_with_comm = False
in_result_per_thread_without_comm = True
elif in_result_per_thread_with_comm:
results["with_comm"].update(line_to_dict(lines[i]))
elif in_result_per_thread_without_comm:
results["without_comm"].update(line_to_dict(lines[i]))
if len(results["without_comm"]) == len(results["with_comm"]):
if len(results["without_comm"]) == nb_threads:
break
return {op: rearrange_dict(results["without_comm"])}, {op: rearrange_dict(results["with_comm"])}
def _parse_machine(self, lines):
nb_pus = None
l3_cache_size = None
nb_numa_nodes = None
for l in lines:
if l.startswith("# Nb PUs"):
nb_pus = int(l.split()[-1])
if self.machine['nb_pus'] is None:
self.machine['nb_pus'] = nb_pus
elif self.machine['nb_pus'] != nb_pus:
print("Warning: nb_pus is different ({} vs {})".format(
self.machine['nb_pus'],
nb_pus
))
elif l.startswith("# L3 cache size"):
l3_cache_size = int(l.split()[-2])
if self.machine['l3_cache_size'] is None:
self.machine['l3_cache_size'] = l3_cache_size
elif self.machine['l3_cache_size'] != l3_cache_size:
print("Warning: l3_cache_size is different ({} vs {})".format(
self.machine['l3_cache_size'],
l3_cache_size
))
elif l.startswith("# Nb NUMA nodes"):
nb_numa_nodes = int(l.split()[-1])
if self.machine['nb_numa_nodes'] is None:
self.machine['nb_numa_nodes'] = nb_numa_nodes
elif self.machine['nb_numa_nodes'] != nb_numa_nodes:
print("Warning: nb_numa_nodes is different ({} vs {})".format(
self.machine['nb_numa_nodes'],
nb_numa_nodes
))
elif l.startswith("# Nb sockets"):
nb_sockets = int(l.split()[-1])
if self.machine['nb_sockets'] is None:
self.machine['nb_sockets'] = nb_sockets
elif self.machine['nb_sockets'] != nb_sockets:
print("Warning: nb_sockets is different ({} vs {})".format(
self.machine['nb_sockets'],
nb_sockets
))
elif not l.startswith("# "):
# we parsed the beginning of the file that could contains these informations,
# no need to parse the whole file
break
infos = {
"nb_pus": "# Nb PUs",
"l3_cache_size": "# L3 cache size",
"nb_numa_nodes": "# Nb NUMA nodes",
"nb_sockets": "# Nb sockets",
}
run = {
"nb_workers": "# Nb workers",
}
run_values = {}
for k in infos:
for l in lines:
if l.startswith(infos[k]):
v = int(l[l.find(":")+1:].split()[0])
if self.machine[k] is None:
self.machine[k] = v
elif self.machine[k] != v:
print("Warning: {} is different ({} vs {})".format(
k, self.machine['k'], v
))
break
elif not l.startswith("# "):
# we parsed the beginning of the file that could contains these informations,
# no need to parse the whole file
break
for k in run:
for l in lines:
if l.startswith(run[k]):
run_values[k] = int(l[l.find(":")+1:].split()[0])
break
elif not l.startswith("# "):
# we parsed the beginning of the file that could contains these informations,
# no need to parse the whole file
break
return run_values
def _parse_file(self, filename):
......@@ -467,7 +459,7 @@ class FilesParser:
with open(filename, 'r') as f:
lines = f.readlines()
self._parse_machine(lines)
run_params = self._parse_machine(lines)
# Communications:
bandwidths, latencies = get_comm_durations(lines)
......@@ -497,7 +489,7 @@ class FilesParser:
alone, with_comm = self._get_stream_results(lines, nb_cores)
elif compute_bench_type == Memset:
alone, with_comm = self._get_bw_time_results(lines, "memset", nb_cores)
alone_per_thread, with_comm_per_thread = self._get_bw_time_per_thread_results(lines, "memset")
alone_per_thread, with_comm_per_thread = self._get_bw_time_per_thread_results(lines, "memset", run_params['nb_workers'])
# elif compute_bench_type == "cholesky":
# file_data["computing"] = get_cholesky_results(lines, nb_cores)
# else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment