Skip to content

Add Backend LLVM Code Gen Support#141

Draft
SousaTrashBin wants to merge 73 commits intomasterfrom
add_gpu_support
Draft

Add Backend LLVM Code Gen Support#141
SousaTrashBin wants to merge 73 commits intomasterfrom
add_gpu_support

Conversation

@SousaTrashBin
Copy link
Copy Markdown
Collaborator

@SousaTrashBin SousaTrashBin commented Mar 12, 2026

Phase 1: LLVM (CPU) Backend Support

  • Decorator translating to C (LLVM) ◆
  • LLVM Subset (LLVM AST) ◆
  • Type Conversion & Validation ◆
  • AST to LLVM Subset Lowerer ◆
  • LLVM Subset to LLVM IR Generator (llvmlite adapter) ◆
  • LLVM Execution Engine ◆
  • Support for C functions (printf, free, malloc) ◆
  • Language support for Tensors/Vectors ◆

Phase 2: LLVM (GPU) Backend Support

  • Decorator translating to CUDA (GPU) ◆
  • AST to LLVM/CUDA Lowerer (Address Spaces) ◇
  • LLVM/CUDA to C/CUDA IR Generator ◇
  • CUDA Kernel Executor ◇

Phase 3: Automatic Pipeline Integration

  • Implement decorator detection in the pipeline ◆
  • Trigger Kernel generation & execution ◆

Phase 4: Configuration & Robustness

  • Add configuration options for backends ◇
  • Implement fallback to native/interpreter ◇

Symbol Meaning

  • ◆ Has Tests | ◇ Needs Tests

@SousaTrashBin
Copy link
Copy Markdown
Collaborator Author

In which step of the pipeline would it make more sense to generate the LLVM IR code? during evaluation? or would it make sense to add an extra step on the pipeline that would just create that intermediate representation, which could then be called on the eval?

@SousaTrashBin
Copy link
Copy Markdown
Collaborator Author

Also, initially I had the idea of having a specific function to run the kernels, but since I will be generating the LLVM IR, wouldn't it make more sense/be seamless to the user if the only thing the user had to do on their code was add the gpu decorator? I feel like it wouldn't make sense to add a specific config data structure just for that, specially since I will be needing to generate the kernel, unless I evaluate the expression, extract the params and then try to pass them to the kernel, but that seems a bit sketchy, when it could be done by adding parameters to the decorator

@SousaTrashBin SousaTrashBin requested a review from alcides March 13, 2026 02:10
@gpu
Copy link
Copy Markdown

gpu commented Mar 13, 2026

Although I was tagged rather accidentally here (that happens often, greetings to @cpu ), it somehow reminded me of an experiment that I made many years ago: http://jocl.org/GroovyGPU/ . Good luck with whatever you're building here 👍

@alcides alcides marked this pull request as draft March 17, 2026 15:00
@SousaTrashBin SousaTrashBin changed the title Add Gpu Support Add Backend LLVM Code Gen Support Mar 17, 2026
@alcides
Copy link
Copy Markdown
Owner

alcides commented Mar 18, 2026

Although I was tagged rather accidentally here (that happens often, greetings to @cpu ), it somehow reminded me of an experiment that I made many years ago: http://jocl.org/GroovyGPU/ . Good luck with whatever you're building here 👍

I remember your project! A couple of years before, I did a similar thing for java (https://github.com/AEminium/AeminiumGPU and https://github.com/AEminium/AeminiumGPUCompiler/)! Really cool!

Sorry for bothering you!

…ot execute, It can still generate llvmir code, It's hard to verify if there are no partial applications when anf and curry is considered
…hings are more isolated and less likely to break
…ignatures, enhance LLVM tests with additional e2e scenarios
…pecific handling in recursive evaluation
…ations, and enhance abstraction generation
…tion support, refactor validation steps and type inference methods
… polymorphic? not sure how to do this since it would need some sort of class restriction like haskell, pow should only receive Numbers)
…s to support IR generation and visitor pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants