Skip to content

Commit

Permalink
Initial support for SuperLU TPL: Issue kokkos#545
Browse files Browse the repository at this point in the history
  • Loading branch information
jjwilke committed Dec 18, 2019
1 parent 93a6787 commit 95ceb0a
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TRIBITS_PACKAGE_DEFINE_DEPENDENCIES(
LIB_REQUIRED_PACKAGES KokkosCore KokkosContainers KokkosAlgorithms
LIB_OPTIONAL_TPLS quadmath MKL BLAS LAPACK CUSPARSE MAGMA
LIB_OPTIONAL_TPLS quadmath MKL BLAS LAPACK CUSPARSE MAGMA SuperLU
TEST_OPTIONAL_TPLS yaml-cpp
)
2 changes: 2 additions & 0 deletions cmake/KokkosKernels_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
#cmakedefine KOKKOSKERNELS_ENABLE_TPL_CUBLAS
/* MAGMA */
#cmakedefine KOKKOSKERNELS_ENABLE_TPL_MAGMA
/* SUPERLU */
#cmakedefine KOKKOSKERNELS_ENABLE_TPL_SUPERLU

/* if MKL, BLAS is also defined */
#if defined(KOKKOSKERNELS_ENABLE_TPL_MKL)
Expand Down
36 changes: 36 additions & 0 deletions cmake/Modules/FindTPLSUPERLU.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#This assume SuperLU >= 5.0. We don't worry about older versions.
KOKKOSKERNELS_FIND_IMPORTED(SUPERLU LIBRARY superlu HEADER supermatrix.h)
SET(SUPERLU_LIBS KokkosKernels::SUPERLU)
IF (TARGET KokkosKernels::BLAS) #This is an interface library
#I don't like doing this since it breaks the abstraction of
#a target is just a thing we link to. CMake doesn't allow
#us to pass in interface targets to try_compile
GET_TARGET_PROPERTY(SUPERLU_BLAS_LIBS KokkosKernels::BLAS INTERFACE_LINK_LIBRARIES)
LIST(APPEND SUPERLU_LIBS ${SUPERLU_BLAS_LIBS})
ENDIF()
IF (TARGET KokkosKernels::LAPACK)
#I don't like doing this since it breaks the abstraction of
#a target is just a thing we link to try_compile
GET_TARGET_PROPERTY(SUPERLU_LAPACK_LIBS KokkosKernels::LAPACK INTERFACE_LINK_LIBRARIES)
LIST(APPEND SUPERLU_LIBS ${SUPERLU_LAPACK_LIBS})
ENDIF()

TRY_COMPILE(SUPERLU_COMPILE_SUCCEEDS)
${KOKKOSKERNELS_TOP_BUILD_DIR}/tpl_tests
${KOKKOSKERNELS_TOP_SOURCE_DIR}/cmake/compile_tests/superlu_test.cpp
LINK_LIBRARIES ${SUPERLU_LIBS}
)

IF (NOT SUPERLU_COMPILE_SUCCEEDS)
MESSAGE(WARNING "SuperLU failed to correctly compile test."
" The most likely failure is missing or incorrect BLAS libraries"
" Please ensure that KokkosKernels is built with same BLAS as SuperLU")
IF (TARGET KokkosKernels::BLAS)
MESSAGE(WARNING "KokkosKernels is using BLAS: ${SUPERLU_BLAS_LIBS}")
ENDIF()
IF (TARGET KokkosKernels::LAPACK)
MESSAGE(WARNING "KokkosKernels is using LAPACK: ${SUPERLU_LAPACK_LIBS}")
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TPLSUPERLU DEFAULT_MSG SUPERLU_CORRECT)
ENDIF()
17 changes: 17 additions & 0 deletions cmake/Modules/superlu_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <slu_ddefs.h>

int main()
{
GlobalLU_t lu;
superlu_options_t opt;
SuperMatrix M;
int *i;
double *d;
void *v;
char *c;
SuperLUStat_t stat;
mem_usage_t mem;

dgsisx(&opt,&M,i,i,i,c,d,d,&M,&M,v,*i,&M,&M,d,d,&lu,&mem,&stat,i);
return 0;
}
18 changes: 18 additions & 0 deletions cmake/compile_tests/superlu_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <slu_ddefs.h>

int main()
{
GlobalLU_t lu;
superlu_options_t opt;
SuperMatrix M;
int *i;
double *d;
void *v;
char *c;
SuperLUStat_t stat;
mem_usage_t mem;

dgsisx(&opt,&M,i,i,i,c,d,d,&M,&M,v,*i,&M,&M,d,d,&lu,&mem,&stat,i);
return 0;
}

3 changes: 3 additions & 0 deletions cmake/kokkoskernels_tpls.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ ENDIF()
KOKKOSKERNELS_ADD_TPL_OPTION(CUBLAS ${CUBLAS_DEFAULT} "Whether to enable CUBLAS")
KOKKOSKERNELS_ADD_TPL_OPTION(CUSPARSE ${CUSPARSE_DEFAULT} "Whether to enable CUSPARSE")

KOKKOSKERNELS_ADD_TPL_OPTION(SUPERLU OFF "Whether to enable SuperLU")

IF (KOKKOSKERNELS_ENABLE_TPL_MAGMA)
IF (KOKKOSKERNELS_HAS_TRILINOS)
IF (F77_BLAS_MANGLE STREQUAL "(name,NAME) name ## _")
Expand All @@ -427,6 +429,7 @@ IF (NOT KOKKOSKERNELS_HAS_TRILINOS)
KOKKOSKERNELS_IMPORT_TPL(MKL INTERFACE)
KOKKOSKERNELS_IMPORT_TPL(CUBLAS INTERFACE)
KOKKOSKERNELS_IMPORT_TPL(CUSPARSE)
KOKKOSKERNELS_IMPORT_TPL(SUPERLU)
ENDIF()

#Convert list to newlines (which CMake doesn't always like in cache variables)
Expand Down

0 comments on commit 95ceb0a

Please sign in to comment.