BLAST - High performance runtime script interpretor, Burst and DOTS compatible

BLAST

- orders of magnitudes faster then generic script interpretors -

- the only interpretor with a wide execution mode -

- naturally maps to datastructures used in ECS/DOTS -

- fast native external dataaccess, external callprofile codegen -


BLAST is a runtime bytecode compiler & interpretor that can interpret scripts at runtime in a native burst compatible environment. It can run single scripts or expressions over large datasets using a vectorized interpretor achieving a higher performance in ssmd mode on scripts then often possible when programmed in a managed language


SSMD is the execution of a single script on multiple sets of data. Single Script Multiple Data. It allows blast to vectorize script code which would normally be very difficult or impossible to vectorize or execute efficiently otherwise. Many code patterns can be vectorized if seen as operations on arrays and by utilizing this fact from the ground up while interpreting script the ssmd interpretor can reach maximum SIMD performance in code segments that would otherwise have costed the developer a long time to rewrite and optimize. The difficulty now is in managing your data so you can feed it to blast fast enough as often managed data management can cost more performance then blast interpreting it.


BLAST currently features:


  • Datatypes: float, float2, float3, float4, int, int2, int3, int4, bool32, constant length arrays
  • Control flow instructions: switch, while, for, if then else
  • External function support, with the interface defined through codegen for ultimate performance
  • The Unity Mathematics library directly accessible through script
  • Flexible datasegment mapping, you can move the data and stack pointers to directly work on the data instead of copying it.
  • Define inputs in script that map to arrays of floats.
  • Extremely compact bytecode compiled from script in milliseconds. Byte sized instructions, 7bit addressing and smart constant handling result in bytecode that make surprisingly large scripts fit in a single cache line with the resulting performance benifits.
  • Simple but powerfull compiler that flattens the input script and removes all nesting resulting in a linear execution path with minimal stack use and branching.
  • Extremely fast execution. “A = Sin(x)” takes only 40ns to interpret, this is 10x faster then a leading jit script compiler. In ssmd mode it can process the same script in 1.5 nanoseconds, 750.000.000 times per second on 1 thread.

This performance comes with limitations:

  • Blast is memory fixed, as such it will not allow variable length data. This does not have to be a limitation as external data access is best done through external functions that can access the native environment and get burst compiled.
  • Blast is fast because it is a simple language, it is aimed at calculating stuff, deciding options, fast, many times, configurable through configuration in the target application.
  • Blast has limited datatype support and only allows simple control flow instructions and arithmetic. See the language reference on github for a full reference.
  • Although you can define macros (inlined functions) each blast script should be seen as a single function operation on a dataset.
  • In order to use SSMD processing all data needs to be organized in such a way that it maps to the scripts datasegments. This is natural to achieve in DOTS/ECS but can be very difficult to achieve in builds centered around GameObjects.
  • BLAST is hard to use, future versions will address this through extensions and supporting components but at its core it will remain a beast.
  • SSMD processing mode is currently limited to float vectors and bool32 values, integer support is planned for release this summer.
  • SSMD mode has limited control flow support, no if then, no switch, it only supports constantly terminated loops: loops with a constant length over the whole dataset. Future releases will remove this restriction.
  • SSMD support for external functions accepting vectorized parameter sets.


Disclaimer: This is package is under active development and we are very open to suggestions.


Please log any issues at:

https://github.com/nijnstein/BLAST-Documentation/issues


Documentation can be found on github: https://github.com/nijnstein/BLAST-Documentation



## Roadmap ##


BLAST V1.1 - Summer 2022

  • Normal Packagemode: Design/Compiletime transpilation from bytecode into bursted functionpointers. This will void any performance penalty to using scripts instead of native code when scripts are known during design time.
  • Int32 (1-4) support for SSMD

BLAST V1.2 - Autumn/Winter 2022

  • Full Control flow support in SSMD (conditional jump support)
  • Computeshader interpretor specialized to float4|half8