microsoft / knossos-ksc

Compiler with automatic differentiation
Other
45 stars 10 forks source link

Call Futhark via API? #68

Open toelli-msft opened 5 years ago

toelli-msft commented 5 years ago

Is it possible to link in Futhark and call it directly via a Haskell API? That would make the tests slightly more robust than shelling out to the binary.

toelli-msft commented 5 years ago

(This is quite low priority)

athas commented 5 years ago

Yes, it's quite straightforward: https://futhark-lang.org/blog/2017-09-26-calling-futhark-from-c-and-haskell.html

toelli-msft commented 4 years ago

This is something I'd like to tackle now, to help with https://github.com/microsoft/knossos-ksc/issues/299#issuecomment-616475295 and https://github.com/microsoft/knossos-ksc/issues/200. The API that you linked to seems lower level than I need.

Ideally I'd be able to install the futhark Haskell package and call a single Haskell function to check a Futhark program contained in a String (or Text). Is that feasible?

athas commented 4 years ago

You could do what futhark check does: https://github.com/diku-dk/futhark/blob/master/src/Futhark/CLI/Check.hs#L25

I haven't thought a lot about API stability and such at this level, but anecdotally that function hasn't changed in a long time, and I don't expect it will ever change fundamentally.

One thing to look out for, though, is that the Futhark code generated by Knossos does not work with Futhark 0.15.1 or newer. The problem is that as Knossos grew more lax about sizes, Futhark grew more strict. I guess it's time to take a real peek at this.

toelli-msft commented 4 years ago

Thanks, I will try Futhark.CLI.Check.main "<futhark via API>" [filename] and go from there.

the Futhark code generated by Knossos does not work with Futhark 0.15.1 or newer. The problem is that as Knossos grew more lax about sizes, Futhark grew more strict. I guess it's time to take a real peek at this.

Good to know, thanks.