mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 09:28:23 +01:00
mdl: profiling_openmp with easy_profile
This commit is contained in:
parent
1dbee6d8d9
commit
3db0e73efe
@ -8,6 +8,7 @@ set(CMAKE_CXX_STANDARD 17)
|
||||
find_package(Eigen3 REQUIRED NO_MODULE)
|
||||
find_package(OpenMP)
|
||||
find_package(easy_profiler)
|
||||
option(EASY_OPTION_LOG "Verbose easy_profiler" 1)
|
||||
|
||||
## SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -mfma")
|
||||
option(TUG_USE_OPENMP "Compile with OpenMP support" ON)
|
||||
@ -40,4 +41,4 @@ if(TUG_ENABLE_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
add_subdirectory(examples)
|
||||
add_subdirectory(examples)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
set(BUILD_WITH_EASY_PROFILER "1" PARENT_SCOPE)
|
||||
add_executable(FTCS_1D_proto_example FTCS_1D_proto_example.cpp)
|
||||
add_executable(FTCS_2D_proto_example FTCS_2D_proto_example.cpp)
|
||||
add_executable(BTCS_1D_proto_example BTCS_1D_proto_example.cpp)
|
||||
@ -9,7 +10,7 @@ target_link_libraries(FTCS_2D_proto_example tug)
|
||||
target_link_libraries(BTCS_1D_proto_example tug)
|
||||
target_link_libraries(BTCS_2D_proto_example tug)
|
||||
target_link_libraries(reference-FTCS_2D_closed tug)
|
||||
target_link_libraries(profiling_openmp tug)
|
||||
target_link_libraries(profiling_openmp tug easy_profiler)
|
||||
|
||||
add_executable(FTCS_2D_proto_example_mdl FTCS_2D_proto_example_mdl.cpp)
|
||||
add_executable(FTCS_2D_proto_closed_mdl FTCS_2D_proto_closed_mdl.cpp)
|
||||
|
||||
@ -2,60 +2,47 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <easy/profiler.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
EASY_MAIN_THREAD;
|
||||
EASY_PROFILER_ENABLE;
|
||||
profiler::startListen();
|
||||
|
||||
int n[4] = {100, 500, 1000, 2000};
|
||||
int threads[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
int iterations[1] = {5};
|
||||
int repetition = 1;
|
||||
int n = 1000;
|
||||
|
||||
ofstream myfile;
|
||||
myfile.open("testLarge.csv");
|
||||
Grid grid = Grid(n, n);
|
||||
grid.setDomain(10, 10);
|
||||
|
||||
for (int i = 0; i < size(n); i++){
|
||||
cout << "Grid size: " << n[i] << " x " << n[i] << endl << endl;
|
||||
myfile << "Grid size: " << n[i] << " x " << n[i] << endl << endl;
|
||||
for(int j = 0; j < size(iterations); j++){
|
||||
cout << "Iterations: " << iterations[j] << endl;
|
||||
myfile << "Iterations: " << iterations[j] << endl;
|
||||
for (int k = 0; k < repetition; k++){
|
||||
cout << "Wiederholung: " << k << endl;
|
||||
Grid grid = Grid(n[i], n[i]);
|
||||
grid.setDomain(1, 1);
|
||||
MatrixXd concentrations = MatrixXd::Constant(n, n, 0);
|
||||
concentrations(n/2,n/2) = 1;
|
||||
grid.setConcentrations(concentrations);
|
||||
MatrixXd alpha = MatrixXd::Constant(n, n, 0.001);
|
||||
|
||||
Boundary bc = Boundary(grid);
|
||||
|
||||
Simulation sim = Simulation(grid, bc, BTCS_APPROACH);
|
||||
sim.setSolver(THOMAS_ALGORITHM_SOLVER);
|
||||
sim.setNumberThreads(1);
|
||||
|
||||
sim.setTimestep(0.001);
|
||||
sim.setIterations(2);
|
||||
sim.setOutputCSV(CSV_OUTPUT_OFF);
|
||||
|
||||
auto begin = std::chrono::high_resolution_clock::now();
|
||||
|
||||
MatrixXd concentrations = MatrixXd::Constant(n[i], n[i], 0);
|
||||
concentrations(n[i]/2,n[i]/2) = 1;
|
||||
grid.setConcentrations(concentrations);
|
||||
MatrixXd alpha = MatrixXd::Constant(n[i], n[i], 0.5);
|
||||
EASY_BLOCK("SIMULATION");
|
||||
sim.run();
|
||||
EASY_END_BLOCK;
|
||||
|
||||
Boundary bc = Boundary(grid);
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
Simulation sim = Simulation(grid, bc, BTCS_APPROACH);
|
||||
sim.setSolver(THOMAS_ALGORITHM_SOLVER);
|
||||
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin);
|
||||
cout << milliseconds.count() << endl;
|
||||
|
||||
if(argc == 2){
|
||||
int numThreads = atoi(argv[1]);
|
||||
sim.setNumberThreads(numThreads);
|
||||
}
|
||||
else{
|
||||
sim.setNumberThreads(1);
|
||||
}
|
||||
profiler::dumpBlocksToFile("./mytest_profile.prof");
|
||||
profiler::stopListen();
|
||||
|
||||
sim.setTimestep(0.001);
|
||||
sim.setIterations(iterations[j]);
|
||||
sim.setOutputCSV(CSV_OUTPUT_OFF);
|
||||
|
||||
auto begin = std::chrono::high_resolution_clock::now();
|
||||
sim.run();
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin);
|
||||
myfile << milliseconds.count() << endl;
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
myfile << endl;
|
||||
|
||||
}
|
||||
myfile.close();
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user