simd-lang
A language that makes it easy to write succinct SIMD code.
Vectorized iteration with cross-iteration state. The stream, over, and carry keywords make SIMD code read like a normal loop. Hits ~73% of simdjson stage-1 throughput on M1 (~3.5 GB/s) and ~76% for full DOM parse (~1.15 GB/s).
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}