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

cmake: Add MAGMA TPL support #982

Merged
merged 2 commits into from
May 21, 2021
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
33 changes: 33 additions & 0 deletions cmake/Modules/FindTPLMAGMA.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
IF (MAGMA_LIBRARY_DIRS AND MAGMA_LIBRARIES)
KOKKOSKERNELS_FIND_IMPORTED(MAGMA INTERFACE LIBRARIES ${MAGMA_LIBRARIES} LIBRARY_PATHS ${MAGMA_LIBRARY_DIRS})
ELSEIF (MAGMA_LIBRARIES)
KOKKOSKERNELS_FIND_IMPORTED(MAGMA INTERFACE LIBRARIES ${MAGMA_LIBRARIES})
ELSEIF (MAGMA_LIBRARY_DIRS)
KOKKOSKERNELS_FIND_IMPORTED(MAGMA INTERFACE LIBRARIES amath ${MAGMA_LIB} LIBRARY_PATHS ${MAGMA_LIBRARY_DIRS})
ELSEIF (KokkosKernels_MAGMA_ROOT)
SET(MAGMA_ROOT ${KokkosKernels_MAGMA_ROOT})
KOKKOSKERNELS_FIND_IMPORTED(MAGMA INTERFACE
LIBRARIES
magma
magma_sparse
LIBRARY_PATHS
${MAGMA_ROOT}/lib
HEADERS
magmablas.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@e10harvey I remember I used "magma_v2.h" before. Did they change it in the latest MAGMA version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. magma_v2.h still exists. magmablas.h here is just used by CMake for detecting paths.

HEADER_PATHS
${MAGMA_ROOT}/include
)
ELSE()
FIND_PACKAGE(MAGMA REQUIRED)
KOKKOSKERNELS_CREATE_IMPORTED_TPL(MAGMA INTERFACE LINK_LIBRARIES ${MAGMA_LIBRARIES})
ENDIF()

TRY_COMPILE(KOKKOSKERNELS_TRY_COMPILE_MAGMA
${KOKKOSKERNELS_TOP_BUILD_DIR}/tpl_tests
${KOKKOSKERNELS_TOP_SOURCE_DIR}/cmake/compile_tests/magma.cpp
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${MAGMA_ROOT}/include
LINK_LIBRARIES -L${MAGMA_ROOT}/lib -lmagma -lmagma_sparse
OUTPUT_VARIABLE KOKKOSKERNELS_TRY_COMPILE_MAGMA_OUT)
IF(NOT KOKKOSKERNELS_TRY_COMPILE_MAGMA)
MESSAGE(FATAL_ERROR "KOKKOSKERNELS_TRY_COMPILE_MAGMA_OUT=${KOKKOSKERNELS_TRY_COMPILE_MAGMA_OUT}")
ENDIF()
8 changes: 8 additions & 0 deletions cmake/compile_tests/magma.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <magma_v2.h>
#include <magmablas.h>
#include <magmasparse.h>
#include <magma_batched.h>

int main(void) {
return 0;
}
4 changes: 1 addition & 3 deletions cmake/kokkoskernels_tpls.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,6 @@ IF (KOKKOSKERNELS_ENABLE_TPL_MAGMA)
ELSE ()
MESSAGE(FATAL_ERROR "F77_BLAS_MANGLE ${F77_BLAS_MANGLE} detected while MAGMA only accepts Fortran mangling that is one of single underscore (-DADD_), uppercase (-DUPCASE), and no change (-DNOCHANGE)")
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR "KokkosKernels does not currently support MAGMA in standalone mode")
ENDIF()
LIST(APPEND TPL_LIST "MAGMA")
ENDIF()
Expand All @@ -483,11 +481,11 @@ IF (NOT KOKKOSKERNELS_HAS_TRILINOS)
KOKKOSKERNELS_IMPORT_TPL(SUPERLU)
KOKKOSKERNELS_IMPORT_TPL(METIS)
KOKKOSKERNELS_IMPORT_TPL(ARMPL)
KOKKOSKERNELS_IMPORT_TPL(MAGMA)
ENDIF()

#Convert list to newlines (which CMake doesn't always like in cache variables)
STRING(REPLACE ";" "\n" KOKKOSKERNELS_TPL_EXPORT_TEMP "${KOKKOSKERNELS_TPL_EXPORTS}")
#Convert to a regular variable
UNSET(KOKKOSKERNELS_TPL_EXPORTS CACHE)
SET(KOKKOSKERNELS_TPL_EXPORTS ${KOKKOSKERNELS_TPL_EXPORT_TEMP})

1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,5 @@ KOKKOSKERNELS_LINK_TPL(kokkoskernels PUBLIC CUBLAS)
KOKKOSKERNELS_LINK_TPL(kokkoskernels PUBLIC CUSPARSE)
KOKKOSKERNELS_LINK_TPL(kokkoskernels PUBLIC METIS)
KOKKOSKERNELS_LINK_TPL(kokkoskernels PUBLIC ARMPL)
KOKKOSKERNELS_LINK_TPL(kokkoskernels PUBLIC MAGMA)
# Not yet here KOKKOSKERNELS_LINK_TPL(kokkoskernels PUBLIC MAGMA)