Skip to content

Commit 3ccbad9

Browse files
authored
Remove dependencies in rest files in source_base (#7333)
* Remove dependencies in global_file.cpp * Move welcome banner output to main.cpp * Remove psi dependencies in math_kernel_op
1 parent 32bd415 commit 3ccbad9

10 files changed

Lines changed: 155 additions & 110 deletions

File tree

source/source_base/global_file.cpp

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <cerrno>
1515
#include <sstream>
1616
#include "global_function.h"
17-
#include "source_io/module_parameter/parameter.h"
1817
#include "global_variable.h"
1918
#include "source_base/parallel_common.h"
2019
#include "source_base/parallel_reduce.h"
@@ -31,7 +30,16 @@ void ModuleBase::Global_File::make_dir_out(
3130
const bool &out_wfc_dir,
3231
const int rank,
3332
const bool &restart,
34-
const bool out_alllog)
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)
3543
{
3644
//----------------------------------------------------------
3745
// USE STL FUNCTION
@@ -43,17 +51,16 @@ void ModuleBase::Global_File::make_dir_out(
4351
#endif
4452
int make_dir = 0;
4553
// mohan update 2011-05-03
46-
//std::string command0 = "test -d " + PARAM.globalv.global_out_dir + " || mkdir " + PARAM.globalv.global_out_dir;
4754

4855
int times = 0;
4956
while(times<GlobalV::NPROC)
5057
{
5158
if(rank==times)
5259
{
53-
int ret = mkdir(PARAM.globalv.global_out_dir.c_str(), 0755);
60+
int ret = mkdir(global_out_dir.c_str(), 0755);
5461
if ( ret == 0 || errno == EEXIST )
5562
{
56-
std::cout << " MAKE THE DIR : " << PARAM.globalv.global_out_dir << std::endl;
63+
std::cout << " MAKE THE DIR : " << global_out_dir << std::endl;
5764
make_dir = 1;
5865
}
5966
else
@@ -82,17 +89,16 @@ void ModuleBase::Global_File::make_dir_out(
8289
if(calculation == "md")
8390
{
8491
int make_dir_stru = 0;
85-
//std::string command1 = "test -d " + PARAM.globalv.global_stru_dir + " || mkdir " + PARAM.globalv.global_stru_dir;
8692

8793
times = 0;
8894
while(times<GlobalV::NPROC)
8995
{
9096
if(rank==times)
9197
{
92-
int ret = mkdir(PARAM.globalv.global_stru_dir.c_str(), 0755);
98+
int ret = mkdir(global_stru_dir.c_str(), 0755);
9399
if ( ret == 0 || errno == EEXIST )
94100
{
95-
std::cout << " MAKE THE STRU DIR : " << PARAM.globalv.global_stru_dir << std::endl;
101+
std::cout << " MAKE THE STRU DIR : " << global_stru_dir << std::endl;
96102
make_dir_stru = 1;
97103
}
98104
else
@@ -123,17 +129,16 @@ void ModuleBase::Global_File::make_dir_out(
123129
if((out_dir) && calculation == "md")
124130
{
125131
int make_dir_matrix = 0;
126-
//std::string command1 = "test -d " + PARAM.globalv.global_matrix_dir + " || mkdir " + PARAM.globalv.global_matrix_dir;
127132

128133
times = 0;
129134
while(times<GlobalV::NPROC)
130135
{
131136
if(rank==times)
132137
{
133-
int ret = mkdir(PARAM.globalv.global_matrix_dir.c_str(), 0755);
138+
int ret = mkdir(global_matrix_dir.c_str(), 0755);
134139
if ( ret == 0 || errno == EEXIST )
135140
{
136-
std::cout << " MAKE THE MATRIX DIR : " << PARAM.globalv.global_matrix_dir << std::endl;
141+
std::cout << " MAKE THE MATRIX DIR : " << global_matrix_dir << std::endl;
137142
make_dir_matrix = 1;
138143
}
139144
else
@@ -163,17 +168,16 @@ void ModuleBase::Global_File::make_dir_out(
163168
if(out_wfc_dir)
164169
{
165170
int make_dir_wfc = 0;
166-
//std::string command1 = "test -d " + PARAM.globalv.global_wfc_dir + " || mkdir " + PARAM.globalv.global_wfc_dir;
167171

168172
times = 0;
169173
while(times<GlobalV::NPROC)
170174
{
171175
if(rank==times)
172176
{
173-
int ret = mkdir(PARAM.globalv.global_wfc_dir.c_str(), 0755);
177+
int ret = mkdir(global_wfc_dir.c_str(), 0755);
174178
if ( ret == 0 || errno == EEXIST )
175179
{
176-
std::cout << " MAKE THE WFC DIR : " << PARAM.globalv.global_wfc_dir << std::endl;
180+
std::cout << " MAKE THE WFC DIR : " << global_wfc_dir << std::endl;
177181
make_dir_wfc = 1;
178182
}
179183
else
@@ -200,20 +204,19 @@ void ModuleBase::Global_File::make_dir_out(
200204
#endif
201205
}
202206

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

208211
times = 0;
209212
while(times<GlobalV::NPROC)
210213
{
211214
if(rank==times)
212215
{
213-
int ret = mkdir(PARAM.globalv.global_mlkedf_descriptor_dir.c_str(), 0755);
216+
int ret = mkdir(global_mlkedf_descriptor_dir.c_str(), 0755);
214217
if ( ret == 0 || errno == EEXIST )
215218
{
216-
std::cout << " MAKE THE MLKEDF DESCRIPTOR DIR : " << PARAM.globalv.global_mlkedf_descriptor_dir << std::endl;
219+
std::cout << " MAKE THE MLKEDF DESCRIPTOR DIR : " << global_mlkedf_descriptor_dir << std::endl;
217220
make_dir_descrip = 1;
218221
}
219222
else
@@ -226,7 +229,7 @@ void ModuleBase::Global_File::make_dir_out(
226229
Parallel_Reduce::reduce_all(make_dir_descrip);
227230
#endif
228231
if(make_dir_descrip > 0)
229-
{
232+
{
230233
break;
231234
}
232235
++times;
@@ -242,20 +245,19 @@ void ModuleBase::Global_File::make_dir_out(
242245
#endif
243246
}
244247

245-
if(PARAM.inp.deepks_out_freq_elec > 0)
248+
if(deepks_out_freq_elec)
246249
{
247250
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;
249251

250252
times = 0;
251253
while(times<GlobalV::NPROC)
252254
{
253255
if(rank==times)
254256
{
255-
int ret = mkdir(PARAM.globalv.global_deepks_label_elec_dir.c_str(), 0755);
257+
int ret = mkdir(global_deepks_label_elec_dir.c_str(), 0755);
256258
if ( ret == 0 || errno == EEXIST )
257259
{
258-
std::cout << " MAKE THE DEEPKS LABELS (ELEC) DIR : " << PARAM.globalv.global_deepks_label_elec_dir << std::endl;
260+
std::cout << " MAKE THE DEEPKS LABELS (ELEC) DIR : " << global_deepks_label_elec_dir << std::endl;
259261
make_dir_deepks_elec = 1;
260262
}
261263
else
@@ -268,7 +270,7 @@ void ModuleBase::Global_File::make_dir_out(
268270
Parallel_Reduce::reduce_all(make_dir_deepks_elec);
269271
#endif
270272
if(make_dir_deepks_elec > 0)
271-
{
273+
{
272274
break;
273275
}
274276
++times;
@@ -287,53 +289,53 @@ void ModuleBase::Global_File::make_dir_out(
287289
// mohan add 2010-09-12
288290
if(out_alllog)
289291
{
290-
open_log(GlobalV::ofs_running, PARAM.globalv.log_file, calculation, restart);
292+
open_log(GlobalV::ofs_running, log_file, calculation, restart, global_out_dir);
291293
#if defined(__CUDA) || defined(__ROCM)
292-
open_log(GlobalV::ofs_device, "device" + std::to_string(rank) + ".log", calculation, restart);
294+
open_log(GlobalV::ofs_device, "device" + std::to_string(rank) + ".log", calculation, restart, global_out_dir);
293295
#endif
294296
}
295297
else
296298
{
297299
if(rank==0)
298300
{
299-
open_log(GlobalV::ofs_running, PARAM.globalv.log_file, calculation, restart);
301+
open_log(GlobalV::ofs_running, log_file, calculation, restart, global_out_dir);
300302
#if defined(__CUDA) || defined(__ROCM)
301-
open_log(GlobalV::ofs_device, "device.log", calculation, restart);
303+
open_log(GlobalV::ofs_device, "device.log", calculation, restart, global_out_dir);
302304
#endif
303305
}
304306
}
305307

306308
if(rank==0)
307309
{
308-
open_log(GlobalV::ofs_warning, "warning.log", calculation, restart);
310+
open_log(GlobalV::ofs_warning, "warning.log", calculation, restart, global_out_dir);
309311
}
310312

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

315317
return;
316318
}
317319

318-
void ModuleBase::Global_File::make_dir_atom(const std::string &label)
320+
void ModuleBase::Global_File::make_dir_atom(const std::string &label, const std::string &global_out_dir)
319321
{
320322
//----------------------------------------------------------
321323
// EXPLAIN : generate atom dir for each type of atom
322324
//----------------------------------------------------------
323325
std::stringstream ss;
324-
ss << PARAM.globalv.global_out_dir << label << "/";
326+
ss << global_out_dir << label << "/";
325327
ModuleBase::GlobalFunc::MAKE_DIR(ss.str());
326328
return;
327329
}
328330

329-
void ModuleBase::Global_File::open_log(std::ofstream &ofs, const std::string &fn, const std::string &calculation, const bool &restart)
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)
330332
{
331333
//----------------------------------------------------------
332334
// USE GLOBAL VARIABLE :
333-
// PARAM.globalv.global_out_dir : (default dir to store "*.log" file)
335+
// global_out_dir : (default dir to store "*.log" file)
334336
//----------------------------------------------------------
335337
std::stringstream ss;
336-
ss << PARAM.globalv.global_out_dir << fn;
338+
ss << global_out_dir << fn;
337339

338340
if(calculation == "md" && restart)
339341
{

source/source_base/global_file.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,19 @@ namespace Global_File
2626
const bool &out_wfc_dir,
2727
const int rank,
2828
const bool &restart,
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);
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);
3342
void close_log( std::ofstream &ofs, const std::string &fn);
3443
void close_all_log(const int rank, const bool out_alllog = false, const std::string& calculation = "md");
3544
}

source/source_base/kernels/cuda/math_kernel_op.cu

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

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

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

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

source/source_base/parallel_global.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "source_base/parallel_reduce.h"
1717
#include "source_base/global_variable.h"
1818
#include "source_base/tool_quit.h"
19-
#include "source_main/version.h"
2019

2120
#include <iostream>
2221
#include <thread>
@@ -175,40 +174,6 @@ void Parallel_Global::read_pal_param(int argc,
175174

176175
NTHREAD_PER_PROC = current_thread_num;
177176

178-
if (MY_RANK == 0)
179-
{
180-
#ifdef VERSION
181-
const char* version = VERSION;
182-
#else
183-
const char* version = "unknown";
184-
#endif
185-
#ifdef COMMIT_INFO
186-
#include "commit.h"
187-
const char* commit = COMMIT;
188-
#else
189-
const char* commit = "unknown";
190-
#endif
191-
std::cout << " "
192-
<< std::endl
193-
<< " ABACUS " << version << std::endl
194-
<< std::endl
195-
<< " Atomic-orbital Based Ab-initio Computation at UStc "
196-
<< std::endl
197-
<< std::endl
198-
<< " Website: http://abacus.ustc.edu.cn/ "
199-
<< std::endl
200-
<< " Documentation: https://abacus.deepmodeling.com/ "
201-
<< std::endl
202-
<< " Repository: https://github.com/abacusmodeling/abacus-develop "
203-
<< std::endl
204-
<< " https://github.com/deepmodeling/abacus-develop "
205-
<< std::endl
206-
<< " Commit: " << commit << std::endl
207-
<< std::endl;
208-
time_t time_now = time(nullptr);
209-
std::cout << " " << ctime(&time_now);
210-
}
211-
212177
// for test
213178
/*
214179
for (int i=0; i<NPROC; i++)

0 commit comments

Comments
 (0)