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

[FR] Allow SoA for UDFs #1237

Open
SteveBronder opened this issue Aug 8, 2022 · 1 comment
Open

[FR] Allow SoA for UDFs #1237

SteveBronder opened this issue Aug 8, 2022 · 1 comment
Labels
feature New feature or request optimization

Comments

@SteveBronder
Copy link
Contributor

Is your feature request related to a problem? Please describe.

It would be nice to extend the Struct of Arrays (SoA) framework to support UDFs so that they can be used in reduce_sum and other higher order functions.

Right now if a user calls a higher order function we have to demote every matrix / vector passed to that function to Array of Structs (AoS). This is unfortunate since reduce_sum is very powerful for large independent blocks of data and parameters.

Describe the solution you'd like

I think we can do this by the following

  1. During the SoA optimization pass, when the optimization hits a UDF or a higher order function it starts a sub-call of the SoA optimization for the UDF. It will just return the list of inputs that cannot be SoA and then continue the rest of the larger optimization pass.
  2. At the end of the SoA optimization pass the program runs another pass over the program collecting which matrices are SoA. Then when it comes to a UDF in the program it looks at that call of the UDFs argument memory type (Either SoA or AoS) and appends that set of argument memory types to a list in the UDFs meta record. So now each UDF defined in the functions block knows what combinations of AoS and SoA arguments it needs to generate.
  3. When the program starts printing out the C++, it will go through each UDF's list of memory patterns and generate a signature and body for each

I think the above will work? It sounds like it's only 3 steps but there's a lot of little things to do in all of those.

@SteveBronder SteveBronder added the feature New feature or request label Aug 8, 2022
@WardBrian
Copy link
Member

This seems reasonable. Part 3 shouldn't be too bad since we already have overloading code generation working. Something like #1233 would make it even easier I think

Since we have the inliner working could we cut down on the amount of work the optimizer needs to do if we only run step 1 for functions which are used in the higher order functions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request optimization
Projects
None yet
Development

No branches or pull requests

2 participants