-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to generate toplev plots from benchmark
- Loading branch information
Showing
5 changed files
with
71 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
#include "c_bench.h" | ||
#include "cnpy.h" | ||
#include <algorithm> | ||
#include <cstdlib> | ||
#include <iostream> | ||
#include <algorithm> | ||
#include "cnpy.h" | ||
#include "c_bench.h" | ||
|
||
#define N_REPEAT 20 | ||
|
||
|
||
int main(int argc, char **argv) { | ||
(void) argc; | ||
(void) argv; | ||
|
||
char *model_name = std::getenv("LLEAVES_BENCHMARK_MODEL"); | ||
std::cout << "Running model " << model_name << "\n"; | ||
|
||
std::ostringstream model_stream; | ||
model_stream << "../../data/" << model_name << ".npy"; | ||
std::string model_file = model_stream.str(); | ||
cnpy::NpyArray arr = cnpy::npy_load(model_file); | ||
|
||
std::cout << "Batchsize: " << arr.shape[0] << "\n"; | ||
|
||
auto *loaded_data = arr.data<double>(); | ||
ulong n_preds = arr.shape[0] / (ulong) 6; | ||
auto *out = (double *) (malloc(n_preds * sizeof(double))); | ||
|
||
std::array<double, N_REPEAT> timings{}; | ||
clock_t start, end; | ||
for (size_t i = 0; i < N_REPEAT; ++i) { | ||
start = clock(); | ||
forest_root(loaded_data, out, (int) 0, (int) n_preds); | ||
end = clock(); | ||
|
||
timings[i] = (double) (end - start) / CLOCKS_PER_SEC; | ||
} | ||
|
||
std::cout << "Runtime: " << *std::min_element(timings.begin(), timings.end()) << "\n"; | ||
(void)argc; | ||
(void)argv; | ||
|
||
char *model_name = std::getenv("LLEAVES_BENCHMARK_MODEL"); | ||
std::cout << "Running model " << model_name << "\n"; | ||
|
||
std::ostringstream model_stream; | ||
model_stream << "../../data/" << model_name << ".npy"; | ||
std::string model_file = model_stream.str(); | ||
cnpy::NpyArray arr = cnpy::npy_load(model_file); | ||
|
||
std::cout << "Batchsize: " << arr.shape[0] << "\n"; | ||
|
||
auto *loaded_data = arr.data<double>(); | ||
ulong n_preds = arr.shape[0] / (ulong)6; | ||
auto *out = (double *)(malloc(n_preds * sizeof(double))); | ||
|
||
std::array<double, N_REPEAT> timings{}; | ||
clock_t start, end; | ||
std::cout << "starting...\n"; | ||
for (size_t i = 0; i < N_REPEAT; ++i) { | ||
start = clock(); | ||
forest_root(loaded_data, out, (int)0, (int)n_preds); | ||
end = clock(); | ||
|
||
timings[i] = (double)(end - start) / CLOCKS_PER_SEC; | ||
} | ||
std::cout << "...ending, took " | ||
<< std::accumulate(timings.begin(), timings.end(), 0.0) << "\n"; | ||
|
||
std::cout << "Runtime: " << *std::min_element(timings.begin(), timings.end()) | ||
<< "\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
prefix=$1 | ||
for model in "NYC_taxi" "mtpl2"; do | ||
export LLEAVES_BENCHMARK_MODEL=${model} | ||
pushd build || exit 1 | ||
cmake .. && make | ||
|
||
# high level overview plot | ||
run_id="${model}_1v_${prefix}" | ||
toplev.py -l1 -v -I 100 -x, -o "../${run_id}.csv" --no-desc --core C0 taskset -c 0 ./benchmark &&\ | ||
tl-barplot.py --cpu C0 -o "../${run_id}.png" "../${run_id}.csv" | ||
|
||
# detailed level 2 metrics | ||
run_id="${model}_2v_${prefix}" | ||
toplev.py -l2 -v -D 500 -o "../${run_id}.txt" --no-desc --core C0 taskset -c 0 ./benchmark | ||
|
||
# detailed level 3 plot | ||
run_id="${model}_3_${prefix}" | ||
toplev.py -l3 -I 100 -x, -o "../${run_id}.csv" --no-desc --core C0 taskset -c 0 ./benchmark &&\ | ||
tl-barplot.py --cpu C0 -o "../${run_id}.png" "../${run_id}.csv" | ||
|
||
popd || exit 1 | ||
done; |