-
Notifications
You must be signed in to change notification settings - Fork 578
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
CMake: Trying to understand linking to static TPLs (esp. MKL) #8926
Comments
TBird2001, Are you using Intel as the compiler? If so, I believe the best option to dealing with MKL is: I believe these sets of flags were added in Intel compiler suite 2018 (or maybe 17)
From
If you aren't using intel... I've never used CMake's 'find' with MKL. I use Intel Link adviser Then put whatever they say into That's just my experience on various platforms around SNL. |
I have never used the "MKL" TPL. I did not add that TriBiTS TPL file and I am not sure how it is related to the BLAS and LAPACK TriBITS TPLs. Looking at the git log for that file it was added by @mhoemmen. Reading the commit log for that file, it seems like it was designed to pull in all of MKL, not just BLAS and LAPACK.
You can find that by doing:
Given what these packages do sparse linear algebra, my guess is that they use the sparse linear algebra routines in MKL. So don't bother with the "MKL" TPL, unless you need to enable those packages with sparse MKL support. Stick with the BLAS and LAPACK TPLs. For those, you need to specify the MKL libraries manually (don't know of a better way). Note that you can use Intel MKL for BLAS and LAPACK with any compatible compiler, including GCC and Clang. You can look at the ATDM Trilinos configurations and see how they use MKL. It looks like they are linking Trilinos against shared MKL libraries, even for static builds of Trilinos. For the Intel builds on 'cts1', they are just using:
Simple as pie. That leaves it up to the Intel compiler to decide if to link against shared or static MKL libs. Otherwise, I don't know of any recent examples of linking against static MKL libraries. @jjellio likely has the best advice above. If that does not resolve your issue, then we can dig deeper into this and figure this out (and if MKL truly supports static libraries). NOTE: I removed the Related to my epic SEPW-213 |
I just wanted to make a quick comment that your comments have been very helpful. We're still understanding the best approach for this, so I will leave this issue open a little longer in case we have follow-up questions. (I'll also remove TriBITS from the title to keep things clear.) |
@TBird2001 - It's worth adding - That's a round-about answer, but if you are wanting MKL for things beyond lapack/blas - that stuff is used in some packages. From a pure linking point of view, I'd use the |
@jjellio, that's actually very helpful in helping my understanding. Thanks! |
FYI, I don't actually work on Trilinos or work for Sandia any more, but I'll be happy to comment : - ) . I added the "MKL TPL" specifically for MKL's C interface to sparse linear algebra operations. It's separate from the BLAS, though I imagine you would just use the MKL for the BLAS library if you had it. |
It seems like enabling the MKL TPL should automatically enable the BLAS and LAPACK TPLs (and everything that can use those) but that type of relationship between TPLs is not something that TriBITS supports. Making that work would take some effort and add more complexity to TriBITS. |
Ross, I believe if you enabled MKL and set BLAS to something else, you would have a mess on your hands. Packages that enable MKL (muelu) would then get MKL added as TPL library, but they also use BLAS, so that would get added too. Which one gives you BLAS or LAPACK would depend on the order of the link line. And then for packages that don't depend on MKL (say Teuchos Numerics), their exe's may compile w/only the BLAS/LAPACK libs on the link line. There could also be shenanigans if one lib mangled one way and the other differently (atleast that would cause an error - otherwise, this would be a silent error where the user doesn't realize blas/lapack isn't coming from the source they expect!) tldr: sounds like a headache. (added this post mostly so if it gets searched in the future maybe it will be helpful) @mhoemmen - You are a ghost a in the shell. A digital haunt.... dare we call you a virus? Has your process gone Zombie? I've seen how this plays out in the Matrix. Give this spirit write access to the repo and let god's judgment befall us. |
@jjellio, yes, those are the problems. But it seems harmless to put the same MKL libraries on the link line multiple times, once for BLAS, once for LAPACK, and once for MKL. But who actually uses the TriBITS MKL with Trilinos? It not enabled in any of the Trilinos PR builds or the ATDM Trilinos builds which means the there is likely no automated testing set up to support it. (Only 15 of the 116 total TPLs are enabled in any one of the Trilinos PR builds.) That means it likely does not work with Trilinos (i.e. what is not tested on a regular basis is likely broken). |
@jjellio ; - P |
Ross - MueLu (and maybe Tacho) can use it. I think in the context of MueLu it's in their example/drivers where they can compare X implementation to Y. (i.e., compare MKL to Kokkos or stuff like that). The codes were pretty crufty. I generally see That said, I think most foos in It seems Tribits/CMake could gain some robustness if they provided a something like This would also make it clearer to a user - google |
@jjellio, thins are more complicated that this in the general case. I will see if I have time to dialog with Kitware on the TPL inter-dependency issues this FY as part of the TriBITS Refactoring work. For more discussion of this, see TriBITSPub/TriBITS#340 (comment) and comments above that. |
This issue has had no activity for 365 days and is marked for closure. It will be closed after an additional 30 days of inactivity. |
This issue was closed due to inactivity for 395 days. |
Question
@bartlettroscoe/CMake/TriBITS
I have a set of questions related to the Intel MKL. The first is (hopefully) simple. In the CMake TPLs, there is an explicit FindTPLMKL.cmake file. I've always specified the MKL libraries only to the BLAS and LAPACK searches. Maybe that is wrong? What does the MKL-specific library search enable in Trilinos?
Second, I have been trying to understand the flags associated with building static executables as described in the Build Reference (particularly as it applies to the MKL). To review, there are three flags:
The first flag is to build static versions of the Trilinos libraries (and I think OFF is the default, anyway). The second, "tells CMake to locate static library versions of any required TPLs." This seems to reject shared libraries completely. The third, "tells the auto-detection routines… to locate static versions."
I was thinking that one could specify
-D Trilinos_LINK_SEARCH_START_STATIC=ON
, alone, and then the CMake would preferentially search for the static libraries, rather than the default, where it looks first for shared libraries. This does not seem to be the case, at least for the MKL. I had to specify all three flags to make the CMake find the static MKL libraries.Related to that, if all of the TPLs are required to be static, I've encountered problems, because not all of the required libraries are available in a static form (e.g., pthreads, which is a system library). This is why the all-or-nothing approach is difficult, and I was hoping for the preferential approach.
The text was updated successfully, but these errors were encountered: