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(Eigen3 REQUIRED NO_MODULE)
find_package(OpenMP) find_package(OpenMP)
find_package(easy_profiler REQUIRED)
## SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -mfma") ## SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -mfma")
option(TUG_USE_OPENMP "Compile with OpenMP support" ON) option(TUG_USE_OPENMP "Compile with OpenMP support" ON)
@ -39,4 +40,4 @@ if(TUG_ENABLE_TESTING)
add_subdirectory(test) add_subdirectory(test)
endif() endif()
add_subdirectory(examples) add_subdirectory(examples)

View File

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