Vector and SIMD instructions are useful methods to increase performance on modern processors that support vector instruction sets. However, vector programming requires a lot of human effort, while existing compilers are not good at automatic vectorizing outer loop, which is critical for certain applications like 3D path tracing.
We design a compiler that allows the developer write vector and SIMD program in SIMT style, similar to how GPU programming is done. This novel programming paradigm maps each virtual thread into a vector lane at compile time, allowing each virtual thread to support complex arbitrary conditional logic, nested function calls, and complex data structures and pointers, also avoiding the need to deal with any alignment or padding issues. Our compiler targets RISC-V “V” vector instruction set extension, is built upon WebAssembly technology, and can support all C standard library functions that are required for a 3D path tracer application to function.
We compiled three test programs using our compiler. One of them is a path tracer program. We prove that our compiler can perform outer loop vectorization efficiently, also reduce the difficulty of vector and SIMD programming.