diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 20fa36b..150a617 100755 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -11,6 +11,7 @@ include_directories("../../DML/include/") find_package(NUMA REQUIRED) set(SOURCES main.cpp) +set(INCLUDES benchmark.hpp statuscode-tostring.hpp task-data.hpp) add_executable(dml-benchmark ${SOURCES}) diff --git a/benchmarks/benchmark-dml-memcpy.hpp b/benchmarks/benchmark.hpp similarity index 88% rename from benchmarks/benchmark-dml-memcpy.hpp rename to benchmarks/benchmark.hpp index 56df6b0..80d140a 100644 --- a/benchmarks/benchmark-dml-memcpy.hpp +++ b/benchmarks/benchmark.hpp @@ -11,31 +11,7 @@ #include #include "statuscode-tostring.hpp" - -struct ThreadArgs { - // thread placement / engine selection - uint8_t numa_node; - uint8_t core; - // region size and source+destination for move - size_t size; - uint8_t nnode_src; - uint8_t nnode_dst; - // repetition - uint32_t rep_count; - bool batch_submit; - uint32_t batch_size; - uint32_t barrier_after_n_operations; - // thread output - dml::status_code status; - // average run duration in microseconds - double combined_duration; - double submit_duration; - double complete_duration; - // completed iterations - uint32_t rep_completed; - // set by execution - sem_t* sig; -}; +#include "task-data.hpp" double avg(const std::vector& v) { int n = 0; @@ -55,7 +31,7 @@ double avg(const std::vector& v) { template void* thread_function(void* argp) { - ThreadArgs* args = reinterpret_cast(argp); + TaskData* args = reinterpret_cast(argp); std::vector submission_durations; std::vector completion_durations; @@ -153,7 +129,7 @@ void* thread_function(void* argp) { } template -void execute_dml_memcpy(std::vector& args) { +void execute_dml_memcpy(std::vector& args) { sem_t sem; std::vector threads; diff --git a/benchmarks/main.cpp b/benchmarks/main.cpp index 4bd0c99..51f5d6b 100644 --- a/benchmarks/main.cpp +++ b/benchmarks/main.cpp @@ -4,8 +4,8 @@ #include #include -#include "logging-helper.hpp" -#include "benchmark-dml-mempcy.hpp" +#include "benchmark.hpp" +#include "task-data.hpp" int main(int argc, char **argv) { if (argc < 3) { @@ -18,7 +18,7 @@ int main(int argc, char **argv) { const std::string output = argv[2]; std::string path; - std::vector args; + std::vector args; std::ifstream is(input); ReadWorkDescription(args, path, is); diff --git a/benchmarks/logging-helper.hpp b/benchmarks/task-data.hpp similarity index 63% rename from benchmarks/logging-helper.hpp rename to benchmarks/task-data.hpp index 0a73d87..3a0b74d 100644 --- a/benchmarks/logging-helper.hpp +++ b/benchmarks/task-data.hpp @@ -4,10 +4,34 @@ #include "json/single_include/nlohmann/json.hpp" -#include "execute-move.hpp" #include "statuscode-tostring.hpp" -inline void to_json(nlohmann::json& j, const ThreadArgs& a) { +struct TaskData { + // thread placement / engine selection + uint8_t numa_node; + uint8_t core; + // region size and source+destination for move + size_t size; + uint8_t nnode_src; + uint8_t nnode_dst; + // repetition + uint32_t rep_count; + bool batch_submit; + uint32_t batch_size; + uint32_t barrier_after_n_operations; + // thread output + dml::status_code status; + // average run duration in microseconds + double combined_duration; + double submit_duration; + double complete_duration; + // completed iterations + uint32_t rep_completed; + // set by execution + sem_t* sig; +}; + +inline void to_json(nlohmann::json& j, const TaskData& a) { j["task"]["size"] = a.size; j["task"]["iterations"]["desired"] = a.rep_count; j["task"]["iterations"]["actual"] = a.rep_completed; @@ -26,7 +50,7 @@ inline void to_json(nlohmann::json& j, const ThreadArgs& a) { j["report"]["status"] = StatusCodeToString(a.status); } -inline void from_json(const nlohmann::json& j, ThreadArgs& a) { +inline void from_json(const nlohmann::json& j, TaskData& a) { j["task"]["size"].get_to(a.size); j["task"]["iterations"]["desired"].get_to(a.rep_count); j["task"]["batching"]["enabled"].get_to(a.batch_submit); @@ -38,7 +62,7 @@ inline void from_json(const nlohmann::json& j, ThreadArgs& a) { j["affinity"]["nnode_dst"].get_to(a.nnode_dst); } -inline void WriteResultLog(const std::vector& args, const std::string& path, std::ostream& os) { +inline void WriteResultLog(const std::vector& args, const std::string& path, std::ostream& os) { nlohmann::json json; json["count"] = args.size(); @@ -48,7 +72,7 @@ inline void WriteResultLog(const std::vector& args, const std::strin os << std::setw(4) << json; } -inline void ReadWorkDescription(std::vector& args, std::string& path, std::istream& is) { +inline void ReadWorkDescription(std::vector& args, std::string& path, std::istream& is) { nlohmann::json json; is >> json; @@ -57,6 +81,6 @@ inline void ReadWorkDescription(std::vector& args, std::string& path path = json.at("path"); for (uint32_t i = 0; i < count; i++) { - args[i] = json["list"][i].template get(); + args[i] = json["list"][i].template get(); } } \ No newline at end of file