Skip to content

Commit 7ef9fa3

Browse files
committed
feat: sync DFT+U/DeltaSpin code from feat/dftu-pw-port-v2
Direct sync of source/ directory from feat/dftu-pw-port-v2 to develop. 276 files changed, +9414/-3864 lines. Includes: - DFT+U/DeltaSpin nspin=1/2/4 support - sc_lambda_strategy, sc_direction_only, sc_scan_* parameters - DFT+U occupation mixing (mixing_dftu, allocate_mixing_uom) - Plus_U accessor functions - npol-aware force/stress/onsite kernels - op_pw_proj nspin=1 DeltaSpin support - All other code modifications from port-v2
1 parent 91c0c03 commit 7ef9fa3

276 files changed

Lines changed: 9414 additions & 3864 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

source/Makefile.Objects

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ VPATH=./src_global:\
1616
./source_basis/module_ao:\
1717
./source_basis/module_nao:\
1818
./source_cell/module_neighbor:\
19-
./source_cell/module_neighlist:\
2019
./source_cell/module_symmetry:\
2120
./source_cell:\
2221
./source_base:\
@@ -87,7 +86,6 @@ ${OBJS_HAMILT}\
8786
${OBJS_HSOLVER}\
8887
${OBJS_MD}\
8988
${OBJS_NEIGHBOR}\
90-
${OBJS_NEIGHBOR_SEARCH}\
9189
${OBJS_PSI}\
9290
${OBJS_PSI_INITIALIZER}\
9391
${OBJS_PW}\
@@ -412,10 +410,6 @@ OBJS_NEIGHBOR=sltk_atom.o\
412410
sltk_grid.o\
413411
sltk_grid_driver.o\
414412

415-
OBJS_NEIGHBOR_SEARCH=neighbor_search.o\
416-
bin_manager.o\
417-
418-
419413
OBJS_ORBITAL=ORB_atomic.o\
420414
ORB_atomic_lm.o\
421415
ORB_gaunt_table.o\

