-
Notifications
You must be signed in to change notification settings - Fork 119
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
Support GHCJS compilation #507
Comments
Could you elaborate a bit on the use case? Who is running [data-parallel] array programs on the web? Moreover we'd need one of the real backends as well, which means ... converting all of LLVM to javascript so it can run on the web as well? That's insane. Saying that, I do see that something like a web-assembly backend for Accelerate could maybe be useful. You'd have Accelerate generate the code offline and just incorporate the result into your site, rather than doing all of the compiling & running online... I could be wrong, so I'm interested to hear what you plan to do here. |
I'm developing a series of mathematical optimization and machine learning libraries in Haskell. I already published a PBIL implementation backed by Accelerate, https://github.com/JustinLovinger/optimal-hs-accelerate-pbil, but I have a lot more in development. I'm also working on a prototype for a web game/teaching aid. It uses mathematical optimization methods like PBIL. If Accelerate can be compiled with GHCJS, I can use the same code for offline machine learning research, where performance is important, and for web applications. Otherwise, I'll have to either use a different array implementation or duplicate a significant amount of code. That's just what I'm working on right now. I have a number of ideas and potential research projects that involve using my libraries on the web, so GHCJS support is important to me. As for backends, I figured the reference implementation could run on the web. At least for my use case, performance on the web isn't as important as code de-duplication. |
Would an offline Accelerate → WASM backend work for this use case? (and would it be better?) I'm just wondering what the easiest/best course here is. As you saw there is a bunch of C code in Accelerate, but maybe that isn't useful in this context and we can just make GHCJS ignore them. At a quick glance I see debugging/profiling hooks and interacting with the terminal, both of which I assume you can live without. I haven't dug any deeper than grep however. If you want to start working on this we can help you getting a PR merged. |
I think you would still need to compile the core It was also my impression that the C code isn't essential. It may be possible to refactor Accelerate to move the C code for debugging and pretty printing into separate packages. However, I'm not familiar enough with Accelerate or the Haskell FFI to know for certain. I think removing the C code from Accelerate is a more appropriate project for someone more familiar with Accelerate and the Haskell FFI. If I end up trying to compile Accelerate to WASM, I'll let you know what the results are, but I'm not sure if Haskell WASM compilation is mature enough. |
We wouldn't be compiling Haskell to WASM, the pathway would be Accelerate → LLVM → WASM. The result would be part of the static site data, and the question was whether that would be enough. Regardless, it sounds like overkill for your use case, so just getting I don't have the time or inclination to work on this (I've never used ghcjs and have no idea how to set it up/use it) but am happy to help you get a PR merged. Here's a rough checklist of things that need to be done.
|
I tried compiling Accelerate to Wasm using I imagine fixing Accelerate to compile with GHCJS would also fix Accelerate to compile to Wasm. However, fixing Accelerate to compile to Wasm may require fewer modifications. P.S. I have to wonder if all 36 Accelerate dependencies are strictly necessary. I've never seen a Haskell project with more dependencies than Accelerate. |
You just have to think bigger, Anyway, certainly some of those might be removed: we don't require all the features of |
Is your feature request related to a problem? Please describe.
GHCJS cannot compile
accelerate
.Describe the solution you'd like
GHCJS to successfully compile
accelerate
.Describe alternatives you've considered
Don't use
accelerate
.Additional context
accelerate
currently uses foreign C calls that fail under GHCJS. Additionally, theterminal-size
dependency does not compile with GHCJS.I'm not sure how practical it would be to support compilation under GHCJS, but it would make
accelerate
an even more backend agnostic framework for computation. With GHCJS,accelerate
could run on the web, in addition to CPUs and GPUs.The text was updated successfully, but these errors were encountered: