Skip to content

Add optional for LAPACK/vendor library bindings for dense linear algebra #1814

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

Draft
wants to merge 15 commits into
base: develop
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ option(
)
option(BUILD_SHARED_LIBS "Build shared (.so, .dylib, .dll) libraries" ON)
option(GINKGO_BUILD_HWLOC "Build Ginkgo with HWLOC. Default is OFF." OFF)
option(GINKGO_BUILD_LAPACK "Build Ginkgo with LAPACK. Default is OFF." OFF)
option(
GINKGO_BUILD_PAPI_SDE
"Build Ginkgo with PAPI SDE. Enabled if a system installation is found."
Expand Down Expand Up @@ -359,6 +360,14 @@ if(GINKGO_BUILD_HWLOC AND (MSVC OR WIN32 OR CYGWIN OR APPLE))
)
endif()

set(GINKGO_HAVE_LAPACK 0)
if(GINKGO_BUILD_LAPACK)
# Need CMake 3.18+ to use LAPACK::LAPACK target
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
find_package(LAPACK REQUIRED)
set(GINKGO_HAVE_LAPACK 1)
endif()

set(GINKGO_HAVE_GPU_AWARE_MPI OFF)
set(GINKGO_HAVE_OPENMPI_PRE_4_1_X OFF)
if(GINKGO_BUILD_MPI)
Expand Down
2 changes: 1 addition & 1 deletion cmake/get_info.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ foreach(log_type ${log_types})
)
ginkgo_print_module_footer(${${log_type}} " Enabled features:")
ginkgo_print_foreach_variable(${${log_type}}
"GINKGO_MIXED_PRECISION;GINKGO_HAVE_GPU_AWARE_MPI;GINKGO_ENABLE_HALF"
"GINKGO_MIXED_PRECISION;GINKGO_HAVE_GPU_AWARE_MPI;GINKGO_ENABLE_HALF;GINKGO_HAVE_LAPACK"
)
ginkgo_print_module_footer(${${log_type}} " Tests, benchmarks and examples:")
ginkgo_print_foreach_variable(${${log_type}}
Expand Down
3 changes: 3 additions & 0 deletions cmake/hip.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ find_package(hipsparse REQUIRED)
find_package(rocrand REQUIRED)
find_package(rocthrust REQUIRED)
find_package(ROCTX)
if(GINKGO_BUILD_LAPACK)
find_package(hipsolver REQUIRED)
endif()

if(GINKGO_HIP_AMD_UNSAFE_ATOMIC AND GINKGO_HIP_VERSION VERSION_GREATER_EQUAL 5)
set(CMAKE_HIP_FLAGS
Expand Down
1 change: 1 addition & 0 deletions common/cuda_hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(CUDA_HIP_SOURCES
distributed/partition_helpers_kernels.cpp
distributed/partition_kernels.cpp
distributed/vector_kernels.cpp
eigensolver/lobpcg_kernels.cpp
factorization/cholesky_kernels.cpp
factorization/factorization_kernels.cpp
factorization/elimination_forest_kernels.cpp
Expand Down
22 changes: 22 additions & 0 deletions common/cuda_hip/base/dev_lapack_bindings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: 2025 The Ginkgo authors
//
// SPDX-License-Identifier: BSD-3-Clause

#ifndef GKO_COMMON_CUDA_HIP_BASE_DEV_LAPACK_BINDINGS_HPP_
#define GKO_COMMON_CUDA_HIP_BASE_DEV_LAPACK_BINDINGS_HPP_


#if defined(GKO_COMPILING_CUDA)
#include "cuda/base/cusolver_bindings.hpp"
#define GKO_DEV_LAPACK_ERROR GKO_CUSOLVER_ERROR
#define DEV_LAPACK_INTERNAL_ERROR CUSOLVER_STATUS_INTERNAL_ERROR
#elif defined(GKO_COMPILING_HIP)
#include "hip/base/hipsolver_bindings.hip.hpp"
Copy link
Member

Choose a reason for hiding this comment

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

This PR seems to handle cuda only, will you also add the hipsolver here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the plan was to add hipSOLVER bindings here once the interface is finalized.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added hipSOLVER in 5e6dc8e.

#define GKO_DEV_LAPACK_ERROR GKO_HIPSOLVER_ERROR
#define DEV_LAPACK_INTERNAL_ERROR HIPSOLVER_STATUS_INTERNAL_ERROR
#else
#error "Executor definition missing"
#endif


#endif // GKO_COMMON_CUDA_HIP_BASE_DEV_LAPACK_BINDINGS_HPP_
Loading
Loading