Skip to content

Use proper include path for cholmod.h. - #364

Merged
cgmb merged 2 commits into
ROCm:developfrom
stellaraccident:fix_cholmod_include_path
Mar 6, 2025
Merged

cgmb merged 2 commits into
ROCm:developfrom
stellaraccident:fix_cholmod_include_path

Conversation

@stellaraccident

Copy link
Copy Markdown
Contributor

It appears that the SuiteSparse::CHOLMOD CMake library advertises its include directory as $PREFIX/include/suitesparse, making the proper way to include it #include <cholmod.h>. When installed in the system /usr prefix, the suitesparse/cholmod.h path works by accident. When using a custom built suitesparse at a custom location, this is not so.

I believe that this change is the correct way to do it for all configurations, based on how the SuiteSparse library is set up.

@stellaraccident
stellaraccident changed the base branch from develop to mainline February 12, 2025 01:51
@jmachado-amd

Copy link
Copy Markdown
Collaborator

Hi @stellaraccident, thanks! I'll have a look at your PR tomorrow, in the meantime, please target the fix at the develop branch.

stellaraccident added a commit to ROCm/TheRock that referenced this pull request Feb 12, 2025
* Adds host-math group and includes OpenBLAS and SuiteSparse in it to
provide libcholmod (so that we have the option to avoid system deps for
these).
* Includes upstream patch ROCm/hipSOLVER#364
* Includes upstream patch ROCm/rocminfo#97

Includes workarounds for #82, #83

---------

Co-authored-by: Stella Laurenzo <stellaraccident@gmail.com>

@jmachado-amd jmachado-amd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @stellaraccident, it looks like my week was far busier than anticipated -- apologies for the delay. I see two other changes that are required in order to allow hipSOLVER to find its Suitesparse dependencies in a general setting:

find_path(CHOLMOD_INCLUDE_DIR suitesparse/cholmod.h)

should be updated into:

find_path(CHOLMOD_INCLUDE_DIR
    NAMES cholmod.h
    PATH_SUFFIXES suitesparse
    )

find_path(SUITESPARSE_CONFIG_INCLUDE_DIR suitesparse/SuiteSparse_config.h)

should be updated into:

find_path(SUITESPARSE_CONFIG_INCLUDE_DIR
    NAMES SuiteSparse_config.h
    PATH_SUFFIXES suitesparse
    )

Thanks again for taking the time to make the PR, and please let me know if this works for you.

@cgmb cgmb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If this is wrong, then mea culpa. I'd hoped that Spack would catch this sort of error, but I guess they had a patch for an earlier problem which ended up sidestepping this issue. :(

The bit that confuses me is that the SuiteSparse::CHOLMOD target is actually quite a new thing in the upstream SuiteSparse project. It didn't exist in older versions, so it's weird that there's an expectation that the user will add an include path to their build flags just to use the OS-provided SuiteSparse headers.

@stellaraccident

Copy link
Copy Markdown
Contributor Author

Yeah, it's kind of a head scratcher if trying to unwind how this got this way and ever worked right. The details on this are context switched out of my head, but I have an easy repro to try changes with a local built SuiteSparse.

@jmachado-amd

Copy link
Copy Markdown
Collaborator

@stellaraccident, I've opened a pr with the changes I suggested last week. They work in my own tests, but please let me know if you can try them in your reproducer.

@jmachado-amd

Copy link
Copy Markdown
Collaborator

Hello @renjithravindrankannath, we would be very grateful if you could test this PR in spack. Many thanks in advance!

@renjithravindrankannath renjithravindrankannath left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified the change in Spack mainline. Looks good to me.

@jmachado-amd jmachado-amd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is all that I need approve the PR, at this point I would just move to rebase and merge and start a cherry-pick into 6.4.

@cgmb, do you have anything to add?

@cgmb cgmb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I still think the suitesparse behaviour is a bit weird, but I see that with the find module update provided by Julio, this change builds properly with libsuitesparse-dev 1:5.10.1+dfsg-4build1 from Ubuntu 22.04 (which did not include CHOLMODConfig.cmake). Thanks @stellaraccident and @jmachado-amd.

The User Guide for CHOLMOD also includes a sample program that shows the direct inclusion of cholmod.h.

stellaraccident and others added 2 commits March 5, 2025 13:08
It appears that the `SuiteSparse::CHOLMOD` CMake library advertises its include directory as `$PREFIX/include/suitesparse`, making the proper way to include it `#include <cholmod.h>`. When installed in the system `/usr` prefix, the `suitesparse/cholmod.h` path works by accident. When using a custom built suitesparse at a custom location, this is not so.

I believe that this change is the correct way to do it for all configurations, based on how the SuiteSparse library is set up.
hipSOLVER's find module scripts (for suitesparse) were using `find_path`
on name `suitesparse/cholmod.h` instead of `cholmod.h`, which allowed
hipSOLVER to `#include <suitesparse/cholmod.h>`.

This commit updates the aforementioned cmake scripts, to honour the way
`Suitesparse::CHOLMOD` advertises its include directories.
@cgmb
cgmb force-pushed the fix_cholmod_include_path branch from c27e02c to ffb8ccd Compare March 5, 2025 20:08
@cgmb
cgmb enabled auto-merge (squash) March 5, 2025 20:11
@cgmb
cgmb merged commit c35541f into ROCm:develop Mar 6, 2025
ammallya pushed a commit that referenced this pull request Oct 28, 2025
* Use proper include path for cholmod.h.

It appears that the `SuiteSparse::CHOLMOD` CMake library advertises its include directory as `$PREFIX/include/suitesparse`, making the proper way to include it `#include <cholmod.h>`. When installed in the system `/usr` prefix, the `suitesparse/cholmod.h` path works by accident. When using a custom built suitesparse at a custom location, this is not so.

I believe that this change is the correct way to do it for all configurations, based on how the SuiteSparse library is set up.

* Update suitesparse's find module scripts

hipSOLVER's find module scripts (for suitesparse) were using `find_path`
on name `suitesparse/cholmod.h` instead of `cholmod.h`, which allowed
hipSOLVER to `#include <suitesparse/cholmod.h>`.

This commit updates the aforementioned cmake scripts, to honour the way
`Suitesparse::CHOLMOD` advertises its include directories.

---------

Co-authored-by: Julio Machado Silva <161654951+jmachado-amd@users.noreply.github.com>

[ROCm/hipSOLVER commit: c35541f]
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.

5 participants