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

With hypre #751

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8764c54
Initial BML-hypre integration to access sparse matrix multiplication …
oseikuffuor1 Oct 18, 2023
0fe50ff
Initial BML-hypre integration to access sparse matrix multiplication …
oseikuffuor1 Oct 18, 2023
4cba29d
Merge branch 'with-hypre' of github.com:oseikuffuor1/bml into with-hypre
oseikuffuor1 Dec 4, 2023
6587fb1
Finalize integration with hypre and some minor code cleanup.
oseikuffuor1 Dec 5, 2023
ac832cc
Added build script to build BML with hypre on summit using gnu compil…
oseikuffuor1 Dec 5, 2023
ee2152a
Initial BML-hypre integration to access sparse matrix multiplication …
oseikuffuor1 Oct 18, 2023
9c340c9
Finalize integration with hypre and some minor code cleanup.
oseikuffuor1 Dec 5, 2023
017ce6d
Added build script to build BML with hypre on summit using gnu compil…
oseikuffuor1 Dec 5, 2023
011f409
Merge branch 'with-hypre' of github.com:oseikuffuor1/bml into with-hypre
oseikuffuor1 Dec 7, 2023
ce03df3
Initial BML-hypre integration to access sparse matrix multiplication …
oseikuffuor1 Oct 18, 2023
cad6c7b
Finalize integration with hypre and some minor code cleanup.
oseikuffuor1 Dec 5, 2023
a6f0822
Added build script to build BML with hypre on summit using gnu compil…
oseikuffuor1 Dec 5, 2023
e863a81
Update matrix multiplication routine to support hypre calls.
oseikuffuor1 Oct 18, 2023
f9bc2b2
Allow integration of BML with hypre library.
oseikuffuor1 Mar 19, 2024
884a5b3
Use C++ compiler when building with hypre.
oseikuffuor1 Mar 19, 2024
2ef65f8
Update and finalize bml+hypre integration with updates from master.
oseikuffuor1 Mar 19, 2024
09db8cd
Minor cleanup to remove extra comments.
oseikuffuor1 Mar 20, 2024
4a3445d
BML-hypre integration to access sparse matrix multiplication and addi…
oseikuffuor1 Oct 18, 2023
4693a32
Merge branch 'with-hypre' of github.com:oseikuffuor1/bml into with-hypre
oseikuffuor1 Mar 20, 2024
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
Prev Previous commit
Next Next commit
Initial BML-hypre integration to access sparse matrix multiplication …
…in hypre.
  • Loading branch information
oseikuffuor1 committed Mar 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit ce03df3421592e47452113c0bb080aa07e77616c
47 changes: 46 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -229,6 +229,7 @@ set(BML_ROCSPARSE FALSE CACHE BOOL "Whether to compile with rocSPARSE support")
set(BML_CUDA FALSE CACHE BOOL "Whether to compile with CUDA support")
set(BML_CUSOLVER FALSE CACHE BOOL "Whether to compile with cuSolver support")
set(BML_MAGMA FALSE CACHE BOOL "Whether to use MAGMA library")
set(BML_HYPRE FALSE CACHE BOOL "Whether to use HYPRE library")
set(BML_OMP_OFFLOAD OFF CACHE BOOL "Compile with OpenMP GPU Offload support")
set(BML_OFFLOAD_ARCH "NVIDIA" CACHE STRING "Offload architecture")
set_property(CACHE BML_OFFLOAD_ARCH PROPERTY STRINGS "NVIDIA" "AMD")
@@ -306,7 +307,7 @@ if(BML_OMP_OFFLOAD)
endif()
endif()

set(BML_USE_DEVICE (BML_CUDA OR BML_MAGMA OR BML_CUSOLVER OR BML_ROCSOLVER OR BML_CUSPARSE OR BML_ROCSPARSE))
set(BML_USE_DEVICE (BML_CUDA OR BML_MAGMA OR BML_CUSOLVER OR BML_ROCSOLVER OR BML_CUSPARSE OR BML_ROCSPARSE OR BML_HYPRE))
if(BML_USE_DEVICE)
message(STATUS "Will use device libraries for some solvers")
if (CUDAToolkit_FOUND)
@@ -390,6 +391,50 @@ if(BML_MAGMA)
endif()
endif()

