Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added hooks for HIP #215

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/eigenSolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/eigenSolverKpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/include/isddft.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion src/initialization.c
Original file line number Diff line number Diff line change
Expand Up @@ -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" };
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/readfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
Loading