Skip to content

Commit fea0620

Browse files
authored
fix undefined behavior (#5251)
1 parent a5c35d9 commit fea0620

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

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)