if(BML_HYPRE)
message(STATUS "Search for HYPRE...")
find_package(HYPRE REQUIRED)

if (${HYPRE_FOUND})
add_definitions(-DBML_USE_HYPRE)
message(STATUS
"HYPRE was found:\n"
" HYPRE_INCLUDE_DIRS: ${HYPRE_INCLUDE_DIRS}\n"
" HYPRE_LIBRARY_DIRS: ${HYPRE_LIBRARY_DIRS}\n"
" HYPRE_LIBRARIES: ${HYPRE_LIBRARIES}"
)
include_directories(${HYPRE_INCLUDE_DIRS})

list(APPEND LINK_LIBRARIES "-L${HYPRE_LIBRARY_DIRS}")
list(APPEND LINK_LIBRARIES ${HYPRE_LIBRARIES})

if (CUDAToolkit_FOUND)
list(APPEND LINK_LIBRARIES "-L${CUDAToolkit_LIBRARY_DIR}")
list(APPEND LINK_LIBRARIES ${CUDA_cublas_LIBRARY})
list(APPEND LINK_LIBRARIES ${CUDA_cudart_LIBRARY})
include_directories(${CUDAToolkit_INCLUDE_DIR})

# add_definitions(-DBML_USE_CUSPARSE)
list(APPEND LINK_LIBRARIES ${CUDA_cusparse_LIBRARY})
list(APPEND LINK_LIBRARIES ${CUDA_curand_LIBRARY})
endif()
list(APPEND LINK_LIBRARIES -lstdc++)
## The following may not be necessary since BML_USE_DEVICE should take care of it
# if(BML_CUSPARSE)
# add_definitions(-DBML_USE_CUSPARSE)
# list(APPEND LINK_LIBRARIES ${CUDA_cusparse_LIBRARY})
# endif()
# if(BML_ROCSPARSE)
# add_definitions(-DBML_USE_ROCSPARSE)
# list(APPEND LINK_LIBRARIES ${rocsparse_LIBRARIES})
# endif()
## end note
message(STATUS "LINK_LIBRARIES: ${LINK_LIBRARIES}")
else()
message(FATAL_ERROR "HYPRE was not found")
endif()
endif()

set(BML_ELPA FALSE CACHE BOOL "Whether to use ELPA library")
if(BML_ELPA)
message(STATUS "Search for ELPA in directory ${ELPA_DIR}\n")
3 changes: 3 additions & 0 deletions src/C-interface/bml_logger.c
Original file line number Diff line number Diff line change
@@ -192,4 +192,7 @@ bml_print_version(
#ifdef BML_USE_ROCSPARSE
fprintf(stdout, "BML uses AMD rocSparse\n");
#endif
#ifdef BML_USE_HYPRE
fprintf(stdout, "BML uses hypre library\n");
#endif
}
2 changes: 1 addition & 1 deletion src/C-interface/ellpack/bml_allocate_ellpack.h
Original file line number Diff line number Diff line change
@@ -179,7 +179,7 @@ void bml_update_domain_ellpack(
int *localPartMax,
int *nnodesInPart);

