DrTimothyAldenDavis / GraphBLAS

SuiteSparse:GraphBLAS: graph algorithms in the language of linear algebra. For production: (default) STABLE branch. Code development: ask me for the right branch before submitting a PR. video intro: https://youtu.be/Tj5y6d7FegI .
http://faculty.cse.tamu.edu/davis/GraphBLAS.html
Other
364 stars 63 forks source link

Compile with cosmopolitan libc #29

Closed bergkvist closed 3 years ago

bergkvist commented 3 years ago

https://github.com/jart/cosmopolitan

"Cosmopolitan Libc makes C a build-once run-anywhere language, like Java, except it doesn't need an interpreter or virtual machine. Instead, it reconfigures stock GCC and Clang to output a POSIX-approved polyglot format that runs natively on Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS with the best possible performance and the tiniest footprint imaginable."

Could be really interesting to try building GraphBLAS/LAGraph using cosmopolitan libc instead of glibc.

DrTimothyAldenDavis commented 3 years ago

Looks cool. Does it have a jit? I really need a C jit to take GraphBLAS to the next level. I can create kernels at run time, instead of pre-constructing them in Source/Generated.

bergkvist commented 3 years ago

That sounds like a very cool idea. I don't think cosmopolitan libc provides any kind of just-in-time compilation for C. The main feature of cosmopolitan libc is the portability you get with the compiled binaries.

Julia and Numba (Python) uses LLVM for JIT - so maybe generating LLVM instructions could be a good way to go about it. There might be something to learn from the implementation details of Julia/Numba in that case.

Some other things projects that might be interesting:

DrTimothyAldenDavis commented 3 years ago

I haven't seen the bitfunnel jit before, but it looks far too complex to handle a 3,000-line kernel. The gcc jit is also cumbersome. There's no way I can do this: https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html to construct a kernel with 3000 lines of code. What I really need is a full compiler, to take in a C function I write out to a file (or string) at run-time, written in standard ANSI C. I need the full parser of a compiler, not just a code generator.

I'm guessing that LLVM does the same thing ( https://llvm.org/docs/tutorial/BuildingAJIT1.html ).

MATLAB has a mechanism (the "mex" command) where it can compile a C "mexFunction", at run time, from the MATLAB command line. It shells out to the compiler, compiles the code, and can then link and run the code. That's what I really need to be able to do, just not always within MATLAB.

CUDA has a jitify mechanism in the works that can do this for the GPU. That effort is in progress (see the CUDA folder in the development branches of GraphBLAS). It takes in a string, or file, with a proper C function that I can write out during run time, and then it compiles that kernel function so it can run on the GPU.

On Wed, Mar 3, 2021 at 6:03 AM Tobias Bergkvist notifications@github.com wrote:

That sounds like a very cool idea. I don't think cosmopolitan libc provides any kind of just-in-time compilation for C. The main feature of cosmopolitan libc is the portability you get with the compiled binaries.

Julia and Numba (Python) uses LLVM for JIT - so maybe generating LLVM instructions could be a good way to go about it. There might be something to learn from the implementation details of Julia/Numba in that case.

This might also be interesting here: https://github.com/bitfunnel/nativejit/

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/DrTimothyAldenDavis/GraphBLAS/issues/29#issuecomment-789665459, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYIIOOI7C2XGYKCP3KHP2DTBYQPPANCNFSM4YNB24BQ .