simd-lang
A language that makes it easy to write succinct SIMD code.
I've been wanting to understand SIMD for a while and really see how much performance you can get with it. But I also find the code to write simd rather confusing. I was curious if you could write something much cleaner and get the performance difference expected. Here I was able to use MLIR and make a language that can implement SIMD JSON and get within 75% of the actual library, with way less code (simplified below).
1fn json_stage1(input: ptr[u8], positions: ptr[i32]) -> i32[1] {2 stream chunk: u8[64] over input carry (prev_in_string: u64[1] = 0,3 pos: i32[1] = 0) {4 quote_vec = chunk == '"'5 bs_vec = chunk == '\\'6 real_quote_vec = quote_vec & ~lane_shr(bs_vec, 1)78 structural_vec = (chunk == '{') | (chunk == '}') | (chunk == '[')9 | (chunk == ']') | (chunk == ':') | (chunk == ',')1011 quote_bits = to_bitmask(real_quote_vec)12 in_string_raw = clmul(quote_bits, ~0)13 in_string_with_carry = in_string_raw ^ prev_in_string1415 real_structural_bits = to_bitmask(structural_vec) & ~in_string_with_carry16 real_structural_vec = from_bitmask(real_structural_bits, 64)1718 indices = iota(64) + chunk_offset19 compressstore(positions, pos, indices, real_structural_vec)2021 carry prev_in_string = in_string_with_carry >> 63 * ~022 carry pos = pos + popcount(real_structural_vec)23 }24 return pos25}