#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE)
#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE) || defined(BML_USE_HYPRE)
void bml_ellpack2cucsr_ellpack(
bml_matrix_ellpack_t * A);
void bml_ellpack2cucsr_ellpack_single_real(
12 changes: 6 additions & 6 deletions src/C-interface/ellpack/bml_allocate_ellpack_typed.c
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ void TYPED_FUNC(

#pragma omp target exit data map(delete: A_nnz[:N], A_index[:N*M], A_value[:N*M])

#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE)
#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE) || defined(BML_USE_HYPRE)
int *csrColInd = A->csrColInd;
int *csrRowPtr = A->csrRowPtr;
REAL_T *csrVal = A->csrVal;
@@ -57,7 +57,7 @@ void TYPED_FUNC(
bml_free_memory(A->index);
bml_free_memory(A->nnz);

#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE)
#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE) || defined(BML_USE_HYPRE)
bml_free_memory(A->csrRowPtr);
bml_free_memory(A->csrColInd);
bml_free_memory(A->csrVal);
@@ -171,7 +171,7 @@ bml_matrix_ellpack_t

#pragma omp target enter data map(alloc:A_value[:N*M], A_index[:N*M], A_nnz[:N])
#pragma omp target update to(A_value[:N*M], A_index[:N*M], A_nnz[:N])
#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE)
#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE) || defined(BML_USE_HYPRE)
A->csrColInd = bml_noinit_allocate_memory(sizeof(int) * N * M);
A->csrRowPtr = bml_allocate_memory(sizeof(int) * (N + 1));
A->csrVal = bml_noinit_allocate_memory(sizeof(REAL_T) * N * M);
@@ -221,7 +221,7 @@ bml_matrix_ellpack_t *TYPED_FUNC(
A->index = bml_allocate_memory(sizeof(int) * N * M);
A->nnz = bml_allocate_memory(sizeof(int) * N);
A->value = bml_allocate_memory(sizeof(REAL_T) * N * M);
#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE)
#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE) || defined(BML_USE_HYPRE)
A->csrColInd = bml_allocate_memory(sizeof(int) * N * M);
A->csrRowPtr = bml_allocate_memory(sizeof(int) * (N + 1));
A->csrVal = bml_allocate_memory(sizeof(REAL_T) * N * M);
@@ -235,7 +235,7 @@ bml_matrix_ellpack_t *TYPED_FUNC(
int *A_nnz = A->nnz;
int *A_index = A->index;
int NM = N * M;
#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE)
#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE) || defined(BML_USE_HYPRE)
int *csrColInd = A->csrColInd;
int *csrRowPtr = A->csrRowPtr;
REAL_T *csrVal = A->csrVal;
@@ -258,7 +258,7 @@ bml_matrix_ellpack_t *TYPED_FUNC(
}
}

#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE)
#if defined(BML_USE_CUSPARSE) || defined(BML_USE_ROCSPARSE) || defined(BML_USE_HYPRE)
#pragma omp target enter data map(to:csrVal[:N*M], csrColInd[:N*M], csrRowPtr[:N+1])
#endif
#endif
37 changes: 37 additions & 0 deletions src/C-interface/ellpack/bml_multiply_ellpack.h
Original file line number Diff line number Diff line change
@@ -203,4 +203,41 @@ void bml_multiply_rocsparse_ellpack_double_complex(
double beta1,
double threshold);
#endif
#if defined(BML_USE_HYPRE)
void bml_multiply_hypre_ellpack(
bml_matrix_ellpack_t * A,
bml_matrix_ellpack_t * B,
bml_matrix_ellpack_t * C,
double alpha1,
double beta1,
double threshold);
void bml_multiply_hypre_ellpack_single_real(
bml_matrix_ellpack_t * A,
bml_matrix_ellpack_t * B,
bml_matrix_ellpack_t * C,
double alpha1,
double beta1,
double threshold);
void bml_multiply_hypre_ellpack_double_real(
bml_matrix_ellpack_t * A,
bml_matrix_ellpack_t * B,
bml_matrix_ellpack_t * C,
double alpha1,
double beta1,
double threshold);
void bml_multiply_hypre_ellpack_single_complex(
bml_matrix_ellpack_t * A,
bml_matrix_ellpack_t * B,
bml_matrix_ellpack_t * C,
double alpha1,
double beta1,
double threshold);
void bml_multiply_hypre_ellpack_double_complex(
bml_matrix_ellpack_t * A,
bml_matrix_ellpack_t * B,
bml_matrix_ellpack_t * C,
double alpha1,
double beta1,
double threshold);
#endif
#endif
Loading