Browse Source

clean up naming of structs, functions and files

master
Constantin Fürst 1 year ago
parent
commit
22f3ed8956
  1. 1
      benchmarks/CMakeLists.txt
  2. 30
      benchmarks/benchmark.hpp
  3. 6
      benchmarks/main.cpp
  4. 36
      benchmarks/task-data.hpp

1
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})

30
benchmarks/benchmark-dml-memcpy.hpp → benchmarks/benchmark.hpp

@ -11,31 +11,7 @@
#include <dml/dml.hpp>
#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<double>& v) {
int n = 0;
@ -55,7 +31,7 @@ double avg(const std::vector<double>& v) {
template <typename path>
void* thread_function(void* argp) {
ThreadArgs* args = reinterpret_cast<ThreadArgs*>(argp);
TaskData* args = reinterpret_cast<TaskData*>(argp);
std::vector<double> submission_durations;
std::vector<double> completion_durations;
@ -153,7 +129,7 @@ void* thread_function(void* argp) {
}
template <typename path>
void execute_dml_memcpy(std::vector<ThreadArgs>& args) {
void execute_dml_memcpy(std::vector<TaskData>& args) {
sem_t sem;
std::vector<pthread_t> threads;

6
benchmarks/main.cpp

@ -4,8 +4,8 @@
#include <iostream>
#include <fstream>
#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<ThreadArgs> args;
std::vector<TaskData> args;
std::ifstream is(input);
ReadWorkDescription(args, path, is);

36
benchmarks/logging-helper.hpp → 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<ThreadArgs>& args, const std::string& path, std::ostream& os) {
inline void WriteResultLog(const std::vector<TaskData>& 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<ThreadArgs>& args, const std::strin
os << std::setw(4) << json;
}
inline void ReadWorkDescription(std::vector<ThreadArgs>& args, std::string& path, std::istream& is) {
inline void ReadWorkDescription(std::vector<TaskData>& args, std::string& path, std::istream& is) {
nlohmann::json json;
is >> json;
@ -57,6 +81,6 @@ inline void ReadWorkDescription(std::vector<ThreadArgs>& args, std::string& path
path = json.at("path");
for (uint32_t i = 0; i < count; i++) {
args[i] = json["list"][i].template get<ThreadArgs>();
args[i] = json["list"][i].template get<TaskData>();
}
}
Loading…
Cancel
Save