Ferrum: uma extensão embutida de Rust para programação em GPUs
Resumo
Este artigo apresenta a Ferrum, uma extensão embutida da linguagem Rust para programação em GPUs. Usando os mecanismos de metaprogramação de Rust, a Ferrum permite escrever kernels no estilo CUDA diretamente em Rust, que são validados estaticamente e traduzidos para CUDA C em tempo de compilação, sem modificar o compilador da linguagem. A memória do device é gerenciada pelas regras de ownership de Rust, e a mutabilidade declarada na assinatura do kernel é verificada e propagada até o código CUDA gerado. Experimentos com três benchmarks clássicos mostram desempenho comparável ao do compilador experimental cuda-oxide, da NVIDIA, e ganhos expressivos sobre o código sequencial em Rust.
Referências
Du Bois, A. R. and Cavalheiro, G. G. H. (2023). GPotion: An embedded DSL for GPU programming in Elixir. In Proceedings of the XXVII Brazilian Symposium on Programming Languages (SBLP 2023), pages 1–8, Campo Grande, MS, Brazil. ACM.
Du Bois, A. R. and Cavalheiro, G. G. H. (2025). Polymorphic higher-order GPU kernels. In Euro-Par 2025: Parallel Processing – 31st European Conference on Parallel and Distributed Processing, pages 100–113, Dresden, Germany.
Eizenberg, A., Peng, Y., Pigli, T., Mansky, W., and Devietti, J. (2017). BARRACUDA: Binary-level analysis of runtime races in CUDA programs. SIGPLAN Notices (PLDI 2017), 52(6):126–140.
Heisler, B. (2026). RustaCUDA: Rusty wrapper for the CUDA driver API. Disponível em: [link]. Acesso em: ago. 2026.
Henriksen, T., Serup, N. G. W., Elsman, M., Henglein, F., and Oancea, C. E. (2017). Futhark: Purely functional GPU-programming with nested parallelism and in-place array updates. SIGPLAN Notices (PLDI 2017), 52(6):556–571.
Holk, E., Pathirage, M., Chauhan, A., Lumsdaine, A., and Matsakis, N. D. (2013). GPU programming in Rust: Implementing high-level abstractions in a systems-level language. In 2013 IEEE International Symposium on Parallel & Distributed Processing, Workshops and PhD Forum, pages 315–324.
Khronos Group (2026). OpenCL: Open standard for parallel programming of heterogeneous systems. Disponível em: [link]. Acesso em: ago. 2026.
Köpcke, B., Gorlatch, S., and Steuwer, M. (2024). Descend: A safe GPU systems programming language. Proceedings of the ACM on Programming Languages, 8(PLDI):181:1–181:24.
Lowman, C. (2026). cudarc: Safe Rust wrapper around the CUDA toolkit. Disponível em: [link]. Acesso em: ago. 2026.
Nickolls, J., Buck, I., Garland, M., and Skadron, K. (2008). Scalable parallel programming with CUDA. Queue, 6(2):40–53.
NVIDIA (2026). CUDA toolkit documentation. Disponível em: [link]. Acesso em: ago. 2026.
NVlabs (2026). cuda-oxide: an experimental Rust-to-CUDA compiler. Disponível em: [link]. Acesso em: ago. 2026.
Owens, J. D., Luebke, D., Govindaraju, N., Harris, M., Krüger, J., Lefohn, A. E., and Purcell, T. J. (2007). A survey of general-purpose computation on graphics hardware. Computer Graphics Forum, 26(1):80–113.
Peng, Y., Grover, V., and Devietti, J. (2018). CURD: A dynamic CUDA race detector. SIGPLAN Notices (PLDI 2018), 53(4):390–403.
Qin, B., Chen, Y., Yu, Z., Song, L., and Zhang, Y. (2020). Understanding memory and thread safety practices and issues in real-world Rust programs. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 763–779, London, UK.
Rust GPU Project (2026). Rust GPU: Making Rust a first-class language and ecosystem for GPU shaders. Disponível em: [link]. Acesso em: ago. 2026.
Sanders, J. and Kandrot, E. (2010). CUDA by Example: An Introduction to General-Purpose GPU Programming. Addison-Wesley Professional.
The Rust Project Developers (2026). The Rust programming language. Disponível em: [link]. Acesso em: ago. 2026.
Weiss, A., Patterson, D., Matsakis, N. D., and Ahmed, A. (2019). Oxide: The essence of rust. arXiv preprint arXiv:1903.00982.
