-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.cpp
More file actions
53 lines (42 loc) · 1.42 KB
/
test.cpp
File metadata and controls
53 lines (42 loc) · 1.42 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
// CUDA_PATH=/opt/cuda/ && g++ -I $CUDA_PATH/include -L $CUDA_PATH/lib64 -lnvrtc -lcuda -lcudart -Wl,-rpath,$CUDA_PATH/lib64 nvrtc.cpp -o nvrtc
#include <iostream>
#include <sstream>
#include <iomanip>
#include <future>
#include "include/bunch.h"
#include "include/lattice.h"
int main() {
CUDA_info();
Lattice lattice("LHC/lhc.twi");
// Lattice lattice("small_ring/lattice.twi");
// Lattice lattice;
// lattice.add("Drift(1.)");
// lattice.add("Multipole(1, 0.1, 0.)");
// lattice.add("Drift(1.)");
// lattice.add("Multipole(1, -0.1, 0.)");
lattice.n_turns = 1000;
std::cout << "N_ELE: " << lattice.get_n_elements() << std::endl;
lattice.optimize();
std::cout << "N_ELE: " << lattice.get_n_elements() << std::endl;
size_t n = 100000;
//size_t n = 512*512;
HostBunch b(n);
DeviceBunch db(b);
// Execute.
for (int k = 0; k < 1 ; k++) {
// auto future = std::async( std::launch::async, [&](){
// //offline analysis on a separated thread
// std::ofstream f0( std::to_string(k)+".dat" );
// for (size_t i = 0; i < 1000; ++i) {
// f0 << std::setprecision(12) << b.x[i] << " " << b.xp[i] << " " << b.d[i] << " " << b.z[i] << "\n";
// }
// });
lattice.track(db);
b = db;
std::ofstream f0( "1000.dat" );
for (size_t i = 0; i < 1000; ++i) {
f0 << std::setprecision(12) << b.x[i] << " " << b.xp[i] << " " << b.d[i] << " " << b.z[i] << "\n";
}
}
return 0;
};