StatMech
Loading...
Searching...
No Matches
Sample_t.cu File Reference

Functions

int main (int argc, char **argv)
 

Variables

namespace filesystem = std::experimental::filesystem
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
58 {
60
61 IntType_t dim_sub; //全ヒルベルト空間の次元
62 IntType_t info, failed=0; // カウンタ
63 double gE, EnergyRange, OpRange, OpMin;
64
65 if( !Initialize(argc, argv, Nargs_common) ) {
66 std::cerr << "Error: Initialization failed." << std::endl;
67 std::exit(EX_USAGE);
68 }
69 debug_print("# Successfully initialized.");
70
71 //******************** Check for the directory structure ********************
72 debug_print("# Checking for the directory structure.");
73 //******************** (END) Check for the directory structure ********************
74
75 //***************************************************************************
76 //******************** Allocation & Initialization **************************
77 //***************************************************************************
78#ifdef GPU
79 magma_init();
80 magma_queue_t queue = NULL;
81 magma_int_t dev = 0;
82 magma_getdevice( &dev );
83 magma_queue_create( dev, &queue );
84#else
85 void* GPUconf = nullptr;
86#endif
87
88 //******************** Translation invariance ********************
89 debug_print("# Calculating translation-invariant sectors.");
91 //******************** (END)Translation invariance ********************
92
93 //********** Allocate CPU memories **********//
94 debug_print("# Allocating CPU memories.");
95 IntType_t const dim_max = SectorDimension(Sector[n_max]);
96 std::vector<IntType_t> NdataInShell(dim_max);
97 std::vector<double> eigenEnergy(dim_max);
98 std::vector<double> EXPvalue(dim_max);
99 matrix<ComplexType_t> h(dloc_h , dloc_h );
100 matrix<ComplexType_t> loc(dloc_op, dloc_op);
101#ifndef GPU
102 matrix<ComplexType_t> h_tot(dim_max, dim_max);
103 matrix<ComplexType_t> loc_tot(dim_max, dim_max);
104 #define dh_tot h_tot
105 #define dloc_tot loc_tot
106#endif
107 //********** (END) Allocate CPU memories **********//
108
109#ifdef GPU
110 //********** Allocate GPU memories **********//
111 debug_print("# Allocating GPU memories.");
112 constexpr IntType_t GPU_UNIT = 32;
113 IntType_t const LDT = magma_roundup(dim_max, GPU_UNIT);
114 matrix_gpu<ComplexType_t> dh(dloc_h , dloc_h );
115 matrix_gpu<ComplexType_t> dloc(dloc_op, dloc_op);
116 matrix_gpu<ComplexType_t> dh_tot(LDT, dim_max);
117 matrix_gpu<ComplexType_t> dloc_tot(LDT, dim_max);
118 //********** (END) Allocate GPU memories **********//
119
120 //********** Determine GPU configuration **********//
122 //********** (END) Determine GPU configuration **********//
123#endif // #ifdef GPU
124
125 double start, t_int, end, temp_t;
126 double T_diag=0, T_post=0, T_pre=0;
127 init_genrand(SEED);
128 start = getETtime();
129 for(IntType_t repetition = 0;repetition < repMin; ++repetition) {
130 generateLocal_h( h, dloc_h, -1);
131 generateLocal_op(loc, dloc_op, -1);
132 }
133 end = getETtime();
134 std::cout << "(init_genrand): time=" << std::fixed << (end-start) << std::endl;
135 //***************************************************************************
136 //******************** (END) Allocation & Initialization ********************
137 //***************************************************************************
138
139 FILE* pipe = popen("hostname", "r");
140 char hostname[256];
141 fgets(&(hostname[0]), 255, pipe);
142 pclose(pipe);
143 char* cpos = strchr(hostname, '\n'); *cpos = '\0';
144 debug_print("Hostname = " << hostname);
145
146 start = getETtime();
147 end = start;
148 for(IntType_t repetition = repMin;repetition <= repMax; ++repetition) {
149 // 局所ハミルトニアンと局所物理量をランダムにとる ******************************//
150 generateLocal_h( h, dloc_h, -1);
151 generateLocal_op(loc, dloc_op, -1);
152
153 std::string filename(baseDirName);
154 {
155 std::stringstream buff("");
156 buff << "/Sample_No" << repetition << "_" << hostname << ".txt";
157 filename += buff.str();
158 filename = std::regex_replace(filename, std::regex("//"), "/");
159 }
160 debug_print("# filename = " << filename);
161 std::ofstream OutFs(filename); checkIsFileOpen(OutFs, filename);
162 h.print(OutFs, dloc_h , dloc_h , "Lower");
163 OutFs << "\n";
164 loc.print(OutFs, dloc_op, dloc_op, "Lower");
165 OutFs.close();
166
167 if(repetition%10 == 9) {
168 std::cerr << "(Sample=" << std::setw(6) << repetition+1 << ")" << std::endl;
169 }
170 }
171
172 Finalize(argc, argv);
173 #ifdef GPU
174 magma_finalize();
175 #endif
176 return 0;
177}
double getETtime()
Definition EnergySpectrum.c:14
std::vector< TransSector > Sector(n_max+1)
bool checkIsFileOpen(std::ifstream &file, std::string const &filename)
Definition file_util.hpp:22
debug_print("# Determining GPU configuration.")
GPUconfig GPUconf(dim3(nBlock, nBlock, 1), dim3(nThread, nThread, 1), 0, queue)
baseDirName
Definition setVariablesForEnsemble.cpp:50
Integer_t const repMin
Definition setVariablesForEnsemble.cpp:31
Integer_t const repMax
Definition setVariablesForEnsemble.cpp:32
Integer_t const dloc_op
Definition setVariablesForEnsemble.cpp:41
Integer_t const dloc_h
Definition setVariablesForEnsemble.cpp:40
Integer_t const n_max
Definition setVariablesForEnsemble.cpp:27
std::stringstream buff("")

Variable Documentation

◆ filesystem

namespace filesystem = std::experimental::filesystem