source/source_base/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ add_library(
3636
mathzone_add1.cpp
3737
matrix.cpp
3838
matrix3.cpp
39-
memory_recorder.cpp
39+
memory.cpp
4040
mymath.cpp
4141
opt_CG.cpp
4242
opt_DCsrch.cpp

source/source_base/global_file.cpp

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <cerrno>
1515
#include <sstream>
1616
#include "global_function.h"
17+
#include "source_io/module_parameter/parameter.h"
1718
#include "global_variable.h"
1819
#include "source_base/parallel_common.h"
1920
#include "source_base/parallel_reduce.h"
@@ -30,16 +31,7 @@ void ModuleBase::Global_File::make_dir_out(
3031
const bool &out_wfc_dir,
3132
const int rank,
3233
const bool &restart,
33-
const bool out_alllog,
34-
const std::string &global_out_dir,
35-
const std::string &global_stru_dir,
36-
const std::string &global_matrix_dir,
37-
const std::string &global_wfc_dir,
38-
const std::string &global_mlkedf_descriptor_dir,
39-
const std::string &global_deepks_label_elec_dir,
40-
const std::string &log_file,
41-
const bool of_ml_gene_data,
42-
const bool deepks_out_freq_elec)
34+
const bool out_alllog)
4335
{
4436
//----------------------------------------------------------
4537
// USE STL FUNCTION
@@ -51,16 +43,17 @@ void ModuleBase::Global_File::make_dir_out(
5143
#endif
5244
int make_dir = 0;
5345
// mohan update 2011-05-03
46+
//std::string command0 = "test -d " + PARAM.globalv.global_out_dir + " || mkdir " + PARAM.globalv.global_out_dir;
5447

5548
int times = 0;
5649
while(times<GlobalV::NPROC)
5750
{
5851
if(rank==times)
5952
{
60-
int ret = mkdir(global_out_dir.c_str(), 0755);
53+
int ret = mkdir(PARAM.globalv.global_out_dir.c_str(), 0755);
6154
if ( ret == 0 || errno == EEXIST )
6255
{
63-
std::cout << " MAKE THE DIR : " << global_out_dir << std::endl;
56+
std::cout << " MAKE THE DIR : " << PARAM.globalv.global_out_dir << std::endl;
6457
make_dir = 1;
6558
}
6659
else
@@ -89,16 +82,17 @@ void ModuleBase::Global_File::make_dir_out(
8982
if(calculation == "md")
9083
{
9184
int make_dir_stru = 0;
85+
//std::string command1 = "test -d " + PARAM.globalv.global_stru_dir + " || mkdir " + PARAM.globalv.global_stru_dir;
9286

9387
times = 0;
9488
while(times<GlobalV::NPROC)
9589
{
9690
if(rank==times)
9791
{
98-
int ret = mkdir(global_stru_dir.c_str(), 0755);
92+
int ret = mkdir(PARAM.globalv.global_stru_dir.c_str(), 0755);
9993
if ( ret == 0 || errno == EEXIST )
10094
{
101-
std::cout << " MAKE THE STRU DIR : " << global_stru_dir << std::endl;
95+
std::cout << " MAKE THE STRU DIR : " << PARAM.globalv.global_stru_dir << std::endl;
10296
make_dir_stru = 1;
10397
}
10498
else
@@ -129,16 +123,17 @@ void ModuleBase::Global_File::make_dir_out(
129123
if((out_dir) && calculation == "md")
130124
{
131125
int make_dir_matrix = 0;
126+
//std::string command1 = "test -d " + PARAM.globalv.global_matrix_dir + " || mkdir " + PARAM.globalv.global_matrix_dir;
132127

133128
times = 0;
134129
while(times<GlobalV::NPROC)
135130
{
136131
if(rank==times)
137132
{
138-
int ret = mkdir(global_matrix_dir.c_str(), 0755);
133+
int ret = mkdir(PARAM.globalv.global_matrix_dir.c_str(), 0755);
139134
if ( ret == 0 || errno == EEXIST )
140135
{
141-
std::cout << " MAKE THE MATRIX DIR : " << global_matrix_dir << std::endl;
136+
std::cout << " MAKE THE MATRIX DIR : " << PARAM.globalv.global_matrix_dir << std::endl;
142137
make_dir_matrix = 1;
143138
}
144139
else
@@ -168,16 +163,17 @@ void ModuleBase::Global_File::make_dir_out(
168163
if(out_wfc_dir)
169164
{
170165
int make_dir_wfc = 0;
166+
//std::string command1 = "test -d " + PARAM.globalv.global_wfc_dir + " || mkdir " + PARAM.globalv.global_wfc_dir;
171167

172168
times = 0;
173169
while(times<GlobalV::NPROC)
174170
{
175171
if(rank==times)
176172
{
177-
int ret = mkdir(global_wfc_dir.c_str(), 0755);
173+
int ret = mkdir(PARAM.globalv.global_wfc_dir.c_str(), 0755);
178174
if ( ret == 0 || errno == EEXIST )
179175
{
180-
std::cout << " MAKE THE WFC DIR : " << global_wfc_dir << std::endl;
176+
std::cout << " MAKE THE WFC DIR : " << PARAM.globalv.global_wfc_dir << std::endl;
181177
make_dir_wfc = 1;
182178
}
183179
else
@@ -204,19 +200,20 @@ void ModuleBase::Global_File::make_dir_out(
204200
#endif
205201
}
206202

207-
if(of_ml_gene_data)
203+
if(PARAM.inp.of_ml_gene_data == 1)
208204
{
209205
int make_dir_descrip = 0;
206+
//std::string command1 = "test -d " + PARAM.globalv.global_mlkedf_descriptor_dir + " || mkdir " + PARAM.globalv.global_mlkedf_descriptor_dir;
210207

211208
times = 0;
212209
while(times<GlobalV::NPROC)
213210
{
214211
if(rank==times)
215212
{
216-
int ret = mkdir(global_mlkedf_descriptor_dir.c_str(), 0755);
213+
int ret = mkdir(PARAM.globalv.global_mlkedf_descriptor_dir.c_str(), 0755);
217214
if ( ret == 0 || errno == EEXIST )
218215
{
219-
std::cout << " MAKE THE MLKEDF DESCRIPTOR DIR : " << global_mlkedf_descriptor_dir << std::endl;
216+
std::cout << " MAKE THE MLKEDF DESCRIPTOR DIR : " << PARAM.globalv.global_mlkedf_descriptor_dir << std::endl;
220217
make_dir_descrip = 1;
221218
}
222219
else
@@ -229,7 +226,7 @@ void ModuleBase::Global_File::make_dir_out(
229226
Parallel_Reduce::reduce_all(make_dir_descrip);
230227
#endif
231228
if(make_dir_descrip > 0)
232-
{
229+
{
233230
break;
234231
}
235232
++times;
@@ -245,19 +242,20 @@ void ModuleBase::Global_File::make_dir_out(
245242
#endif
246243
}
247244

248-
if(deepks_out_freq_elec)
245+
if(PARAM.inp.deepks_out_freq_elec > 0)
249246
{
250247
int make_dir_deepks_elec = 0;
248+
//std::string command1 = "test -d " + PARAM.globalv.global_deepks_label_elec_dir + " || mkdir " + PARAM.globalv.global_deepks_label_elec_dir;
251249

252250
times = 0;
253251
while(times<GlobalV::NPROC)
254252
{
255253
if(rank==times)
256254
{
257-
int ret = mkdir(global_deepks_label_elec_dir.c_str(), 0755);
255+
int ret = mkdir(PARAM.globalv.global_deepks_label_elec_dir.c_str(), 0755);
258256
if ( ret == 0 || errno == EEXIST )
259257
{
260-
std::cout << " MAKE THE DEEPKS LABELS (ELEC) DIR : " << global_deepks_label_elec_dir << std::endl;
258+
std::cout << " MAKE THE DEEPKS LABELS (ELEC) DIR : " << PARAM.globalv.global_deepks_label_elec_dir << std::endl;
261259
make_dir_deepks_elec = 1;
262260
}
263261
else
@@ -270,7 +268,7 @@ void ModuleBase::Global_File::make_dir_out(
270268
Parallel_Reduce::reduce_all(make_dir_deepks_elec);
271269
#endif
272270
if(make_dir_deepks_elec > 0)
273-
{
271+
{
274272
break;
275273
}
276274
++times;
@@ -289,53 +287,53 @@ void ModuleBase::Global_File::make_dir_out(
289287
// mohan add 2010-09-12
290288
if(out_alllog)
291289
{
292-
open_log(GlobalV::ofs_running, log_file, calculation, restart, global_out_dir);
290+
open_log(GlobalV::ofs_running, PARAM.globalv.log_file, calculation, restart);
293291
#if defined(__CUDA) || defined(__ROCM)
294-
open_log(GlobalV::ofs_device, "device" + std::to_string(rank) + ".log", calculation, restart, global_out_dir);
292+
open_log(GlobalV::ofs_device, "device" + std::to_string(rank) + ".log", calculation, restart);
295293
#endif
296294
}
297295
else
298296
{
299297
if(rank==0)
300298
{
301-
open_log(GlobalV::ofs_running, log_file, calculation, restart, global_out_dir);
299+
open_log(GlobalV::ofs_running, PARAM.globalv.log_file, calculation, restart);
302300
#if defined(__CUDA) || defined(__ROCM)
303-
open_log(GlobalV::ofs_device, "device.log", calculation, restart, global_out_dir);
301+
open_log(GlobalV::ofs_device, "device.log", calculation, restart);
304302
#endif
305303
}
306304
}
307305

308306
if(rank==0)
309307
{
310-
open_log(GlobalV::ofs_warning, "warning.log", calculation, restart, global_out_dir);
308+
open_log(GlobalV::ofs_warning, "warning.log", calculation, restart);
311309
}
312310

313311
#ifdef GATHER_INFO
314-
open_log(GlobalV::ofs_info, "math_info_" + std::to_string(rank) + ".log", calculation, restart, global_out_dir);
312+
open_log(GlobalV::ofs_info, "math_info_" + std::to_string(rank) + ".log", calculation, restart);
315313
#endif
316314

317315
return;
318316
}
319317

320-
void ModuleBase::Global_File::make_dir_atom(const std::string &label, const std::string &global_out_dir)
318+
void ModuleBase::Global_File::make_dir_atom(const std::string &label)
321319
{
322320
//----------------------------------------------------------
323321
// EXPLAIN : generate atom dir for each type of atom
324322
//----------------------------------------------------------
325323
std::stringstream ss;
326-
ss << global_out_dir << label << "/";
324+
ss << PARAM.globalv.global_out_dir << label << "/";
327325
ModuleBase::GlobalFunc::MAKE_DIR(ss.str());
328326
return;
329327
}
330328

331-
void ModuleBase::Global_File::open_log(std::ofstream &ofs, const std::string &fn, const std::string &calculation, const bool &restart, const std::string &global_out_dir)
329+
void ModuleBase::Global_File::open_log(std::ofstream &ofs, const std::string &fn, const std::string &calculation, const bool &restart)
332330
{
333331
//----------------------------------------------------------
334332
// USE GLOBAL VARIABLE :
335-
// global_out_dir : (default dir to store "*.log" file)
333+
// PARAM.globalv.global_out_dir : (default dir to store "*.log" file)
336334
//----------------------------------------------------------
337335
std::stringstream ss;
338-
ss << global_out_dir << fn;
336+
ss << PARAM.globalv.global_out_dir << fn;
339337

340338
if(calculation == "md" && restart)
341339
{

source/source_base/global_file.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,10 @@ namespace Global_File
2626
const bool &out_wfc_dir,
2727
const int rank,
2828
const bool &restart,
29-
const bool out_alllog,
30-
const std::string &global_out_dir,
31-
const std::string &global_stru_dir,
32-
const std::string &global_matrix_dir,
33-
const std::string &global_wfc_dir,
34-
const std::string &global_mlkedf_descriptor_dir,
35-
const std::string &global_deepks_label_elec_dir,
36-
const std::string &log_file,
37-
const bool of_ml_gene_data,
38-
const bool deepks_out_freq_elec);
39-
40-
void make_dir_atom(const std::string &label, const std::string &global_out_dir);
41-
void open_log ( std::ofstream &ofs, const std::string &fn, const std::string &calculation, const bool &restart, const std::string &global_out_dir);
29+
const bool out_alllog = false);
30+
31+
void make_dir_atom(const std::string &label);
32+
void open_log ( std::ofstream &ofs, const std::string &fn, const std::string &calculation, const bool &restart);
4233
void close_log( std::ofstream &ofs, const std::string &fn);
4334
void close_all_log(const int rank, const bool out_alllog = false, const std::string& calculation = "md");
4435
}

source/source_base/kernels/cuda/math_kernel_op.cu

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "source_base/module_device/memory_op.h"
22
#include "source_base/kernels/math_kernel_op.h"
3+
#include "source_psi/psi.h"
34
#include "source_base/tool_quit.h"
45
#include "source_base/module_container/base/third_party/cublas.h"
56

@@ -313,6 +314,9 @@ void gemm_op<std::complex<double>, base_device::DEVICE_GPU>::operator()(const ch
313314
{
314315
cublasOperation_t cutransA = judge_trans_op(true, transa, "gemm_op");
315316
cublasOperation_t cutransB = judge_trans_op(true, transb, "gemm_op");
317+
if (cublas_handle == nullptr) {
318+
CHECK_CUBLAS(cublasCreate(&cublas_handle));
319+
}
316320
CHECK_CUBLAS(cublasZgemm(cublas_handle, cutransA, cutransB, m, n ,k, (double2*)alpha, (double2*)a , lda, (double2*)b, ldb, (double2*)beta, (double2*)c, ldc));
317321
}
318322

source/source_base/kernels/rocm/math_kernel_op.hip.cu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "source_base/module_device/memory_op.h"
22
#include "source_base/kernels/math_kernel_op.h"
3+
#include "source_psi/psi.h"
34
#include "source_base/tool_quit.h"
45

56
#include <base/macros/macros.h>

source/source_base/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void calculate()
3636
/*
3737
time_t time_start = std::time(NULL);
3838
39-
// ModuleBase::timer::start();
39+
// ModuleBase::timer::tick();
4040
4141
//----------------------------------------------------------
4242
// main program for doing electronic structure calculations

0 commit comments

Comments
 (0)