-
Notifications
You must be signed in to change notification settings - Fork 94
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
Basic Kokkos Extension #1358
Basic Kokkos Extension #1358
Conversation
#include <ginkgo/config.hpp> | ||
|
||
|
||
#if GINKGO_EXTENSION_KOKKOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you avoid the extensions header are included in the main header, the macro is not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather leave it here, in case the headers are included individually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it indeed can be included individually, doesn't it?
There's nothing rely on ginkgo from kokkos extensions if native_type.hpp is always included in ginkgo.hpp or is included from extensions.
User can link kokkos and ginkgo with including these two files such that they can use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I didn't get your point, but yes the headers could be included individually. That's why I left my first comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of the case
users do not configure ginkgo with Kokkos extension but they use these header in the end.
They definitely need to take care of Kokkos dependence.
This condition seems to be unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. If they don't have kokkos, then the include will fail, which should give enough of an error.
f63fc83
to
05588a0
Compare
Kudos, SonarCloud Quality Gate passed! |
3f2340c
to
ce36c16
Compare
9b495de
to
03b94da
Compare
Since this is a header-only extension, I agree with @yhmtsai that the header can be made unconditional. A consequence of this is that we can include Kokkos in That would significantly trim down the CMake changes we need to do (and also remove the need for a separate EXTENSION flag), limiting it to only examples and tests. |
I don't think it should be unconditional. My reasoning is:
Of course, I also dislike the hack to disable the |
I already noted in #1389 that none of the additional CMake setup is actually necessary, because the only thing we are testing is a single function that is or is not compiled based on whether JSON support was activated. On the compiler launcher, IMO this is mainly a CI/development thing. In CI we can control it ourselves, for development, maybe it does make sense to provide CMake developer presets that set a lot of useful variables ( |
They are somehow different in my mind. The parser of property_tree is not just one function. for example, it can also be used to hide the JSON package requirement from the application, which was mentioned long time ago. In this case, it needs to be compiled, but still out of the main ginkgo. If we still go the direction putting Kokkos in the main header, it's only required to add the condition in main header but not in the header itself. The header (Kokkos) can still be used by user directly. For me, the extension on top of ginkgo should be pluggable. papi in my mind might also be an extension not feature if it does not need to be inside the ginkgo. hwloc is still in ginkgo itself because it changes the memory behavior (in theory). |
@yhmtsai The kokkos stuff is not part of ginkgo_main and will not be. I consider only |
We have a lot of optional things (MPI, PAPI, TAU, roctx, rocfft, hwloc) inside Ginkgo. The parser is just a single function to the user interface (which as I just noticed is also header-only, so it's almost exactly the same scenario as with Kokkos). |
Most systems, alteast the HPC systems, have Kokkos installed. I am not sure always building with Kokkos is a good idea. While the explosion of options and the increase in build system complexity is definitely a concern, but we should also consider that always building with third-party options can unnecessarily increase the library object size. |
If you change the #1389 mentioned it will move the parser to another pr. There are two things for the optional stuff:
In packaging, putting into extensions should be easier, right? If you want to provide pre-compiled library for user to switch these options, you need to provide all ginkgo compiled with these combinations but you can provide ginkgo + extension to produce these combinations easily. |
I'm not sure who is building Kokkos here. We are not. It's only a cmake dependency if the corresponding option is set. But the package must already be installed. |
No, I mean building Ginkgo with the Kokkos dependency always enabled. |
By default it's disabled. Only if the user request it, it will be added. |
Yes, that is what is now. But if I understand correctly, what @upsj is suggesting is that you remove the option to disable it, thereby always building Ginkgo with Kokkos (if Kokkos is available), which IMO is not a good idea. |
@pratikvn I believe you misunderstand how this will be used. It is a header-only interoperability layer that is there (and will be installed) independent of whether Kokkos is available on the system or not. Ginkgo (the library) does not need to know whether Kokkos is there, its compilation does not change if Kokkos is there or not, and we only need to detect it for the test and example, because those get compiled like an application would use the Kokkos interoperability layer. |
@upsj, This Kokkos layer header would still be a part of |
Yes, |
Ok I think I can remove the changes to Effectively yes, it mainly links to I think I will remove But coming back to the alias issue, for me it is quite hard to think about a way to notify the user of our dependency without the alias target. |
agree with the config.hpp was the annoying part. I need to recompile all when I realize I do not install kokkos with complex align |
Let me ask this way - how does a user use Kokkos without configuring it in their own build system? They will need to create some views, run some parallel for loops, so they themselves also need to be aware of the Kokkos build system. In the unlikely case that they try to use the Ginkgo Kokkos extension without having provided the correct include paths, we get either a rather clear error message (´#include <Kokkos/...> not found |
@upsj I agree that is a very clear error message. But it only appears on compile time. By then the user may have spend who knows how long to build and fixing the linking issue may result in them recompiling everything. A configure time error will prevent that very easily. And even if they already use kokkos, they might not link against it in the required places. Maybe they extracted the parts where they use ginkgo + kokkos into its own library, and then forgot to link again with Kokkos. There are a lot of possibilities for users to mess up. We shouldn't assume that they have the perfect cmake setup and instead complain when we know that they are doing something wrong. But I also agree that linking |
91bc280
to
a6ac314
Compare
I've now removed the changes to |
a6ac314
to
744a2eb
Compare
So far I've not come up with a better solution than linking against kokkos. I think in some sense this is ok, since it is a true dependency. The extension headers really depend on kokkos. @upsj how should we proceed. I really would like to have a configure time check, so maybe you have a lightweight option? Otherwise if this is a blocker for you then I would remove the cmake setup. |
Sorry for holding this up - on second thought, I think the bigger issue to me is that |
@upsj I agree there. I've also thought about removing the dependency (which I would also prefer), but so far, I've not found a solution to provide the minimal Kokkos version we need otherwise. |
Just for my understanding: Is there an issue with checking the version beyond compile time vs. configure time? |
No, it's again that issue. If we are not able to have all dependency checks at configure time, we are better off to move everything to compile time, for the benefits you mentioned. |
@upsj I've removed the cmake setup now. There is still the cmake option |
reverted: create_executor* functions return global executors This is necessary because we implicitly assume that a program only has one executor of a specific type (up to changes in construtor parameters). Thus, without this we create different executors each time the create_* functions are called. And as a consequence extra copies are used instead of moves: ``` auto exec1 = create_default_executor(); auto exec2 = create_default_executor(); array<...> a{exec1, ...}; array<...> b{std::move(a)}; // this copies! ``` Alternative: move the responsibility to downstream projects.
- formatting - enable uncommented test - add static_assert to warn on mismatching alignment - check ginkgo build config matches kokkos - increase types test - remove unnecessary if-def guard - use memory space type for mapping instead of variable - set cxx standard to 17 for kokkos extension - documentation - move implementation out of class - add install doc Co-authored-by: Pratik Nayak <pratik.nayak@kit.edu> Co-authored-by: Yu-Hsiang M. Tsai <yhmtsai@gmail.com>
|
This PR adds a mapping to Kokkos types and functions to choose the Ginkgo executor based on the Kokkos execution space.
It also introduces the
Ginkgo::ext
andGinkgo::ext::kokkos
targets to make it easy for applications to opt into this functionality.Currently, the mapping only supports
array
matrix::Dense
anddevice_matrix_data
. Other mappings are possible, but not necessary at the moment.Old PR Description
Note: This description is not reflective of the changes anymore. They are left here, because I want to move them into their on PR at some point.
Instead of providing the kokkos type mapping directly, an extra layer of mapping classes is introduced. This extra layer provides mapping for 'complex' Ginkgo types (i.e. not
gko::array
orgko::matrix::Dense
). These mappings can then be concretized for different frameworks such as Kokkos, or maybe Raja in the future, by specifying howgko::array
andgko::matrix::Dense
are mapped in these frameworks.Currently, we only offer mapping types in the direction
framework -> Ginkgo
(through our array views), and this can make the other direction possible.The mapping could also be used in Ginkgo internally for the common kernels, but that would require some changes to the kernel calls.
Todo:
Note:
This exposes some internal implementation detail. A key factor for this PR is to define (in the future) for nearly all of our types a basic struct that describes the memory layout in terms of 1D and 2D arrays. This would make interface conforming changes to the internal storage format more difficult. On the other hand, it would also allow us to define low-level representation of our classes, that could be passed into kernels.