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(Eigen3 REQUIRED NO_MODULE)
|
||||||
find_package(OpenMP)
|
find_package(OpenMP)
|
||||||
find_package(easy_profiler)
|
find_package(easy_profiler)
|
||||||
|
option(EASY_OPTION_LOG "Verbose easy_profiler" 1)
|
||||||
|
|
||||||
## 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)
|
||||||
@ -40,4 +41,4 @@ if(TUG_ENABLE_TESTING)
|
|||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
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_1D_proto_example FTCS_1D_proto_example.cpp)
|
||||||
add_executable(FTCS_2D_proto_example FTCS_2D_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)
|
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_1D_proto_example tug)
|
||||||
target_link_libraries(BTCS_2D_proto_example tug)
|
target_link_libraries(BTCS_2D_proto_example tug)
|
||||||
target_link_libraries(reference-FTCS_2D_closed 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_example_mdl FTCS_2D_proto_example_mdl.cpp)
|
||||||
add_executable(FTCS_2D_proto_closed_mdl FTCS_2D_proto_closed_mdl.cpp)
|
add_executable(FTCS_2D_proto_closed_mdl FTCS_2D_proto_closed_mdl.cpp)
|
||||||
|
|||||||
@ -2,60 +2,47 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <easy/profiler.h>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
EASY_MAIN_THREAD;
|
||||||
|
EASY_PROFILER_ENABLE;
|
||||||
|
profiler::startListen();
|
||||||
|
|
||||||
int n[4] = {100, 500, 1000, 2000};
|
int n = 1000;
|
||||||
int threads[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
|
||||||
int iterations[1] = {5};
|
|
||||||
int repetition = 1;
|
|
||||||
|
|
||||||
ofstream myfile;
|
Grid grid = Grid(n, n);
|
||||||
myfile.open("testLarge.csv");
|
grid.setDomain(10, 10);
|
||||||
|
|
||||||
for (int i = 0; i < size(n); i++){
|
MatrixXd concentrations = MatrixXd::Constant(n, n, 0);
|
||||||
cout << "Grid size: " << n[i] << " x " << n[i] << endl << endl;
|
concentrations(n/2,n/2) = 1;
|
||||||
myfile << "Grid size: " << n[i] << " x " << n[i] << endl << endl;
|
grid.setConcentrations(concentrations);
|
||||||
for(int j = 0; j < size(iterations); j++){
|
MatrixXd alpha = MatrixXd::Constant(n, n, 0.001);
|
||||||
cout << "Iterations: " << iterations[j] << endl;
|
|
||||||
myfile << "Iterations: " << iterations[j] << endl;
|
Boundary bc = Boundary(grid);
|
||||||
for (int k = 0; k < repetition; k++){
|
|
||||||
cout << "Wiederholung: " << k << endl;
|
Simulation sim = Simulation(grid, bc, BTCS_APPROACH);
|
||||||
Grid grid = Grid(n[i], n[i]);
|
sim.setSolver(THOMAS_ALGORITHM_SOLVER);
|
||||||
grid.setDomain(1, 1);
|
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);
|
EASY_BLOCK("SIMULATION");
|
||||||
concentrations(n[i]/2,n[i]/2) = 1;
|
sim.run();
|
||||||
grid.setConcentrations(concentrations);
|
EASY_END_BLOCK;
|
||||||
MatrixXd alpha = MatrixXd::Constant(n[i], n[i], 0.5);
|
|
||||||
|
|
||||||
Boundary bc = Boundary(grid);
|
auto end = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
Simulation sim = Simulation(grid, bc, BTCS_APPROACH);
|
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin);
|
||||||
sim.setSolver(THOMAS_ALGORITHM_SOLVER);
|
cout << milliseconds.count() << endl;
|
||||||
|
|
||||||
if(argc == 2){
|
profiler::dumpBlocksToFile("./mytest_profile.prof");
|
||||||
int numThreads = atoi(argv[1]);
|
profiler::stopListen();
|
||||||
sim.setNumberThreads(numThreads);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
sim.setNumberThreads(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
sim.setTimestep(0.001);
|
return(0);
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user