Commit ba033659 authored by Philippe SWARTVAGHER's avatar Philippe SWARTVAGHER
Browse files

FilesParser: get the number of header lines to parse them all or exclude them

And thus remove the simple heuristic: consider only the first 20 lines as header.
parent dcc236e7
......@@ -170,6 +170,22 @@ class FilesParser:
self.x_values = sorted(self.x_values)
def _get_nb_header_lines(self, lines):
meet_sharp = False
nb_header_lines = 0
for l in lines:
if l.startswith("# "):
meet_sharp = True
elif meet_sharp:
# we parsed all the header of the file that could contains these informations,
# no need to parse the whole file
break
nb_header_lines += 1
return nb_header_lines
@classmethod
def _get_compute_bench_type(cls, lines):
name_to_bench_type = {
......@@ -182,12 +198,12 @@ class FilesParser:
"cholesky": Cholesky,
"memset": Memset
}
for line in lines[:20]:
for line in lines:
if line.strip().startswith("# Computing kernel:"):
return name_to_bench_type[line.strip().split()[-1]]
# legacy format:
for line in lines[:20]:
for line in lines:
if line.strip().startswith("# Will do CPU intensive benchmark"):
return Prime
elif line.strip().startswith("# Will do Cholesky benchmark"):
......@@ -306,7 +322,7 @@ class FilesParser:
results = {"without_comm": {}, "with_comm": {}}
nb_found = 0
for i in range(len(lines)-15, len(lines)):
for i in range(max(len(lines)-15, 0), len(lines)):
if lines[i].strip().startswith("# without communications"):
assert(op not in results["without_comm"])
results["without_comm"][op] = line_to_dict(lines[i])
......@@ -387,15 +403,7 @@ class FilesParser:
run_values = {}
for k in infos:
meet_sharp = False
for l in lines:
if l.startswith("# "):
meet_sharp = True
elif meet_sharp:
# we parsed all the header of the file that could contains these informations,
# no need to parse the whole file
break
if l.startswith(infos[k]):
v = int(l[l.find(":")+1:].split()[0])
if self.machine[k] is None:
......@@ -407,14 +415,7 @@ class FilesParser:
break
for k in run:
meet_sharp = False
for l in lines:
if l.startswith("# "):
meet_sharp = True
elif meet_sharp:
# we parsed all the header of the file that could contains these informations,
# no need to parse the whole file
break
if l.startswith(run[k]):
run_values[k] = int(l[l.find(":")+1:].split()[0])
break
......@@ -475,8 +476,9 @@ class FilesParser:
with open(filename, 'r') as f:
lines = f.readlines()
nb_header_lines = self._get_nb_header_lines(lines)
run_params = self._parse_machine(lines)
run_params = self._parse_machine(lines[:nb_header_lines])
# Communications:
bandwidths, latencies = get_comm_durations(lines)
......@@ -492,7 +494,7 @@ class FilesParser:
self.comm_lat_with_comp_results[x] = compute_stats(latencies[1])
# Computations:
compute_bench_type = self._get_compute_bench_type(lines)
compute_bench_type = self._get_compute_bench_type(lines[:nb_header_lines])
if self.compute_bench_type is None:
self.compute_bench_type = compute_bench_type
elif self.compute_bench_type != compute_bench_type:
......@@ -503,10 +505,10 @@ class FilesParser:
alone_per_thread = None
with_comm_per_thread = None
if compute_bench_type == Stream:
alone, with_comm = self._get_stream_results(lines, nb_cores)
alone, with_comm = self._get_stream_results(lines[nb_header_lines-1:], 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", run_params['nb_workers'])
alone, with_comm = self._get_bw_time_results(lines[nb_header_lines-1:], "memset", nb_cores)
alone_per_thread, with_comm_per_thread = self._get_bw_time_per_thread_results(lines[nb_header_lines-1:], "memset", run_params['nb_workers'])
# elif compute_bench_type == "cholesky":
# file_data["computing"] = get_cholesky_results(lines, nb_cores)
# else:
......
Markdown is supported
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