Erk- / genfut

Generate bindings for Futhark
ISC License
37 stars 10 forks source link

Allow use as library, and minimally support opaque types #1

Closed porcuquine closed 4 years ago

porcuquine commented 4 years ago

~This may need a bit more cleanup, but it at least now compiles my code. I have not yet tried to actually run/use the generated code yet.~

This now handles opaque types returned by Futhark, but not arrays (of any dimension) of opaque types.

I modified to allow calling as a library to support a workflow in which genfut is used in a custom build script. Here's the WIP example usage: https://github.com/filecoin-project/neptune-triton

Erk- commented 4 years ago

It looks good to me, when I tried to run it with your code I spotted a bug though it seems to be in the Futhark compiler and Athas is working on a fix for it. if you use modules with different names but the same type name inside of them it will produce broken code. I don't think that any of the code will have to be changed, except maybe the names of the opaques in entry methods are going to be constrained to strings that are valid c identifiers.

porcuquine commented 4 years ago

It looks good to me, when I tried to run it with your code I spotted a bug though it seems to be in the Futhark compiler and Athas is working on a fix for it. if you use modules with different names but the same type name inside of them it will produce broken code. I don't think that any of the code will have to be changed, except maybe the names of the opaques in entry methods are going to be constrained to strings that are valid c identifiers.

Good point about name collisions. That occurred to me too.

I'm currently having problems trying to generate OpenCL on MacOS. Something needs to be adjusted, but my initial efforts haven't succeeded. I'll try to resolve that before finalizing this.

Erk- commented 4 years ago

What that needs to be adjusted is likely the searchpath that it uses, At the moment the only system I have tried it on is arch linux and that is not very general with where it places the librarys. Also Athas have pushed a fix for the name collision bug

athas commented 4 years ago

This line needs to be -framework OpenCL on macOS (and maybe similarly elsewhere, I didn't check).

porcuquine commented 4 years ago

Thanks. I have not yet been able to get this and other variations to work yet. I'm pulled into other things right now but will try to get this figured out as a next step. Worst case, I can ignore it for now, since MacOS is not a primary target for me. But solving it would be nice and will make development easier for me.

porcuquine commented 4 years ago

This line needs to be -framework OpenCL on macOS (and maybe similarly elsewhere, I didn't check).

I figured it out — just need a few little tweaks. (For the curious: https://github.com/Erk-/genfut_bin/pull/1/commits/4d13c363586dcfeb401cd191389fa86aef389f96).