add easy profiler to CMAKE files

This commit is contained in:
Hannes Signer 2023-07-24 18:16:35 +02:00
parent b7561b93e0
commit 23da250cba
3 changed files with 19 additions and 9 deletions

View File

@ -7,6 +7,7 @@ set(CMAKE_CXX_STANDARD 17)
find_package(Eigen3 REQUIRED NO_MODULE)
find_package(OpenMP)
find_package(easy_profiler REQUIRED)
## SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -mfma")
option(TUG_USE_OPENMP "Compile with OpenMP support" ON)

View File

@ -7,3 +7,4 @@ target_link_libraries(first_example tug)
target_link_libraries(second_example tug)
target_link_libraries(boundary_example1D tug)
target_link_libraries(FTCS_2D_proto_example tug)
target_link_libraries(FTCS_2D_proto_example easy_profiler)

View File

@ -7,13 +7,17 @@
*/
#include <tug/Simulation.hpp>
#include <easy/profiler.h>
#define EASY_PROFILER_ENABLE ::profiler::setEnabled(true);
int main(int argc, char *argv[]) {
EASY_PROFILER_ENABLE;
profiler::startListen();
// **************
// **** GRID ****
// **************
profiler::startListen();
// create a grid with a 20 x 20 field
int row = 20;
int col = 20;
@ -25,8 +29,8 @@ int main(int argc, char *argv[]) {
// (optional) set the concentrations, e.g.:
// MatrixXd concentrations = MatrixXd::Constant(20,20,1000); // #row,#col,value
// grid.setConcentrations(concentrations);
MatrixXd concentrations = MatrixXd::Constant(20,20,0);
// concentrations(0,0) = 2000;
MatrixXd concentrations = MatrixXd::Constant(row, col,1);
concentrations(0,0) = 2000;
grid.setConcentrations(concentrations);
// (optional) set alphas of the grid, e.g.:
@ -64,7 +68,7 @@ int main(int argc, char *argv[]) {
simulation.setTimestep(0.1); // timestep
// (optional) set the number of iterations
simulation.setIterations(1000);
simulation.setIterations(2);
// (optional) set kind of output [CSV_OUTPUT_OFF (default), CSV_OUTPUT_ON, CSV_OUTPUT_VERBOSE]
simulation.setOutputCSV(CSV_OUTPUT_VERBOSE);
@ -72,6 +76,10 @@ int main(int argc, char *argv[]) {
// **** RUN SIMULATION ****
// run the simulation
simulation.run();
EASY_BLOCK("SIMULATION")
simulation.run();
EASY_END_BLOCK;
profiler::dumpBlocksToFile("test_profile.prof");
profiler::stopListen();
}