Skip to content

Commit

Permalink
kokkos#7: (v1): old way for rocsparse and rocblas
Browse files Browse the repository at this point in the history
  • Loading branch information
meriadeg perrinel authored and meriadegp committed Mar 30, 2023
1 parent 11d442b commit 8efb035
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 2 deletions.
59 changes: 58 additions & 1 deletion cmake/Modules/FindTPLROCBLAS.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
MESSAGE( "Enter in FindTPLROCBLAS.cmake")

## MPL: v3
## MPL: 12/29/2022: CMake regular way to find a package
#FIND_PACKAGE(ROCBLAS)
#if(TARGET roc::rocsparse)
### MPL: 12/29/2022: Variable TPL_ROCBLAS_IMPORTED_NAME follows the requested convention
### of KokkosKernel (method kokkoskernels_import_tpl of kokkoskernels_tpls.cmake)
#SET(TPL_ROCBLAS_IMPORTED_NAME roc::rocblas)
#SET(TPL_IMPORTED_NAME roc::rocblas)
### MPL: 12/29/2022: A target comming from a TPL must follows the requested convention
### of KokkosKernel (method kokkoskernels_link_tpl of kokkoskernels_tpls.cmake)
#ADD_LIBRARY(KokkosKernels::ROCBLAS ALIAS roc::rocblas)
#ELSE()
# MESSAGE(FATAL_ERROR "Package ROCBLAS requested but not found")
#ENDIF()

## MPL: v2
## MPL: 12/26/2022: This bloc is not necessary anymore since ROCBLAS installation provide a cmake config file.
## Should we verify for different version of ROCBLAS ?
## GOAL: The code is commented for now and we aim to remove it
#IF (ROCBLAS_LIBRARY_DIRS AND ROCBLAS_LIBRARIES)
# KOKKOSKERNELS_FIND_IMPORTED(ROCBLAS INTERFACE LIBRARIES ${ROCBLAS_LIBRARIES} LIBRARY_PATHS ${ROCBLAS_LIBRARY_DIRS})
#ELSEIF (ROCBLAS_LIBRARIES)
# KOKKOSKERNELS_FIND_IMPORTED(ROCBLAS INTERFACE LIBRARIES ${ROCBLAS_LIBRARIES})
#ELSEIF (ROCBLAS_LIBRARY_DIRS)
#ELSE()
# # MPL: 12/26/2022: USE FIND_PACKAGE and check if the requested target is the more modern way to do it
# # MPL: 12/28/2022 : This logical bloc is based on the logical bloc coming from FindTPLCUBLAS. But instead of
# # expecting a ROCBLAS_FOUND variable to be set. We expect the TARGET roc::rocblas to be defined (more modern)
# FIND_PACKAGE(ROCBLAS)
# if(NOT TARGET roc::rocblas)
# MESSAGE( "TARGET roc::rocblas NOT FOUND")
# #Important note here: this find Module is named TPLROCBLAS
# #The eventual target is named roc::rocblas. To avoid naming conflicts
# #the find module is called TPLROCBLAS. This call will cause
# #the find_package call to fail in a "standard" CMake way
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(TPLROCBLAS REQUIRED_VARS ROCBLAS_FOUND)
# ELSE()
# # MPL: 12/26/2022: USING FIND_PACKAGE_HANDLE_STANDARD_ARGS can be ok in modern CMAKE but with a Find module
# # if the package is found, we can verify that some variables are defined using FIND_PACKAGE_HANDLE_STANDARD_ARGS
# MESSAGE( "TARGET roc::rocblas FOUND")
# #The libraries might be empty - OR they might explicitly be not found
# IF("${ROCBLAS_LIBRARIES}" MATCHES "NOTFOUND")
# MESSAGE( "ROCBLAS_LIBRARIES is not found")

# FIND_PACKAGE_HANDLE_STANDARD_ARGS(TPLROCBLAS REQUIRED_VARS ROCBLAS_LIBRARIES)
# ELSE()
# MESSAGE( "ROCBLAS_LIBRARIES is not found")
# # 12/28/2022: ROCBLAS_LIBRARIES is found using find_packge which defines it as a target and not a lib
# message("TPLROCBLAS LIBRARIES VARIABLE IS ${ROCBLAS_LIBRARIES}")
# KOKKOSKERNELS_CREATE_IMPORTED_TPL(ROCBLAS INTERFACE LINK_LIBRARIES ${ROCBLAS_LIBRARIES})
# ENDIF()
# endif()
#ENDIF()

