Skip to content

Commit 16082a3

Browse files
authored
Merge branch 'develop' into consts_refactor
2 parents 14c2036 + 50a204f commit 16082a3

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

source/module_elecstate/module_dm/density_matrix.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR()
496496
{
497497
throw std::string("Atom-pair not belong this process");
498498
}
499+
std::vector<std::complex<double>> tmp_DMR;
500+
if (PARAM.inp.nspin == 4)
501+
{
502+
tmp_DMR.resize(tmp_ap.get_size());
503+
}
499504
for (int ir = 0; ir < tmp_ap.get_R_size(); ++ir)
500505
{
501506
const ModuleBase::Vector3<int> r_index = tmp_ap.get_R_index(ir);
@@ -553,9 +558,7 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR()
553558
// treat DMR as pauli matrix when NSPIN=4
554559
if (PARAM.inp.nspin == 4)
555560
{
556-
std::vector<std::complex<double>> tmp_DMR(this->_paraV->get_col_size()
557-
* this->_paraV->get_row_size(),
558-
std::complex<double>(0.0, 0.0));
561+
tmp_DMR.assign(tmp_ap.get_size(), std::complex<double>(0.0, 0.0));
559562
for (int ik = 0; ik < this->_nks; ++ik)
560563
{
561564
// cal k_phase
@@ -573,35 +576,34 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR()
573576
// jump DMK to fill DMR
574577
// DMR is row-major, DMK is column-major
575578
tmp_DMK_pointer += col_ap * this->_paraV->nrow + row_ap;
576-
for (int mu = 0; mu < this->_paraV->get_row_size(iat1); ++mu)
579+
for (int mu = 0; mu < tmp_ap.get_row_size(); ++mu)
577580
{
578-
BlasConnector::axpy(this->_paraV->get_col_size(iat2),
581+
BlasConnector::axpy(tmp_ap.get_col_size(),
579582
kphase,
580583
tmp_DMK_pointer,
581584
ld_hk,
582585
tmp_DMR_pointer,
583586
1);
584587
tmp_DMK_pointer += 1;
585-
tmp_DMR_pointer += this->_paraV->get_col_size(iat2);
588+
tmp_DMR_pointer += tmp_ap.get_col_size();
586589
}
587590
}
588591
int npol = 2;
589592
// step_trace = 0 for NSPIN=1,2; ={0, 1, local_col, local_col+1} for NSPIN=4
590-
std::vector<int> step_trace(npol * npol, 0);
593+
int step_trace[4];
591594
for (int is = 0; is < npol; is++)
592595
{
593596
for (int is2 = 0; is2 < npol; is2++)
594597
{
595-
step_trace[is * npol + is2] = this->_paraV->get_col_size(iat2) * is + is2;
596-
// step_trace[is + is2 * npol] = this->_paraV->get_col_size(iat2) * is + is2;
598+
step_trace[is * npol + is2] = tmp_ap.get_col_size() * is + is2;
597599
}
598600
}
599601
std::complex<double> tmp[4];
600602
double* target_DMR = tmp_matrix->get_pointer();
601603
std::complex<double>* tmp_DMR_pointer = tmp_DMR.data();
602-
for (int irow = 0; irow < this->_paraV->get_row_size(iat1); irow += 2)
604+
for (int irow = 0; irow < tmp_ap.get_row_size(); irow += 2)
603605
{
604-
for (int icol = 0; icol < this->_paraV->get_col_size(iat2); icol += 2)
606+
for (int icol = 0; icol < tmp_ap.get_col_size(); icol += 2)
605607
{
606608
// catch the 4 spin component value of one orbital pair
607609
tmp[0] = tmp_DMR_pointer[icol + step_trace[0]];
@@ -616,8 +618,8 @@ void DensityMatrix<std::complex<double>, double>::cal_DMR()
616618
= -tmp[1].imag() + tmp[2].imag(); // (i * (rho_updown - rho_downup)).real()
617619
target_DMR[icol + step_trace[3]] = tmp[0].real() - tmp[3].real();
618620
}
619-
tmp_DMR_pointer += this->_paraV->get_col_size(iat2) * 2;
620-
target_DMR += this->_paraV->get_col_size(iat2) * 2;
621+
tmp_DMR_pointer += tmp_ap.get_col_size() * 2;
622+
target_DMR += tmp_ap.get_col_size() * 2;
621623
}
622624
}
623625
}

source/module_hsolver/kernels/cuda/diag_cusolver.cuh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@ class Diag_Cusolver_gvd{
2121
// private variables
2222
//-------------------
2323

24-
cusolverDnHandle_t cusolverH;
24+
cusolverDnHandle_t cusolverH = nullptr;
2525

26-
cusolverEigType_t itype; //problem type: A*x = (lambda)*B*x
27-
cusolverEigMode_t jobz; // compute eigenvalues and eigenvectors.
28-
cublasFillMode_t uplo;
26+
cusolverEigType_t itype = CUSOLVER_EIG_TYPE_1; //problem type: A*x = (lambda)*B*x
27+
cusolverEigMode_t jobz = CUSOLVER_EIG_MODE_NOVECTOR; // compute eigenvalues and eigenvectors.
28+
cublasFillMode_t uplo = CUBLAS_FILL_MODE_LOWER;
2929

30-
int m;
31-
int lda;
30+
int m = 0;
31+
int lda = 0;
3232

33-
double *d_A;
34-
double *d_B;
35-
double *d_work;
33+
double *d_A = nullptr;
34+
double *d_B = nullptr;
35+
double *d_work = nullptr;
3636

37-
cuDoubleComplex *d_A2;
38-
cuDoubleComplex *d_B2;
39-
cuDoubleComplex *d_work2;
37+
cuDoubleComplex *d_A2 = nullptr;
38+
cuDoubleComplex *d_B2 = nullptr;
39+
cuDoubleComplex *d_work2 = nullptr;
4040

41-
double *d_W ;
42-
int *devInfo;
41+
double *d_W = nullptr;
42+
int *devInfo = nullptr;
4343

44-
int lwork;
45-
int info_gpu;
44+
int lwork = 0;
45+
int info_gpu = 0;
4646

4747
// subroutines that are related to initializing the class:
4848
// - init_double : initializing relevant double type data structures and gpu apis' handle and memory
@@ -55,7 +55,7 @@ class Diag_Cusolver_gvd{
5555
void finalize(); // for recycling the usage of the static class Diag_Cusolver_gvd
5656
public:
5757

58-
int is_init; // For expensive gpu initialization only once when using cusolver for lcao
58+
int is_init = 0; // For expensive gpu initialization only once when using cusolver for lcao
5959

6060
Diag_Cusolver_gvd();
6161
~Diag_Cusolver_gvd();

0 commit comments

Comments
 (0)