Skip to content
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

SoA Proxy, main branch (2024.09.25.) #296

Merged
merged 5 commits into from
Sep 30, 2024

Conversation

krasznaa
Copy link
Member

With the final straw being acts-project/traccc#712, this is an attempt at providing "proxies" for the SoA containers that would allow an "AoS-like" access to the containers in the client code.

The code requires the user to create the same type of interface struct/class for their container, as they did so far. But now that interface is no longer only used providing a user-friendly API for the containers, but also to provide the same API for the proxy objects. Allowing user code to interchangeably use

  • container.variable().at(i) or;
  • container.at(i).variable()

semantics to access the same variable.

We discussed about this already with @stephenswat, and I'm absolutely not convinced that I did the correct thing here, but I made the proxies behave in the following way:

  • "constant proxies" keep their variables by value for the scalar and vector variable types;
  • "non-const proxies" keep their variables by reference.

My idea being that this way we could force the loading of all variables of a given container in a single place in device code, when we are only reading from those variables. But as @stephenswat pointed out, I might very well be doing something silly with this. And should maybe just use references in the proxies everywhere. 🤔

The device code, and a lot of additional testing code is still to come, but I wanted to showcase already how I want to implement this feature.

@krasznaa krasznaa added enhancement New feature or request tests This issue or pull request is related to the test suite labels Sep 25, 2024
Did not try to make a fully functional vecmem::tuple_cat
function, as that was not technically needed so far.
Proxies can be used to provide an "AoS view" over an
SoA container. A view that would make use of the same
interface that the container itself also uses.

Code for device container support was also added, but
is probably not functional at the moment.
While also ensuring that vecmem::edm::proxy would be usable in
device code, and also with C++14.
As feared, this premature/misguided optimization was not helping
with code performance in real life.
@krasznaa krasznaa marked this pull request as ready for review September 26, 2024 15:33
@krasznaa
Copy link
Member Author

I now tried this code with acts-project/traccc#712. @stephenswat was correct. It's more performant to just use references everywhere in the proxies, and leave it up to the GPU to figure out what it would pull into registers.

As noted on acts-project/traccc#712, it turns out that memory copies with vecmem::edm are not quite as amazing as I was hoping for. 😦 Specifically, vecmem::edm::host to vecmem::edm::buffer H->H copies (in order to collect all columns into a single allocation for the H->D copy) are not nearly as quick as I thought. 😕

I intend to study that more deeply in some new benchmarks that I'll add in a separate PR. 🤔

@krasznaa
Copy link
Member Author

After having slept on it a few times already, I'm still pretty happy with this code. So let's go forward with it. 😉

@krasznaa krasznaa merged commit b247389 into acts-project:main Sep 30, 2024
30 checks passed
@krasznaa krasznaa deleted the SoAProxy-main-20240925 branch September 30, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tests This issue or pull request is related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant