Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,28 @@ cmake -B build
Process the raw output:

```
./scripts/latex_table.py myresults.txt
./scripts/latex_table.py myresults.txt
```

This will print out to std out the table. The numbers are already rounded to two significant digits,
ready to be included in a scientific manuscript.
This will print to stdout the table.
The numbers are already rounded to two significant digits, ready to be included in a scientific manuscript.

It is also possible to create multiple LaTeX tables at once with:

```
./scripts/generate_multiple_tables.py <compiler_name>`
```

## Running tests on Amazon AWS

It is possible to generate tests on Amazon AWS:

```
./scripts/aws_tests.py
```

This script will create new EC2 instances, run
`./scripts/generate_multiple_tables.py` script on both g++ and clang++ builds,
save each output to a separate folder, and then terminate the instance.

Prerequisites and some user configurable variables are in the script itself.
4 changes: 2 additions & 2 deletions scripts/aws_tests.bash
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ process_instance() {
clang++ --version > outputs/clang++.txt

echo "Building project with g++ and running the benchmarks..."
CXX=g++ cmake -B build . && cmake --build build
CC=gcc CXX=g++ cmake -B build . && cmake --build build
./scripts/generate_multiple_tables.py g++

rm -rf build

echo "Building project with clang++ and running the benchmarks..."
CXX=clang++ cmake -B build . && cmake --build build
CC=clang CXX=clang++ cmake -B build . && cmake --build build
./scripts/generate_multiple_tables.py clang++
EOF

Expand Down
24 changes: 17 additions & 7 deletions scripts/generate_multiple_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@


def get_cpu_model():
env = os.environ.copy()
env["LANG"] = "C"

system = platform.system()
if system == "Windows":
return platform.processor()
elif system == "Darwin":
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + '/usr/sbin'
command = ["sysctl", "-n", "machdep.cpu.brand_string"]
return subprocess.check_output(command, text=True).strip()
return subprocess.check_output(command, env=env, text=True).strip()
elif system == "Linux":
output = subprocess.check_output(["lscpu"], text=True)
output = subprocess.check_output(["lscpu"], env=env, text=True)
model_name = None
architecture = None
for line in output.splitlines():
Expand Down Expand Up @@ -78,14 +81,21 @@ def process_job(label, cmd_args, flags):
# Build output file name
flag_label = ''.join([f.strip('-') for f in flags]) or 'none'
safe_label = label.replace('.', '_')
filename = f"{CPUModel}_{CompilerLabel}_{safe_label}_{flag_label}.tex"
out_path = os.path.join(output_dir, filename)
filename_tex = f"{CPUModel}_{CompilerLabel}_{safe_label}_{flag_label}.tex"
filename_raw = filename_tex[:-4] + '.raw' # replace .tex with .raw
out_path_tex = os.path.join(output_dir, filename_tex)
out_path_raw = os.path.join(output_dir, filename_raw)

# Write to file
# Write LaTeX table to file
tex_content = generate_latex_table(output)
with open(out_path, 'w') as f:
with open(out_path_tex, 'w') as f:
f.write(tex_content)
print(f"Written: {out_path}\n", flush=True)
print(f"Written: {out_path_tex}", flush=True)

# Write raw output to .raw file
with open(out_path_raw, 'w') as f:
f.write(output)
print(f"Written: {out_path_raw}\n", flush=True)


if __name__ == '__main__':
Expand Down