Commit 94f50e65 authored by Quentin Khan's avatar Quentin Khan
Browse files

PerfTest: adjust json serialisation

parent cf69aa5e
......@@ -7,6 +7,8 @@
#include "PerfTest/DescriptorLookup.hpp"
#include <omp.h>
#define HOST_NAME_MAX 64
using FReal = double;
......@@ -45,36 +47,51 @@ int main (int argc, char** argv)
"../Data/unitCubeXYZQ100.bfma");
params.treeHeight = getValue(argc, argv, OctreeHeight.options, 5);
params.subTreeHeight = getValue(argc, argv, OctreeSubHeight.options, 2);
params.nbThreads = getValue(argc, argv, NbThreads.options, 1);
params.nbThreads = getValue(argc, argv, NbThreads.options, omp_get_max_threads());
params.algo = getStr(argc,argv,ParName::Algo.options,"task");
params.kernel = getStr(argc,argv,ParName::Kern.options,"lagrange");
params.adaptive_density = getValue(argc, argv, ParName::Density.options, 400);
params.omp_chunk_size = getValue(argc, argv, ParName::ChunkSize.options, 0);
params.perf_file = getStr(argc,argv,ParName::PerfFile.options,"perf.json");
params.perf_file = getStr(argc,argv,ParName::PerfFile.options,"");
}
// End of Parameter handling ///////
char hostname[HOST_NAME_MAX];
memset(hostname,'\0',HOST_NAME_MAX);
if ( -1 == gethostname(hostname, HOST_NAME_MAX-1) ) {
perror("Could not get hostname");
strncpy(hostname, "unknown", HOST_NAME_MAX);
{ // Save hostname
char hostname[HOST_NAME_MAX];
memset(hostname,'\0',HOST_NAME_MAX);
if ( -1 == gethostname(hostname, HOST_NAME_MAX-1) ) {
perror("Could not get hostname");
strncpy(hostname, "unknown", HOST_NAME_MAX);
}
std::cout << "Hostname: " << hostname << std::endl;
params.json["env"]["hostname"] = hostname;
}
{ // Save date
auto now = std::chrono::system_clock::now();
std::time_t d = std::chrono::system_clock::to_time_t(now);
std::tm date = *std::localtime(&d);
std::stringstream sstr;
sstr << std::put_time(&date, "%F %T");
params.json["env"]["date"] = sstr.str();
}
std::cout << "Hostname: " << hostname << std::endl;
std::cout << "Available kernels: ";
scalfmm::kernel_list<FReal>();
std::cout << "Available algorithms: ";
scalfmm::algo_list<FReal>();
scalfmm::run<FReal>(params);
// Automatically handle file memory, fallback to std::cout if no file is given
std::unique_ptr<std::fstream> file_handle;
if(params.perf_file != "") {
std::fstream perf_file(params.perf_file, std::ios::out);
perf_file << std::setw(4) << params.json << '\n';
} else {
std::cout << std::setw(4) << params.json << '\n';
file_handle = std::make_unique<std::fstream>(params.perf_file, std::ios::out);
}
std::ostream& os = file_handle ? *file_handle : std::cout;
os.precision(5);
os << std::setw(4) << params.json << '\n';
}
......@@ -316,19 +316,19 @@ namespace scalfmm {
timers["algo"].tac();
for(auto t : algo->Timers) {
params.json["run"]["time"]["operator"][t.first] = t.second.cumulated();
params.json["time"]["operator"][t.first] = t.second.cumulated();
}
for(auto t : params.timers) {
params.json["run"]["time"][t.first] = t.second.cumulated();
params.json["time"][t.first] = t.second.cumulated();
}
params.json["config"]["algo"]["name"] = params.algo;
params.json["config"]["algo"]["threads"] = params.nbThreads;
params.json["config"]["tree"]["height"] = tree->getHeight();
params.json["config"]["tree"]["particle files"] = {params.filename};
params.json["config"]["particle files"] =
{params.filename.substr(params.filename.find_last_of('/'))};
params.json["config"]["kernel"]["name"] = params.kernel;
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment