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

Make trans vtables more visible to Perl, enable kernels to be passed as callbacks #506

Open
mohawk2 opened this issue Dec 4, 2024 · 2 comments

Comments

@mohawk2
Copy link
Member

mohawk2 commented Dec 4, 2024

In order to better support both #349 and PDL libraries that want to pass callbacks (PDL::LinearAlgebra, PDL::GSL::MROOT, among others), it would be good to make transformations' vtables more of a first-class entity. Things I can think of needed:

  • have a package array variable listing all the xforms
  • have a Perl class method that can instantiate a vtable
  • store the various types of Code in the vtable
  • make those available as Perl methods, maybe including an as_hashref method
  • break out the per-gentype code snippets into separate kernel functions, put them in a vtable array entry
  • allow a vtable object to be passed as a callback for e.g. PDL::GSL::MROOT - this would mean not needing to enter Perl space for each callback-call

This also links to #505.

@mohawk2
Copy link
Member Author

mohawk2 commented Jan 14, 2025

As noted on https://sourceforge.net/p/pdl/mailman/message/59118263/ - this would help with both loop fusion (if a single-step version of readdata/writebackdata is also generated), and implementing "einops". Both the latter would be "meta-functions".

@mohawk2
Copy link
Member Author

mohawk2 commented Jan 21, 2025

To bring over the thought from #505 to enable closing that:

Another thing that would help generally (including for callbacks) is being able to stack-allocate a struct pdl and then call an inline function (which would live in pdl.h) to initialise it; this could then also be used in pdl_pdlnew itself, so there'd be only one "source of truth" for initialisation. There should also be a slightly more powerful version that also initialises dims and datatype, and a further one that also initialises with data (usable by this).

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

No branches or pull requests

1 participant