## MPL: v1
IF (ROCBLAS_LIBRARY_DIRS AND ROCBLAS_LIBRARIES)
KOKKOSKERNELS_FIND_IMPORTED(ROCBLAS INTERFACE LIBRARIES ${ROCBLAS_LIBRARIES} LIBRARY_PATHS ${ROCBLAS_LIBRARY_DIRS})
ELSEIF (ROCBLAS_LIBRARIES)
Expand Down Expand Up @@ -34,4 +91,4 @@ ELSE()
# FIND_PACKAGE(ROCBLAS REQUIRED)
# KOKKOSKERNELS_CREATE_IMPORTED_TPL(ROCBLAS INTERFACE LINK_LIBRARIES ${ROCBLAS_LIBRARIES})
# GET_TARGET_PROPERTY(ROCBLAS_LINK_LIBRARIES ${ROCBLAS_LIBRARIES} IMPORTED_LINK_INTERFACE_LIBRARIES)
ENDIF()
ENDIF()
46 changes: 45 additions & 1 deletion cmake/Modules/FindTPLROCSPARSE.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
# MPL: 05/01/2023: This file follows the partern of FindTPLROCBLAS.cmake

# MPL: v3
#FIND_PACKAGE(ROCSPARSE)
#if(TARGET roc::rocsparse)
# SET(TPL_ROCSPARSE_IMPORTED_NAME roc::rocsparse)
# SET(TPL_IMPORTED_NAME roc::rocsparse)
# ADD_LIBRARY(KokkosKernels::ROCSPARSE ALIAS roc::rocsparse)
#ELSE()
# MESSAGE(FATAL_ERROR "Package ROCSPARSE requested but not found")
#ENDIF()

## MPL: v2
#IF (ROCSPARSE_LIBRARY_DIRS AND ROCSPARSE_LIBRARIES)
# KOKKOSKERNELS_FIND_IMPORTED(ROCSPARSE INTERFACE LIBRARIES ${ROCSPARSE_LIBRARIES} LIBRARY_PATHS ${ROCSPARSE_LIBRARY_DIRS})
#ELSEIF (ROCSPARSE_LIBRARIES)
# KOKKOSKERNELS_FIND_IMPORTED(ROCSPARSE INTERFACE LIBRARIES ${ROCSPARSE_LIBRARIES})
#ELSEIF (ROCSPARSE_LIBRARY_DIRS)
#ELSE()
# FIND_PACKAGE(ROCSPARSE)
# if(NOT TARGET roc::rocsparse)
# MESSAGE( "TARGET roc::ROCSPARSE NOT FOUND")
# #Important note here: this find Module is named TPLROCSPARSE
# #The eventual target is named roc::ROCSPARSE. To avoid naming conflicts
# #the find module is called TPLROCSPARSE. This call will cause
# #the find_package call to fail in a "standard" CMake way
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(TPLROCSPARSE REQUIRED_VARS ROCSPARSE_FOUND)
# ELSE()
# # if the package is found, we can verify that some variables are defined using FIND_PACKAGE_HANDLE_STANDARD_ARGS
# MESSAGE( "TARGET roc::ROCSPARSE FOUND")
# #The libraries might be empty - OR they might explicitly be not found
# IF("${ROCSPARSE_LIBRARIES}" MATCHES "NOTFOUND")
# MESSAGE( "ROCSPARSE_LIBRARIES is not found")

# FIND_PACKAGE_HANDLE_STANDARD_ARGS(TPLROCSPARSE REQUIRED_VARS ROCSPARSE_LIBRARIES)
# ELSE()
# MESSAGE( "ROCSPARSE_LIBRARIES is not found")
# message("TPLROCSPARSE LIBRARIES VARIABLE IS ${ROCSPARSE_LIBRARIES}")
# KOKKOSKERNELS_CREATE_IMPORTED_TPL(ROCSPARSE INTERFACE LINK_LIBRARIES ${ROCSPARSE_LIBRARIES})
# ENDIF()
# endif()
#ENDIF()

# MPL: v1
IF (ROCSPARSE_LIBRARY_DIRS AND ROCSPARSE_LIBRARIES)
KOKKOSKERNELS_FIND_IMPORTED(ROCSPARSE INTERFACE LIBRARIES ${ROCSPARSE_LIBRARIES} LIBRARY_PATHS ${ROCSPARSE_LIBRARY_DIRS})
ELSEIF (ROCSPARSE_LIBRARIES)
Expand Down Expand Up @@ -34,4 +78,4 @@ ELSE()
# FIND_PACKAGE(ROCSPARSE REQUIRED)
# KOKKOSKERNELS_CREATE_IMPORTED_TPL(ROCSPARSE INTERFACE LINK_LIBRARIES ${ROCSPARSE_LIBRARIES})
# GET_TARGET_PROPERTY(ROCSPARSE_LINK_LIBRARIES ${ROCSPARSE_LIBRARIES} IMPORTED_LINK_INTERFACE_LIBRARIES)
ENDIF()
ENDIF()

0 comments on commit 8efb035

Please sign in to comment.