Commit 29164de6 authored by Quentin Khan's avatar Quentin Khan
Browse files

PerfTest: add perf file output

parent 02b8d498
#include <iomanip>
#include "Utils/FParameters.hpp"
#include "Utils/FParameterNames.hpp"
......@@ -15,6 +17,7 @@ namespace ParName {
const FParameterNames Density = {{"--density"},"Maximum particle count per leaf in adaptive algorihtms."};
const FParameterNames Schedule = {{"--schedule"},"OpenMP scheduling policy (static, dynamic)."};
const FParameterNames ChunkSize = {{"--chunk-size"},"OpenMP chunk size for basic dynamic algorithm."};
const FParameterNames PerfFile = {{"--perf-file"},"Output file for performance measures."};
}
int main (int argc, char** argv)
......@@ -30,6 +33,7 @@ int main (int argc, char** argv)
ParName::Algo,
ParName::Kern,
ParName::Density,
ParName::PerfFile,
ParName::Schedule,
ParName::ChunkSize);
......@@ -46,6 +50,7 @@ int main (int argc, char** argv)
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");
}
// End of Parameter handling ///////
......@@ -65,4 +70,11 @@ int main (int argc, char** argv)
scalfmm::run<FReal>(params);
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';
}
}
......@@ -293,6 +293,8 @@ namespace scalfmm {
* \param params The program parameters
*/
static void run(FPerfTestParams& params) {
FTimerMap& timers = params.timers;
tree_factory tree_f;
loader_factory loader_f;
kernel_factory kernel_f;
......@@ -301,19 +303,32 @@ namespace scalfmm {
// The factories return unique_ptr specialisations
auto loader = loader_f.build(params);
auto tree = tree_f.build(params, *loader);
timers["load"].tic();
loader->load(*tree);
timers["load"].tac();
auto kernel = kernel_f.build(params, *tree);
auto algo = algo_f.build(params, *tree, *kernel);
std::cout << algo->name() << '\n';
std::cout << algo->description() << '\n';
algo->Timers["total"].tic();
timers["algo"].tic();
algo->execute();
algo->Timers["total"].tac();
timers["algo"].tac();
for(auto t : algo->Timers) {
std::cout << "@@ " << t.first << ": " << t.second.cumulated() << '\n';
timers[t.first] = t.second;
}
for(auto t : params.timers) {
params.json["run"]["operator"][t.first] = t.second.cumulated();
}
params.json["run"]["total time"] = params.timers["algo"].cumulated();
params.json["config"]["algo"]["name"] = algo->name();
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"]["kernel"]["name"] = {params.kernel};
}
};
......
......@@ -3,6 +3,12 @@
#include <string>
#include "Utils/FAlgorithmTimers.hpp"
#include "Utils/Contribs/json.hpp"
namespace json = nlohmann;
#ifdef SCALFMM_USE_MPI
#include "Utils/FMpi.hpp"
#endif
......@@ -15,14 +21,17 @@ struct FPerfTestParams {
int treeHeight = 5; ///< Tree height.
int nbThreads = 1; ///< Maximum thread count (when used).
std::string filename = ""; ///< Particles file.
std::string algo = "task"; ///< Algorithm implementation to run.
std::string kernel = "task"; ///< Kernel to use.
int adaptive_density = 400; ///< Kernel to use.
std::string algo = ""; ///< Algorithm implementation to run.
std::string kernel = ""; ///< Kernel to use.
std::string perf_file= ""; ///< Perf measures filename.
int adaptive_density = 400; ///< Particle density for adaptive algorithms.
int omp_chunk_size = 0; ///< OpenMP chunk size for basic algorithm (FFmmAlgorithmThread)
int nbProcs = 1;
#ifdef SCALFMM_USE_MPI
FMpi* mpiContext = nullptr;
#endif
FTimerMap timers;
json::json json;
};
......
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