-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTFG.cpp
More file actions
78 lines (63 loc) · 2.32 KB
/
TFG.cpp
File metadata and controls
78 lines (63 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "TFG.h"
using namespace std;
using namespace std::chrono;
void simulacion(int particulas, int lado, double mason, double deltaT, double tiempo, int repeticion) {
auto start = high_resolution_clock::now();
melleOpenCL(particulas, lado, mason, deltaT, tiempo, repeticion);
auto stop = high_resolution_clock::now();
auto duration = duration_cast<seconds>(stop - start);
cout << "Tiempo para ma = " << mason << ": "
<< duration.count() << " segundos" << endl;
}
void hilos_moctezuma(int particulas, int lado, double mason, double deltaT, double tiempo, int repeticion) {
auto start = high_resolution_clock::now();
moctezumaOpenCL(particulas, lado, mason, deltaT, tiempo, repeticion);
auto stop = high_resolution_clock::now();
auto duration = duration_cast<seconds>(stop - start);
cout << "Tiempo para ma = " << mason << ": "
<< duration.count() << " segundos" << endl;
}
int main()
{
auto start = high_resolution_clock::now();
int particulas = 400;
//int lado = 140;
int lado = 67;
double mason[4] = { 0.001, 0.004, 1.0, 2.0 };
int repeticiones = 5;
double tiempo = 1000;
double deltaT = 0.001;
/*std::thread hilos_melle[5];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < repeticiones; j++) {
hilos_melle[j] = std::thread(simulacion, particulas, lado, mason[i], deltaT, tiempo, j);
}
for (int j = 0; j < repeticiones; j++) {
hilos_melle[j].join();
}
}*/
std::thread hilos[5];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < repeticiones; j++) {
hilos[j] = std::thread(hilos_moctezuma, particulas, lado, mason[i], deltaT, tiempo, j);
}
for (int j = 0; j < repeticiones; j++) {
hilos[j].join();
}
}
/*for (int i = 0; i < repeticiones; i++) {
for (int j = 0; j < 4; j++) {
auto comienzo = high_resolution_clock::now();
melleOpenCL(particulas, lado, mason[j], deltaT, tiempo, i);
auto fin = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(fin - comienzo);
cout << "Tiempo para ma = " << mason[j] << " y repeticion " << i + 1 << ": "
<< duration.count() << " milisegundos" << endl;
}
}*/
auto stop = high_resolution_clock::now();
auto duration = duration_cast<seconds>(stop - start);
cout << "Tiempo total: "
<< duration.count() << " segundos" << endl;
return 0;
}