futhark icon indicating copy to clipboard operation
futhark copied to clipboard

Provide packed API functions

Open athas opened this issue 1 year ago • 1 comments

Some of the functions exposed by the C API have a variable number of parameters, depending on the underlying Futhark program:

  • Entry points have a parameter for every input and for every output.
  • Record creation functions take a parameter for every field.
  • Sum type creation functions take a parameter for every payload value.
  • Array creation functions take a parameter for every dimension.
  • ...others?

This is inconvenient for some users, particularly those making use of run-time linking (dlopen()), as it is difficult to invoke a function with a dynamically known number of arguments. It is also slightly inconvenient for other FFIs in some cases.

As a solution, we could expose "packed" variants of these functions (does a better name exist?) where each sequence of variable-length parameters is replaced with a single array that contains pointers to those values.

athas avatar Jul 01 '24 10:07 athas

In order to not complicate the code generator for this relatively niche use case, the best way to implement this would be to have a separate facility (which can be part of futhark) for generating packed wrapper code from a manifest file.

athas avatar Jul 25 '24 10:07 athas