-
Notifications
You must be signed in to change notification settings - Fork 268
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
Improved CMake variables / behavior #599
Comments
Thank you for the feedback. Re 1: Good point. IIUC, those variable names are remnants from the transition from the Makefile based build system to the CMake build system. Re 2: Good point. (See Re 1.) Re 3: PETSc packagers said SuiteSparse behaved different to their other dependencies before this change. I'm open to reverting that change. But maybe that should be coordinated. See: https://gitlab.com/petsc/petsc/-/merge_requests/7104#note_1693474274 Re 4: That could probably be done after the negative flag Re 5: The minimum CMake version depends on the set of subprojects that you'd like to build. It could probably be raised in the root CMake file. But iiuc, that would mean that some (older) versions of CMake could no longer be used to build subprojects for which they would be "new enough". |
I opened #600 that could be used to transition away from I'm a bit hesitant to go with your suggestions 4 or 5 for the reasons described above. |
Re your suggestion 3, the PETSc packagers will set that CMake flag in their project. I opened #601 that would revert the change that sets the RPATH for installed libraries. (The INSIDE_SUITESPARSE code path should not be triggered when packaging SuiteSparse.) |
Thanks @mmuetzel, this all looks great :) Regarding 4) I would say it's good practice. For example if someone upgrades or changes their compiler toolchain but forgets to install the relevant openmp package, it's more convenient to get a configure error than working binaries for something they didn't ask for. Similarly when you have some automated way of building the package in a fixed configuration (say SUITESPARSE_WITH_CUDA=ON) on different machines, it's more convenient to get a configure error when e.g. cuda is missing than working binaries without cuda support. |
Which idiom would you suggest to check whether a variable was set by a user or whether its default value is used? |
Hm, you can't really with ON/OFF. LLVM uses a tri-state ON / OFF / FORCE_ON, but dunno if that's very common: if(LLVM_ENABLE_TERMINFO STREQUAL FORCE_ON)
set(MAYBE_REQUIRED REQUIRED)
else()
set(MAYBE_REQUIRED)
endif()
if(LLVM_ENABLE_TERMINFO)
find_library(COMPILER_RT_TERMINFO_LIB NAMES terminfo tinfo curses ncurses ncursesw ${MAYBE_REQUIRED})
endif()
Don't know what if that can be made dynamic, you really have to specify |
I meant different minimum version requirements for CUDA or OpenMP. |
The double negative derives from things like the For CUDA, I really need to have the options of (a) do not use CUDA even if the GPU is available, and (b) use CUDA if available but build the packages without it if not. I'm OK with adding a third option: (c) use CUDA and fail if not available. Option (b) needs to be the default for CHOLMOD and SPQR, and eventually GraphBLAS when the CUDA kernels are ready for production use (they are not yet ready and cannot be used at all in production). The same is true for OpenMP: the packages should use OpenMP by default, if available, but they can still be built without it. Other user-facing variables have been in place a long time, like Regarding things like For the I require cmake 3.16 for the GraphBLAS JIT, which is need by the end user of GraphBLAS to compile their JIT kernels, even if they get a GraphBLAS.h and libgraphblas.so already built and installed in a linux distro / spack / brew / Windows / etc. That should stay the same. So this is why things like this are needed:
I'd like to keep that one, but I can remove the older ones since I see those have been in CMake a long time now. |
See 3ed3bd7 for the removal of |
Are you sure? This drives the point home ;)
How about a tri-state Regarding if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0" )
cmake_policy ( SET CMP0104 NEW ) # initialize CUDA architectures
endif ( ) you could use |
Oh ... right. Ack. I'm a bit dyslexic. I will simplify the cmake_minimum_required statements. Most can change to 3.22 since they depend on SuiteSparse_config, which requires 3.22. GraphBLAS, LAGraph, and CSparse can be built as stand-alone packages, so I will leave their cmake_minimum_required the same. See: |
OK ... I've decided to ditch NCAMD, etc, and go with CHOLMOD_CAMD, etc, instead. This will also prefix these user-facing variables to "(package)_WHATEVER" instead of just "WHATEVER". |
Thanks, that should also make name clashes less likely (although already unlikely given those names...) and CMakeCache.txt files orderly when suitesparse itself is used as a sub-project elsewhere. |
|
CMake options are Boolean by default. They can't really be tri-state unless we'd use cache variables. But that could cause issues with packagers (e.g., setting a flag to |
You'll be happy to learn that strings like "OFF" and "0" etc are falsy: cmake_minimum_required(VERSION 3.20)
project(example)
set(EXAMPLE "AUTO" CACHE STRING "EXAMPLE: can be AUTO, ON, OFF")
if (EXAMPLE STREQUAL "AUTO")
message("Autodetection")
set(EXAMPLE ON)
endif ()
if (EXAMPLE)
message("Enabled")
else ()
message("Disabled")
endif ()
|
What does |
I don't think it's something to care too much about, given that people will use ON/OFF 99.9% of the time. If the value is not a special string it's simply truthy. |
So |
You can use Also don't think too much of |
Actually you can even |
Good to know. But maybe we could postpone that to until after SuiteSparse 7.4.0 is released. (I hope we are approaching a point where everything is "stable enough" for a release soon.) |
I'd like to postpone this too. I'd like to release a stable SuiteSparse 7.4.0 soon, and consider adding |
I think these issues (except I'll leave this issue open for the |
From the packaging point of view, ensuring there is an error when a flag can't work would be greatly appreciated. There is a good case that highlights this problem in the Julia binary packaging: We wanted to build just the GPU targets into a separate library, but it turns out CUDA wasn't being configured by our environment correctly, and so CMake couldn't find nvcc to build any CUDA code. CMake's CUDA detection reported the error, but the builder instead continued and just gave us the CPU library again instead of the GPU library like we really wanted. This was kind of just caught by accident when reviewing the logs due to an unrelated packaging failure. So including the option to error if a requested option is unavailable would have caught that before we even merged the new version because it would have failed the build process with an obvious error. |
Yeah, that's the kind of thing I had in mind when opening this issue. Even if you don't wanna make this auto / on / off tri-state, you could still make |
It's not that trivial. I tried to point out earlier that different sub-projects of SuiteSparse have different version requirements for OpenMP. E.g., ParU requires OpenMP 4.5 or newer. CHOLMOD is fine with OpenMP 2.0. The "AUTO" approach would probably work for that. But implementing it will probably take a bit (and might cause regressions in the process). |
This is rather complicated. To simplify the logic in the cmake scripts, and as part of the renaming of variables to prefix them with
I never change those values, regardless of whether or not CUDA and/or OpenMP are available. I have another set of values that I set internally that hold the result of whether or not OpenMP and CUDA are used in a particular package, such as:
If OpenMP is requested ( So I treat the This simplifies the logic, and it might also be simpler to revise the logical for the tri-state case. The |
Actually, in replying in the above just now, I went looking and found that I wasn't as consistent as I meant to be. So I fixed it; see: For example, None of the |
The CUDA setting is also complicated when considering a possible tri-state behavior. CHOLMOD has a setting called So if I'm really unsure about how to handle these variations. |
Oh ... here's a simple solution. It keeps all my logic the same, and does not introduce any tristate I just add a single new ON/OFF setting:
By default, this is If I'm adding this now and will include it in SuiteSparse 7.4.0.beta8. For example: SuiteSparse/GraphBLAS/CMakeLists.txt Lines 98 to 115 in 9439bda
|
See #621 |
I think all these issues are now fixed in my latest 7.4.0.beta8 version: https://github.com/DrTimothyAldenDavis/SuiteSparse/releases/tag/v7.4.0.beta8 . Can you let me know if this is resolved? |
Fixed in SuiteSparse 7.4.0. |
Hi, I'm trying out the new CMake build system after struggling to keep up with all breaking changes in the Makefile-based build system.
Few comments.
Could you please drop double negatives, it's only confusing. Do not not use openmp?
Please prefix user facing variables: for example
SUITESPARSE_WITH_OPENMP
,SUITESPARSE_WITH_CUDA
, etc.I don't understand why there's so much special handling of rpaths in suite sparse? What problem is being solved that is not already solved by CMake? (e.g.
CMAKE_INSTALL_RPATH_USE_LINK_PATH=ON
) Is there anything unique about suitesparse that requires this? If not, could you please remove special handling and leave it to packagers?Please use
find_package(... REQUIRED)
instead of silently turning a feature off.Same for CUDA: if enabled by the user, require it, instead of
SuiteSparse/LAGraph/cmake_modules/SuiteSparsePolicy.cmake
Lines 301 to 304 in a02c53b
Please be clear about the minimum CMake version. The top-level CMakeLists.txt requires 3.20 but says higher may be required. What's the minimum then? I don't want to go over each and every subproject. Just set the top-level min to
max(min(subproject) for subproject in subprojects)
Further, there are a lot of outdated and redundant cmake policy things, can they be removed? They're all NEW by default.
SuiteSparse/SuiteSparse_config/cmake_modules/SuiteSparsePolicy.cmake
Lines 98 to 103 in a02c53b
Would be great if this is addressed before the official release, so that there won't be a series of breaking changes to the CMake build system too. I'm packaging suitesparse for spack where we wanna be able to install older versions as well as newer versions, and we're probably skipping the 5 < version < 7.4 versions because of breaking changes. But see also here, people are hesitant to package things if the build system changes every release: JuliaPackaging/Yggdrasil#7803 (comment).
The text was updated successfully, but these errors were encountered: