diff --git a/ChangeLog b/ChangeLog index 2ce50126..a8c215fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,12 @@ -Name -changes +-------------- +August 16, 2024 +Name: Abhiraj Sharma +Changes: initialization.c, eigenSolver.c, eigenSolverKpt.c, include/isddft.h +1. Added hooks for HIP code + -------------- August 15, 2024 Name: Shashikant Kumar diff --git a/src/eigenSolver.c b/src/eigenSolver.c index 378f7232..27a6f4ce 100644 --- a/src/eigenSolver.c +++ b/src/eigenSolver.c @@ -382,7 +382,7 @@ void CheFSI(SPARC_OBJ *pSPARC, double lambda_cutoff, double *x0, int count, int // if eigvals are calculated in root process, then bcast the eigvals // SPARCX_ACCEL_NOTE Need to add this to propagate GPU calculated eigenvalues back to the other MPI tasks #ifdef SPARCX_ACCEL - if (pSPARC->useACCEL == 1 && nproc_kptcomm > 1) + if (pSPARC->useACCEL == 1 && nproc_kptcomm > 1 && (!pSPARC->useHIP || pSPARC->useLAPACK == 1)) MPI_Bcast(pSPARC->lambda, pSPARC->Nstates * pSPARC->Nspin_spincomm, MPI_DOUBLE, 0, pSPARC->kptcomm); #else if (pSPARC->useLAPACK == 1 && nproc_kptcomm > 1) { @@ -477,7 +477,7 @@ void Solve_standard_EigenProblem(SPARC_OBJ *pSPARC, int k, int spn_i) #endif #ifdef SPARCX_ACCEL // SPARCX_ACCEL_NOTE - if (pSPARC->useACCEL == 1 && pSPARC->cell_typ < 20) { + if (pSPARC->useACCEL == 1 && pSPARC->cell_typ < 20 && !pSPARC->useHIP) { int info = 0; t1 = MPI_Wtime(); if (!pSPARC->bandcomm_index) { @@ -1265,7 +1265,7 @@ void DP_Solve_Generalized_EigenProblem(SPARC_OBJ *pSPARC, int spn_i) if (DP_CheFSI == NULL) return; #ifdef SPARCX_ACCEL // SPARCX_ACCEL_NOTE -- ADDS GPU Eigensolver - if (pSPARC->useACCEL == 1 && pSPARC->cell_typ < 20) + if (pSPARC->useACCEL == 1 && pSPARC->cell_typ < 20 && !pSPARC->useHIP) { int Ns_dp = DP_CheFSI->Ns_dp; int rank_kpt = DP_CheFSI->rank_kpt; @@ -1687,7 +1687,7 @@ void Solve_Generalized_EigenProblem(SPARC_OBJ *pSPARC, int k, int spn_i) #endif #ifdef SPARCX_ACCEL // SPARCX_ACCEL_NOTE - if (pSPARC->useACCEL == 1 && pSPARC->cell_typ < 20) { + if (pSPARC->useACCEL == 1 && pSPARC->cell_typ < 20 && !pSPARC->useHIP) { int info = 0; t1 = MPI_Wtime(); if (!pSPARC->bandcomm_index) { diff --git a/src/eigenSolverKpt.c b/src/eigenSolverKpt.c index 57f84f5b..d3792d82 100644 --- a/src/eigenSolverKpt.c +++ b/src/eigenSolverKpt.c @@ -289,7 +289,7 @@ void CheFSI_kpt(SPARC_OBJ *pSPARC, double lambda_cutoff, double _Complex *x0, in t3 = MPI_Wtime(); // if eigvals are calculated in root process, then bcast the eigvals #ifdef SPARCX_ACCEL - if (pSPARC->useACCEL == 1 && nproc_kptcomm > 1) + if (pSPARC->useACCEL == 1 && nproc_kptcomm > 1 && (!pSPARC->useHIP || pSPARC->useLAPACK == 1)) MPI_Bcast(pSPARC->lambda, pSPARC->Nstates * pSPARC->Nkpts_kptcomm * pSPARC->Nspin_spincomm, MPI_DOUBLE, 0, pSPARC->kptcomm); #else if (pSPARC->useLAPACK == 1 && nproc_kptcomm > 1) { @@ -839,7 +839,7 @@ void DP_Solve_Generalized_EigenProblem_kpt(SPARC_OBJ *pSPARC, int kpt, int spn_i if (DP_CheFSI_kpt == NULL) return; #ifdef SPARCX_ACCEL // SPARCX_ACCEL_NOTE -- ADDS GPU Eigensolver - if (pSPARC->useACCEL == 1 && pSPARC->cell_typ < 20) + if (pSPARC->useACCEL == 1 && pSPARC->cell_typ < 20 && !pSPARC->useHIP) { int Ns_dp = DP_CheFSI_kpt->Ns_dp; int rank_kpt = DP_CheFSI_kpt->rank_kpt; diff --git a/src/include/isddft.h b/src/include/isddft.h index d23f5c0f..fc3dcb30 100644 --- a/src/include/isddft.h +++ b/src/include/isddft.h @@ -500,6 +500,7 @@ typedef struct _SPARC_OBJ{ double *Mp_s; // whole projected mass matrix Mp redistributed for solving eigenproblem (GLOBAL) #ifdef ACCEL int useACCEL; // SPARCX_ACCEL_NOTE Flag needed to trigger GPU Acceleration + int useHIP; // Flag to hook in HIP #endif int useLAPACK; // flag for using LAPACK_dsygv to solve subspace eigenproblem int eig_serial_maxns;// maximum Nstates for using LAPACK to solve the subspace eigenproblem by default, diff --git a/src/initialization.c b/src/initialization.c index 4e12debf..821cf4ba 100644 --- a/src/initialization.c +++ b/src/initialization.c @@ -346,6 +346,12 @@ void Initialize(SPARC_OBJ *pSPARC, int argc, char *argv[]) { #ifdef SPARCX_ACCEL // Activating flag for using hardware acceleration at compile time. pSPARC->useACCEL = 1; + #ifdef HIP + pSPARC->useHIP = 1; + #else + pSPARC->useHIP = 0; + #endif + if (rank == 0) { char *hwaccel[2] = { "DISABLED", "ENABLED" }; @@ -3464,7 +3470,7 @@ void write_output_init(SPARC_OBJ *pSPARC) { } fprintf(output_fp,"***************************************************************************\n"); - fprintf(output_fp,"* SPARC (version August 11, 2024) *\n"); + fprintf(output_fp,"* SPARC (version August 16, 2024) *\n"); fprintf(output_fp,"* Copyright (c) 2020 Material Physics & Mechanics Group, Georgia Tech *\n"); fprintf(output_fp,"* Distributed under GNU General Public License 3 (GPL) *\n"); fprintf(output_fp,"* Start time: %s *\n",c_time_str); diff --git a/src/readfiles.c b/src/readfiles.c index 68cf9dbb..8666f5eb 100644 --- a/src/readfiles.c +++ b/src/readfiles.c @@ -1818,7 +1818,7 @@ void read_pseudopotential_PSP(SPARC_INPUT_OBJ *pSPARC_Input, SPARC_OBJ *pSPARC) } // Check the scientific notation of floating point number - char notation = '\0'; + /* char notation = '\0'; int num = 0; do { fscanf(psd_fp,"%s",str); @@ -1829,7 +1829,7 @@ void read_pseudopotential_PSP(SPARC_INPUT_OBJ *pSPARC_Input, SPARC_OBJ *pSPARC) " Please run sed -i -e 's/%c-/E-/g' -e 's/%c+/E+/g' *.psp8 in the\n" " pseudopotential directory to convert to a compatible scientific notation\n"RESET, notation, notation); exit(EXIT_FAILURE); - } + }*/ // reset file pointer to the start of the file fseek(psd_fp, 0L, SEEK_SET); // returns 0 if succeeded, can use to check status