Discussion: MPSL looks interesting
I spent quite some time foraging today to find asmjit and mpsl. This is certainly close to what I had in mind for some numerical and pixel processing, having some background in GPU shaders. I'm not a CPU assembly programmer, so it's a little daunting to target asmjit directly, and ideally our tools could accept user-provided C-style expressions, ideally assignments to multiple variables. A couple of broader questions in terms of goals for MPSL:
- Is there potential to harmonize more closely with C++ types such as
int8_t/char,uint8_t,int16_t,uint16_t,int32_t,uint32_t,int64_tanduint64_t? (If particular types are not natively available it's fine if they're simply not supported on that platform, IMHO) - It would be nice to have both C-style casting and C++ constructor style casting such as
float(4)oruint64_t(0) - We'd need to be able to query MPSL for the variable names, in order to provide the types of those variables. As a workaround we can provide a potentially large list of possible variables, hopefully there isn't a significant downside to that approach.
- Ideally we'd be able to do constant array indexing and/or dot notation into variables to bind vector data such as complex numbers or RGB tuples to MPSL at compile time. Such as
color[0]orcolor.x - First-class 2D, 3D, 4D
vectorandmatrixsupport with GLSL-style swizlling (pos.xxy) would be nice, eventually. - Our data is struct of arrays rather than array of structs, ideally we could bind each parameter as a pointer and a byte-increment for incrementing and JIT code for evaluating large batches of points/pixels/items.
Aside from this particular application we have in mind, best wishes with MPSL. I do think there is room for a light-weight C-like JITable CPU-friendly shading style of language, aside from things like Julia and GLSL.
Hey Nigels, thanks! Believe me, the JIT part is the simplest, the most interesting is IR and possible optimizations, which is not done yet :)
- It would be possible, but I wanted to simplify the initial implementation. Actually I started with rich-type system, but then changed it so I can more focus on other things. However, I plan to define arrays on any type and a way to read from such arrays.
- Yeah constructor-like casting and creating vars is planned
- That would be possible too, I can imagine a hook, something like "onUndefinedVariable", which is called, this would be the simplest thing
- Array indexing is planned. I don't know how far it is though as I focused more on other projects quite some time
- Also fine, basically MPSL needs to understand arrays and possibly structs.
Basically I started MSPL to be able to plug-in shaders into Blend2D and I made the project separate. My initial idea was to have a simple language that maps directly to CPU SIMD functionality with some sugar on top of it (basically 256-bit types would map directly to AVX, 128 types to SSE2). I'm still undecided how far I want to go, if I should keep the design simple like mathpresso or I should make a more complex engine that uses IR and various optimizations.