-
Notifications
You must be signed in to change notification settings - Fork 564
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
GTest as a TPL #8001
Comments
@jhux2, I did not have anything to do with adding GTest as a Trilinos package. Given that STK is having version problems with GTest in Trilinos, a GTest TPL would also be problematic, right? Therefore, I think each package should just snapshot the version of GTest that they want into their source tree if the version of GTest provided by the Trilinos GTest package becomes a problem. That is what @etphipp did with Sacado. That is my two cents so I will not unsubscribe. |
Thanks @jhux2, I want to tag Timothy @tasmith4 as he is the one specifically looking into gtest. |
As to why gtest is a package and not a TPL, my guess is so that Trilinos packages can use it without requiring a TPL dependency, which ensures the tests will actually be run. That was my motivation for using it in Sacado (previously Sacado used CppUnit, which almost no one has, so those tests were rarely run). I spent a lot of time trying to update the gtest package in Trilinos because I wanted to use functionality that was not in the Trilinos version. Ultimately that failed because I could never solve the cmake installation issues, so I ended up putting my own snapshot in Sacado (which does not get installed). The issues are described in issue #7698. |
I should also mention that if someone wants to pick this up and can solve the installation issues, I would be happy to remove the snapshot in Sacado. |
@bartlettroscoe @etphipp Thanks for the information. #7698 might be helpful for @tasmith4 as he decides on a path forward. |
I just spent about an hour unsuccessfully trying to build a code that actually uses GTest properly as a TPL from the actual repository here on GitHub where Google provides it, and also tries to use Trilinos. This practice of copy-pasting packages that are not part of the Trilinos project into Trilinos and installing them as if we are the sole providers of that package must stop. GTest, CppUnit, and all others must be turned into TPLs. If your users "don't have them", they are as easy to get from GitHub as Trilinos is. |
@jwillenbring @ccober6 Should this be added to the Trilinos planning board? |
I added it to the agenda for the next Trilinos Product Leads Meeting to discuss, and from there make the needed Jira issues. |
Just for the record, I did not have anything to do with adding gtest as a Trilinos package and most certainly did not have anything to do with installing it. (I think that was added while I was at ORNL.) This situation with the Gtest package was a major pain with Trilinos integration with SPARC and EMPIRE. (In fact, it was the last unresolved issue that stopped SPARC and EMPIRE from being able to use the exact same binary installs of Trilinos because SPARC needed the install of Gtest and EMPIRE broke if it was installed.) Now, if gtest was just built and used internally to test things in Trilinos, then that is fine. (But in that case, each package should just use their own version of gtest like Sacado and Kokkos do.) But given that it is being used by an installed Trilinos library, this is a huge mess. Why force every Trilinos package to use the exact same version of GTest? Yes that saves in source space and binary space but given the experience that @etphipp had in #7698, is that really worth it? |
@bartlettroscoe brings up a good point. @ibaned have you or anyone else tested linking the installed Trilinos with the GTest TPL in #9514 against a code that uses it (e.g., Albany I think). This was the major stumbling block in #7698 and is why I ended up putting my own gtest library in Sacado instead of updating the GTest package in Trilinos. It required a custom CMake targets file for that library, which I didn't know how to create. Generally I support the idea of removing the GTest package in Trilinos and replacing it with a TPL, however it does seem to me to be an awful lot of work to install the module everywhere Trilinos is tested. I also question why some Trilinos packages are allowed to keep their local gtest copy and others aren't. To me it seems like a simpler solution to understand why an installed Trilinos library is depending on gtest, and whether that is really required. |
And you likely need to add SPARC to that list as well. (I would be curious to know how many other APPs used easy access to Gtest through Trilinos in this way. This could turn into a real mess.)
That is a great question. But if there is a Trilinos library that gets installed that depends on GTest, then I think that GTest has to be a TPL so that the customer can choose the GTest version (which is the whole problem here). |
Downstream applications can find GTest using the same (proper modern CMake) That was actually the whole use case for this pull request, since I'm in charge of an application that uses Trilinos but also uses other things besides Trilinos and all of them get GTest from an installed location like well-behaved C++ projects. This works because instead of trying to launder GTest's CMake packages through TriBITS, I used them directly as intended. Again, I built every relevant package in Trilinos with the latest GTest version and there were no issues, so this fear of issues with sharing one version is also completely unfounded. |
@ibaned, but what about APPs like SPARC and Albany (and perhaps others) that may be using the older GTest version through the Trilinos Below is just a suggestion; feel free to ignore. (I don't have a horse in this race.) A short-term (and even medium-term) solution that will allow those existing APPs to keep working and not break all of the other existing use cases is to set up STK to allow the usage of either this new
and the other STK
I think the rest of the Trilinos Then customers that want to use STK with the new |
@bartlettroscoe that seems like it would work for me and for backward compatibility as well. I'm fine going in the |
@ibaned, it is basically the same solution you already have in PR #9514 except you keep the |
We had a discussion on the STK team about the best path forward and we think it's best for STK to shift from using GTest as a package to using it as a TPL. @ibaned can you do another, smaller PR that allows GTest as a TPL through TriBITS (or fixes the name or whatever is required?) Then we will do something like what @bartlettroscoe shows to enable use of GTest as a TPL and deprecate usage of GTest as a package, eventually deleting the STK dependence on the GTest package. |
And installing gtest along with Trilinos and having customers use it from Trilinos is causing problems with the move to modern CMake (and note that yaml-cpp is doing the same thing as per jbeder/yaml-cpp#539). See TriBITSPub/TriBITS#443 (comment) for details. No package should be installing gtest as part its install. This just sets you for problems. |
This is coming back to haunt even SPARC now as it tries to pull in its own version of gtest. But in the case of EMPIRE, if they would have put the include path for their GTest in front of the include path for Trilinos, they it would have been selected over the one installed in Trilinos. This what SPARC is going to have to do. I think that is the lesion for packages like GTest that everyone seems to want to install as part of their package; put the It turns out that modern CMake with imported targets prior to CMake 3.23 (which is not even released yet) did not provide enough fine-grained control to do this properly but after CMake 3.23 and with a little property hacking, a CMake project should have full nearly control over the include directories it uses, even from IMPORTED targets. (But those tweaks are not well known.) |
FYI: Looks like SPARC is very close to sucking in its own GTest. I helped them fix some include dirs issues that required a small patch to gtest to build it internally which was:
And to make sure that their gtest headers are selected (i.e. by moving their include dirs forward on the compile line and list them with And with that, a customer CMake project can suck in GTest with |
FYI: I verified that the internal build of googletest (gtest) with SPARC does not appear to have broken any of their nighty builds. See internal issue tribitsrefactoring#3. This should be an example for all packages that may have similar problems and need to be building with their own gtest and need to make sure that their gtest headers are selected (i.e. by moving their include dirs forward on the compile line by calling |
Just got the below email from @e10harvey. I will respond in the next comment. Hi Ross, Both Kokkos and KokkosKernels currently have a snapshot of GTEST under version control in their repositories. After running it by Kokkos and KokkosKernels, I would like to do the following:
What are your thoughts on this approach? Is this approach “better” than continuing to snapshot GTEST? Would this conflict with how Trilinos uses GTEST? |
@e10harvey, I think that individual packages should be able to do what they want with test-only dependencies like GTest (googletest). If they want to rely on an external installation (that is found through find_package()) then that is fine. If they want to snapshot GTest to only be used by their test suite, that is fine too. As long as only the tests for Kokkos and KokkosKernels need GTest, then I don't know why anyone should care. Other opinions? |
There is some discussion in #9514, as well. |
I've brought this up before as well. I think the Kokkos team was not receptive to this at the time, but I support asking them again. I agree with Ross that if it is truly a test-only dependency then having a copy-pasted version doesn't hurt downstream packages (although it is still bad software design). However, there is a GTest version in Trilinos that isn't always test-only (an STK package can cause it to be installed). This does hurt our downstream packages and needs to be fixed. |
Thinking more about this, we can't have a top-level TriBITS TPL for GTest and still allow individual packages to snapshot and use their own version of GTest. The problem is that, with the new TriBITS, if you define a top-level TriBITS TPL called GTest that calls Therefore, I think we need to eliminate the TriBITS GTest TPL and eliminate the Trilinos GTest package and just make individual Trilinos packages either snapshot and build their own version of GTest (like Sacado does) or they should call And yes, we can't have any regular package libraries for any Trilinos package depend on GTest. That is a big no no. (So STK would need to be refactored to remove such a dependency or one needs to be very careful how STK libraries that depend on GTest are handled as not to clash with downstream packages. Such STK libraries could be marked as Thoughts? |
I like the idea of having individual packages handle their own dependencies in one way. I think Kokkos has to maintain some extra cmake right now to build in Trilinos. How would this decision affect how TriBITS handles other TPLs such as BLAS and CUDA? Would TPL symbols across packages conflict at Trilinos link time? |
We would be fine with cleaning up STK's dependence on Gtest. It looks like most of STK's gtest dependencies use 'TEST_REQUIRED_DEP_PACKAGES Gtest'. Is that ok? Just one says 'LIB_REQURED_...'. In any case we're fine with doing whatever refactoring/restructuring is needed for this change to work. |
I'm strongly in favor of the approach outlined by Ross to remove the TriBITS GTest TPL and package and allow per-package solutions. The STK package that causes problems is |
@tasmith4 what do you think of Dan's last comment? I think it sounds fine for Sierra but not so sure about exawind. (Sierra doesn't build stk with cmake so it's a non-issue.) Exawind depends on stk_unit_test_utils, so that needs to be an exported target. If we can accomplish that, then this approach sounds fine. |
@alanw0 off the top of my head, I think if we and nalu-wind both use And yeah, Sierra builds are handled through the bake/jamfile system so the gtest dependency is captured in a completely different way and won't affect this discussion. |
@alanw0 we've definitely made sure that SEMS has a GTest package and if installs are needed anywhere else to support Trilinos testing I'm happy to request it through SEMS and ASC DevOps. |
@alanw0, I can help with dealing with these test libraries. |
@e10harvey, no, for external packages/TPLs that are used by the libraries of a TriBITS package (and therefore propagate downstream), they need to be handled as TriBITS TPLs to ensure there is just one definition across all packages that may have that same TPL dependency. GTest and other external dependencies that only impact the tests and examples for a package are a different situation. They don't propagate anywhere (unless a downstream package specifically uses a test-only library from an upstream package but that is specific type of dependency for which the downstream package takes on with its eyes wide open). |
@alanw0, it may require a TriBITS extension but I think that we could support this as a One issue is that I think having a external CMake package dependency not handled as a TriBITS TPL would require adding some custom code to the generated
I think in this case, we would need to have an acceptable version of GTest installed on the system before configuring Trilinos for those Trilinos packages that are using |
FYI: After the merge of TriBITSPub/TriBITS#560 and the sync to Trilinos, it should be pretty easy to build Trilinos with internal GTest package or external GTest TPL (and we should be able to call the TPL and the internal package the same name "GTest"). |
@bartlettroscoe this sounds great, I was just about to circle back to this for STK. Can you keep me in the loop on that sync to Trilinos? |
|
@ccober6 I would like to bring your attention on this as well for the Trilinos User-Developer Group Meeting 😉 |
Yeah, this one has been sitting on the back burner for a while, and has not had a lot of discussion recently. I will add it to the list. :) |
#11184 may be related. |
This topic did not make it to the top of the list at the TUG 2023 meeting yesterday. Perhaps this could be discussed at a future Trilinos Developers meeting? With the updated TriBITS, I think it would be fairly easy to set up Trilinos to be able to build GTest internally (by default), or build against an externally installed GTest. Since GTest is not a quite a TriBITS-Compliant external package when installed, we will need to create a Any interested customers should contact me by my SNL email and we can discuss how to get this done. |
Question
@trilinos/framework @bartlettroscoe
The version of gtest in Trilinos is old, and projects such as Exawind would benefit from having a newer version.
Why is gtest part of Trilinos instead of being a TPL?
Which packages rely on gtest?
As an FYI, I believe @alanw0 is looking at upgrading gtest.
The text was updated successfully, but these errors were encountered: