mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 09:28:23 +01:00
change experiment files
This commit is contained in:
parent
8fcc8812e7
commit
eb42377f30
@ -1,3 +1,4 @@
|
||||
#include <string>
|
||||
#include <tug/Simulation.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@ -5,20 +6,24 @@
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
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[] = {2000};
|
||||
int threads[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
int iterations[1] = {1};
|
||||
int repetition = 10;
|
||||
|
||||
|
||||
for(int l=0; l<size(threads); l++){
|
||||
//string filename = "ftcs_openmp_" + to_string(threads[l]) + ".csv";
|
||||
ofstream myfile;
|
||||
myfile.open("testLarge.csv");
|
||||
myfile.open("speedup_1000.csv", std::ios::app);
|
||||
myfile << "Number threads: " << threads[l] << endl;
|
||||
|
||||
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;
|
||||
//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;
|
||||
//myfile << "Iterations: " << iterations[j] << endl;
|
||||
for (int k = 0; k < repetition; k++){
|
||||
cout << "Wiederholung: " << k << endl;
|
||||
Grid grid = Grid(n[i], n[i]);
|
||||
@ -39,10 +44,10 @@ int main(int argc, char *argv[]) {
|
||||
sim.setNumberThreads(numThreads);
|
||||
}
|
||||
else{
|
||||
sim.setNumberThreads(1);
|
||||
sim.setNumberThreads(threads[l]);
|
||||
}
|
||||
|
||||
sim.setTimestep(0.001);
|
||||
sim.setTimestep(0.01);
|
||||
sim.setIterations(iterations[j]);
|
||||
sim.setOutputCSV(CSV_OUTPUT_OFF);
|
||||
|
||||
@ -58,4 +63,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
}
|
||||
myfile.close();
|
||||
}
|
||||
}
|
||||
67
examples/profiling_speedup.cpp
Normal file
67
examples/profiling_speedup.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
#include <string>
|
||||
#include <tug/Simulation.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
int n[] = {2000};
|
||||
int threads[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
int iterations[1] = {1};
|
||||
int repetition = 10;
|
||||
|
||||
|
||||
for(int l=0; l<size(threads); l++){
|
||||
//string filename = "ftcs_openmp_" + to_string(threads[l]) + ".csv";
|
||||
ofstream myfile;
|
||||
myfile.open("speedup_1000.csv", std::ios::app);
|
||||
myfile << "Number threads: " << threads[l] << endl;
|
||||
|
||||
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[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);
|
||||
|
||||
Boundary bc = Boundary(grid);
|
||||
|
||||
Simulation sim = Simulation(grid, bc, BTCS_APPROACH);
|
||||
sim.setSolver(THOMAS_ALGORITHM_SOLVER);
|
||||
|
||||
if(argc == 2){
|
||||
int numThreads = atoi(argv[1]);
|
||||
sim.setNumberThreads(numThreads);
|
||||
}
|
||||
else{
|
||||
sim.setNumberThreads(threads[l]);
|
||||
}
|
||||
|
||||
sim.setTimestep(0.01);
|
||||
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