Skip to content

Commit e507003

Browse files
committed
Merge branch 'develop' of github.com:deepmodeling/abacus-develop into HSolver
2 parents 3c80ac0 + 7b42f40 commit e507003

File tree

13 files changed

+97
-99
lines changed

13 files changed

+97
-99
lines changed

.github/workflows/cuda.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,20 @@ jobs:
4242
run: |
4343
nvidia-smi
4444
cmake -B build -DUSE_CUSOLVER_LCAO=ON
45-
cmake --build build -j4
45+
cmake --build build -j4
4646
cmake --install build
47+
cmake -B build -DBUILD_TESTING=ON
48+
cmake --build build -j4 --target hsolver_diago
4749
- name: Test
4850
run: |
4951
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64
5052
cd tests/integrate
5153
echo "ks_solver cusolver" >> ./270_NO_MD_2O/INPUT
5254
./Autotest.sh -r 270_NO_MD_2O
55+
cd ../../source/src_pdiag/test/
56+
cp ../../../build/source/src_pdiag/test/hsolver_diago .
57+
./hsolver_diago
58+
bash diago_parallel_test.sh
5359
5460
stop-runner:
5561
name: Stop self-hosted EC2 runner

examples/performance/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ check_out() {
3737
cal=$(grep "$key" $outfile | awk '{printf "%.'$ca'f\n",$2}')
3838
ref=$(grep "$key" result.ref | awk '{printf "%.'$ca'f\n",$2}')
3939
deviation=$(awk 'BEGIN {x='$ref';y='$cal';if (x<y) {a=y-x} else {a=x-y};printf "%.'$ca'f\n",a}')
40-
deviation1=$(awk 'BEGIN{print '$deviation'*(10**'$ca')}')
41-
40+
deviation1=$(awk 'BEGIN{print '$deviation'*(10^'$ca')}')
41+
4242
if [ $key == "totaltimeref" ]; then
4343
break
4444
fi

source/driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void Driver::atomic_world(void)
9393
// lcao: linear combination of atomic orbitals
9494
//--------------------------------------------------
9595
string use_ensol;
96-
ModuleESolver::ESolver *p_esolver;
96+
ModuleESolver::ESolver *p_esolver = nullptr;
9797
if(GlobalV::BASIS_TYPE=="pw" || GlobalV::BASIS_TYPE=="lcao_in_pw")
9898
{
9999
if(GlobalV::CALCULATION.substr(0,3) == "sto") use_ensol = "sdft_pw";

source/module_esolver/esolver.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ namespace ModuleESolver
4545

4646
void clean_esolver(ESolver*& pesolver)
4747
{
48-
if (pesolver != NULL)
49-
{
50-
delete pesolver;
51-
}
48+
delete pesolver;
5249
}
5350

5451
}

source/module_esolver/esolver_fp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ModuleESolver
1414
}
1515
ESolver_FP::~ESolver_FP()
1616
{
17-
if(pw_rho!=NULL) delete pw_rho;
17+
delete pw_rho;
1818
}
1919
void ESolver_FP::Init(Input& inp, UnitCell_pseudo& cell)
2020
{

source/module_esolver/esolver_ks.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ namespace ModuleESolver
3636
tmp->setbxyz(INPUT.bx,INPUT.by,INPUT.bz);
3737
}
3838

39+
ESolver_KS::~ESolver_KS()
40+
{
41+
delete this->pw_wfc;
42+
delete this->pelec;
43+
delete this->phami;
44+
delete this->phsol;
45+
}
46+
3947
void ESolver_KS::Init(Input& inp, UnitCell_pseudo& ucell)
4048
{
4149
ESolver_FP::Init(inp,ucell);

source/module_esolver/esolver_ks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace ModuleESolver
1616
{
1717
public:
1818
ESolver_KS();
19+
virtual ~ESolver_KS();
1920
// HSolver* phsol;
2021
double diag_ethr; // diag threshold
2122
double scf_thr; // scf threshold

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,6 @@ namespace ModuleESolver
4848
}
4949
ESolver_KS_PW::~ESolver_KS_PW()
5050
{
51-
if(this->pelec!=nullptr)
52-
{
53-
delete this->pelec;
54-
}
55-
if(this->phami!=nullptr)
56-
{
57-
delete this->phami;
58-
}
59-
if(this->phsol!=nullptr)
60-
{
61-
delete this->phsol;
62-
}
6351
}
6452

6553
void ESolver_KS_PW::Init(Input& inp, UnitCell_pseudo& ucell)

source/module_gint/gint_tools.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace Gint_Tools
3939
const int jby,
4040
const int kbz)
4141
{
42-
int *vindex = (int*)malloc(GlobalC::bigpw->bxyz*sizeof(int));
42+
int *vindex = new int[GlobalC::bigpw->bxyz];
4343
int bindex=0;
4444
// z is the fastest,
4545
// ipart can be obtained by using a previously stored array
@@ -71,12 +71,12 @@ namespace Gint_Tools
7171
{
7272
// set the index for obtaining local potentials
7373
int* vindex = Gint_Tools::get_vindex(ncyz, ibx, jby, kbz);
74-
double *vldr3 = (double*)malloc(GlobalC::bigpw->bxyz*sizeof(double));
74+
double *vldr3 = new double[GlobalC::bigpw->bxyz];
7575
for(int ib=0; ib<GlobalC::bigpw->bxyz; ib++)
7676
{
7777
vldr3[ib]=vlocal[vindex[ib]] * dv;
7878
}
79-
free(vindex); vindex=nullptr;
79+
delete[] vindex;
8080
return vldr3;
8181
}
8282

@@ -88,12 +88,12 @@ namespace Gint_Tools
8888
{
8989
// set the index for obtaining local potentials
9090
int* vindex = Gint_Tools::get_vindex(start_ind, ncyz);
91-
double *vldr3 = (double*)malloc(GlobalC::bigpw->bxyz*sizeof(double));
91+
double *vldr3 = new double[GlobalC::bigpw->bxyz];
9292
for(int ib=0; ib<GlobalC::bigpw->bxyz; ib++)
9393
{
9494
vldr3[ib]=vlocal[vindex[ib]] * dv;
9595
}
96-
free(vindex); vindex=nullptr;
96+
delete[] vindex;
9797
return vldr3;
9898
}
9999

source/module_gint/gint_tools.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ namespace Gint_Tools
243243
template<typename T>
244244
Array_Pool<T>::Array_Pool(const int nr, const int nc) // Attention: uninitialized
245245
{
246-
ptr_1D = (T*)malloc(nr*nc*sizeof(T));
247-
ptr_2D = (T**)malloc(nr*sizeof(T*));
246+
ptr_1D = new T[nr*nc];
247+
ptr_2D = new T*[nr];
248248
for (int ir=0; ir<nr; ++ir)
249249
ptr_2D[ir] = &ptr_1D[ir*nc];
250250
}
@@ -254,15 +254,15 @@ namespace Gint_Tools
254254
{
255255
ptr_1D = array.ptr_1D;
256256
ptr_2D = array.ptr_2D;
257-
free(array.ptr_2D); array.ptr_2D=nullptr;
258-
free(array.ptr_1D); array.ptr_1D=nullptr;
257+
delete[] array.ptr_2D;
258+
delete[] array.ptr_1D;
259259
}
260260

261261
template<typename T>
262262
Array_Pool<T>::~Array_Pool()
263263
{
264-
free(ptr_2D);
265-
free(ptr_1D);
264+
delete[] ptr_2D;
265+
delete[] ptr_1D;
266266
}
267267
}
268268

0 commit comments

Comments
 (0)