3 ms·
Personally, I use Nim to develop domain specific language for VM, JIT, emulators and neural networks. I'm currently writing a compiler for deep learning with b
by mratsim 8y ago
Personally, I use Nim to develop domain specific language for VM, JIT, emulators and neural networks.
I'm currently writing a compiler for deep learning with both AOT (emitting Nim code) and hopefully later JIT (emitting LLVM IR) capabilities complete with SIMD support. I don't see how I could do that in another language.
My biggest successes:
- include a quite maintainable JIT for x86_64 (compared to asmjit and xbyak I don't need to parse or codegen the C++ code): https://github.com/numforge/laser/blob/master/laser/photon_jit/x86_64/x86_64_ops.nim#L24-L51 https://github.com/numforge/laser/blob/master/laser/photon_j...
- a DSL for neural network: https://github.com/mratsim/Arraymancer#sequence-classification-with-stacked-recurrent-neural-networks https://github.com/mratsim/Arraymancer#sequence-classificati...
- a matrix multiplication BLAS written from scratch competitive with OpenBLAS and MKL on select matrix shape (2000x2000) but that can also support int8/int16/int32/int64 and not just float32/float64 thanks to metaprogramming. Expanding to new SIMD architecture (ARM) is very easy:
--> benchmark: https://github.com/numforge/laser/blob/master/benchmarks/gemm/gemm_bench_float32.nim#L418-L465 https://github.com/numforge/laser/blob/master/benchmarks/gem...
--> Metaprogramming AVX512 support: https://github.com/numforge/laser/blob/master/laser/primitives/matrix_multiplication/gemm_ukernel_avx512.nim https://github.com/numforge/laser/blob/master/laser/primitiv...
The most important thing for me for metaprogramming is being able to operate on the AST directly