Skip to content

Commit

Permalink
kokkos#7: V2 Added hybrid version for rocblas and rocsparse
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 8efb035 commit 5c8d760
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 134 deletions.
142 changes: 70 additions & 72 deletions cmake/Modules/FindTPLROCBLAS.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
MESSAGE( "Enter in FindTPLROCBLAS.cmake")

## MPL: v3
## MPL: 12/29/2022: CMake regular way to find a package
#FIND_PACKAGE(ROCBLAS)
Expand All @@ -15,80 +13,80 @@ MESSAGE( "Enter in FindTPLROCBLAS.cmake")
# 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
# 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)
KOKKOSKERNELS_FIND_IMPORTED(ROCBLAS INTERFACE LIBRARIES rocblas LIBRARY_PATHS ${ROCBLAS_LIBRARY_DIRS})
ELSEIF (KokkosKernels_ROCBLAS_ROOT)
KOKKOSKERNELS_FIND_IMPORTED(ROCBLAS INTERFACE
LIBRARIES
rocblas
LIBRARY_PATHS
${KokkosKernels_ROCBLAS_ROOT}/lib
HEADERS
rocblas.h
HEADER_PATHS
${KokkosKernels_ROCBLAS_ROOT}/include
)
ELSEIF (DEFINED ENV{ROCM_PATH})
MESSAGE(STATUS "Detected ROCM_PATH: ENV{ROCM_PATH}")
SET(ROCBLAS_ROOT "$ENV{ROCM_PATH}/rocblas")
KOKKOSKERNELS_FIND_IMPORTED(ROCBLAS INTERFACE
LIBRARIES
rocblas
LIBRARY_PATHS
${ROCBLAS_ROOT}/lib
HEADERS
rocblas.h
HEADER_PATHS
${ROCBLAS_ROOT}/include
)
ELSE()
MESSAGE(ERROR "rocBLAS was not detected properly, please disable it or provide sufficient information at configure time.")
# Todo: figure out how to use the target defined during rocblas installation
# 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)
# 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)
# KOKKOSKERNELS_FIND_IMPORTED(ROCBLAS INTERFACE LIBRARIES ${ROCBLAS_LIBRARIES})
#ELSEIF (ROCBLAS_LIBRARY_DIRS)
# KOKKOSKERNELS_FIND_IMPORTED(ROCBLAS INTERFACE LIBRARIES rocblas LIBRARY_PATHS ${ROCBLAS_LIBRARY_DIRS})
#ELSEIF (KokkosKernels_ROCBLAS_ROOT)
# KOKKOSKERNELS_FIND_IMPORTED(ROCBLAS INTERFACE
# LIBRARIES
# rocblas
# LIBRARY_PATHS
# ${KokkosKernels_ROCBLAS_ROOT}/lib
# HEADERS
# rocblas.h
# HEADER_PATHS
# ${KokkosKernels_ROCBLAS_ROOT}/include
# )
#ELSEIF (DEFINED ENV{ROCM_PATH})
# MESSAGE(STATUS "Detected ROCM_PATH: ENV{ROCM_PATH}")
# SET(ROCBLAS_ROOT "$ENV{ROCM_PATH}/rocblas")
# KOKKOSKERNELS_FIND_IMPORTED(ROCBLAS INTERFACE
# LIBRARIES
# rocblas
# LIBRARY_PATHS
# ${ROCBLAS_ROOT}/lib
# HEADERS
# rocblas.h
# HEADER_PATHS
# ${ROCBLAS_ROOT}/include
# )
#ELSE()
# MESSAGE(ERROR "rocBLAS was not detected properly, please disable it or provide sufficient information at configure time.")
# # Todo: figure out how to use the target defined during rocblas installation
# # 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()
124 changes: 62 additions & 62 deletions cmake/Modules/FindTPLROCSPARSE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,72 @@
# 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
# 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)
KOKKOSKERNELS_FIND_IMPORTED(ROCSPARSE INTERFACE LIBRARIES rocsparse LIBRARY_PATHS ${ROCSPARSE_LIBRARY_DIRS})
ELSEIF (KokkosKernels_ROCSPARSE_ROOT)
KOKKOSKERNELS_FIND_IMPORTED(ROCSPARSE INTERFACE
LIBRARIES
rocsparse
LIBRARY_PATHS
${KokkosKernels_ROCSPARSE_ROOT}/lib
HEADERS
rocsparse.h
HEADER_PATHS
${KokkosKernels_ROCSPARSE_ROOT}/include
)
ELSEIF (DEFINED ENV{ROCM_PATH})
MESSAGE(STATUS "Detected ROCM_PATH: ENV{ROCM_PATH}")
SET(ROCSPARSE_ROOT "$ENV{ROCM_PATH}/rocsparse")
KOKKOSKERNELS_FIND_IMPORTED(ROCSPARSE INTERFACE
LIBRARIES
rocsparse
LIBRARY_PATHS
${ROCSPARSE_ROOT}/lib
HEADERS
rocsparse.h
HEADER_PATHS
${ROCSPARSE_ROOT}/include
)
ELSE()
MESSAGE(ERROR "rocSPARSE was not detected properly, please disable it or provide sufficient information at configure time.")
# Todo: figure out how to use the target defined during rocsparse installation
# 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)
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)
# KOKKOSKERNELS_FIND_IMPORTED(ROCSPARSE INTERFACE LIBRARIES ${ROCSPARSE_LIBRARIES})
#ELSEIF (ROCSPARSE_LIBRARY_DIRS)
# KOKKOSKERNELS_FIND_IMPORTED(ROCSPARSE INTERFACE LIBRARIES rocsparse LIBRARY_PATHS ${ROCSPARSE_LIBRARY_DIRS})
#ELSEIF (KokkosKernels_ROCSPARSE_ROOT)
# KOKKOSKERNELS_FIND_IMPORTED(ROCSPARSE INTERFACE
# LIBRARIES
# rocsparse
# LIBRARY_PATHS
# ${KokkosKernels_ROCSPARSE_ROOT}/lib
# HEADERS
# rocsparse.h
# HEADER_PATHS
# ${KokkosKernels_ROCSPARSE_ROOT}/include
# )
#ELSEIF (DEFINED ENV{ROCM_PATH})
# MESSAGE(STATUS "Detected ROCM_PATH: ENV{ROCM_PATH}")
# SET(ROCSPARSE_ROOT "$ENV{ROCM_PATH}/rocsparse")
# KOKKOSKERNELS_FIND_IMPORTED(ROCSPARSE INTERFACE
# LIBRARIES
# rocsparse
# LIBRARY_PATHS
# ${ROCSPARSE_ROOT}/lib
# HEADERS
# rocsparse.h
# HEADER_PATHS
# ${ROCSPARSE_ROOT}/include
# )
#ELSE()
# MESSAGE(ERROR "rocSPARSE was not detected properly, please disable it or provide sufficient information at configure time.")
# # Todo: figure out how to use the target defined during rocsparse installation
# # 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()

0 comments on commit 5c8d760

Please sign in to comment.