From 5606a21cc072622ed2e8656a254a4ce683f4ee54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20F=C3=BCrst?= Date: Sun, 26 Nov 2023 15:16:29 +0100 Subject: [PATCH] use the new json handler for reading configuration and writing output --- benchmarks/main.cpp | 61 +++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/benchmarks/main.cpp b/benchmarks/main.cpp index ff29a79..1b1ea63 100644 --- a/benchmarks/main.cpp +++ b/benchmarks/main.cpp @@ -2,53 +2,42 @@ #include #include +#include -#include "error.hpp" +#include "logging-helper.hpp" #include "execute-move.hpp" -template -int testrunner() { - std::vector args; - - ThreadArgs a; - a.core = 0; - a.numa_node = 0; - a.size = 4096; - a.nnode_dst = 0; - a.nnode_src = 0; - - args.emplace_back(a); - - execute_mem_move(args); - - const auto status = args.front().status.front(); - std::cout << "Operation Result Status: " << status << std::endl; - - return 0; -} - int main(int argc, char **argv) { - if (argc < 2) { - std::cout << "Missing the execution path as the first parameter. Use hardware_path, software_path or automatic_path." << std::endl; + if (argc < 3) { + std::cout << "Missing input and output file names." << std::endl; + std::cout << "Usage: ./benchmarks [input.json] [output.json]" << std::endl; return 1; } - const std::string path = argv[1]; + const std::string input = argv[1]; + const std::string output = argv[2]; + + std::string path; + std::vector args; + + std::ifstream is(input); + ReadWorkDescription(args, path, is); + is.close(); - if (path == "hardware_path") { - std::cout << "Executing using dml::hardware path" << std::endl; - return testrunner(); + if (path == "hw") { + execute_mem_move(args); } - else if (path == "software_path") { - std::cout << "Executing using dml::software path" << std::endl; - return testrunner(); + else if (path == "sw") { + execute_mem_move(args); } - else if (path == "auto_path") { - std::cout << "Executing using dml::automatic path" << std::endl; - return testrunner(); + else if (path == "auto") { + execute_mem_move(args); } else { - std::cout << "Unrecognized value for parameter. Use hardware_path, software_path or automatic_path." << std::endl; - return 1; + std::cerr << "Path is neither hw/sw/auto." << std::endl; } + + std::ofstream os(output); + WriteResultLog(args, path, os); + os.close(); } \ No newline at end of file