Skip to content

[LAPACK] Dynamically load reference lapack library for tests. #701

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

adegomme
Copy link
Contributor

Description

Lapack tests suffered same issue as BLAS tests which was reported in #204 and fixed in #251 . If a backend uses the same LAPACKE interface and symbols as the reference LAPACK, it will end up comparing only the first found library to itself.

This basically copies #251 solution by using dlopen each time the reference library symbols are needed instead of linking to the library directly.

In the process of testing this, I noticed that Lapack tests were not exactly working if only the lapack backend is built, as it depends on the BLAS library as well for accuracy checks. A second commit was added to make Lapack tests work alone, by checking that BLAS reference library can be found even if BLAS backend is not built. It also adds REF_LAPACK_ROOT in the search path for BLAS library, as in the reference design all blas/lapack libraries are in the same location (this avoids having to provide both REF_LAPACK_ROOT and REF_BLAS_ROOT in this case).

  • Do all unit tests pass locally? Attach a log.
    100% tests passed, 0 tests failed out of 796

@adegomme adegomme requested review from a team as code owners July 17, 2025 15:26
Copy link
Contributor

@andrewtbarker andrewtbarker left a comment

Choose a reason for hiding this comment

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

This all looks good. Thanks for the changes!

Copy link
Contributor

@dnhsieh-intel dnhsieh-intel left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! I only have some minor comments.

One more thing is that the original inconsistency (reference_blas_templates.hpp in BLAS and lapack_reference_wrappers.hpp in LAPACK) now leads to:

  • reference_blas_templates.hpp includes reference_blas_wrappers.hpp in BLAS
  • lapack_reference_wrappers.hpp includes lapack_reference_templates.hpp in LAPACK

I will leave this for @andrewtbarker to decide if we need alignment.

list(REMOVE_ITEM TEST_TARGET_DOMAINS "blas")
if ("lapack" IN_LIST TEST_TARGET_DOMAINS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please check if it can work without this condition?

@@ -30,6 +30,11 @@ set(EXAMPLE_TARGET example_lapack_getrs_usm_mklcpu_cusolver)
# Create a CMake target with one source file
add_executable(${EXAMPLE_TARGET} getrs_usm_mklcpu_cusolver.cpp)

# May be needed to compile source files with SYCL kernels
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
if(USE_ADD_SYCL_TO_TARGET_INTEGRATION)

# External applications should use find_package or FetchContent to include oneMath first.
# See https://github.com/uxlfoundation/oneMath/blob/develop/docs/using_onemath_with_cmake.rst

# Create a CMake target with one source file
add_executable(${EXAMPLE_TARGET} getrs_usm.cpp)

# May be needed to compile source files with SYCL kernels
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
if(USE_ADD_SYCL_TO_TARGET_INTEGRATION)

@@ -86,7 +86,11 @@ if(BUILD_SHARED_LIBS)
PUBLIC ${CMAKE_BINARY_DIR}/bin
$<$<BOOL:${LAPACKE_FOUND}>:${LAPACKE_INCLUDE}>
)
target_link_libraries(lapack_source_rt PUBLIC ONEMATH::SYCL::SYCL)
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
if(USE_ADD_SYCL_TO_TARGET_INTEGRATION)

Comment on lines +106 to +107
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET lapack_source_ct SOURCES ${LAPACK_SOURCES})
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
if (USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET lapack_source_ct SOURCES ${LAPACK_SOURCES})
if(USE_ADD_SYCL_TO_TARGET_INTEGRATION)
add_sycl_to_target(TARGET lapack_source_ct SOURCES ${LAPACK_SOURCES})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants