language-c-quote icon indicating copy to clipboard operation
language-c-quote copied to clipboard

ISPC support

Open pema99 opened this issue 2 years ago • 2 comments

This PR adds support for ispc, which is Intel's data parallel C dialect. We've been using these changes to generate ISPC code for a new backend for the Futhark compiler. The PR does not add support for every language construct unique to ISPC, but for the large portion of them that were sufficient for our use case.

We've attempted to pattern match from the existing codebase, but couldn't quite figure out how the script for generating Syntax-instances.hs works, so we added the relevant typeclasses instances manually. Hope that is fine.

The PR introduces one new shift-reduce error, which is the dangling else problem but for ISPC's own cif construct. I've added a note.

Added:

  • A new ISPC module which encompasses the added language constructs
  • uniform and varying type qualifiers.
  • foreach, foreach_active, foreach_unique, foreach_tiled loops.
  • export and unmasked storage qualifiers.
  • cif, cfor, cwhile, cdo/while constructs for coherent control flow.
  • An antiquotation, $foreachiters, to parse iteration spaces for foreach loops, such as i = 0 ... n.
  • A new test suite exercising all the added functionality.

Notable missing language constructs:

  • new and delete syntax for allocating arrays.
  • launch construct for multithreading.
  • Short vector notation, ie. float<3>.
  • Struct-of-array qualifiers, ie. soa<8> Point pts[n];
  • Reference syntax for interacting with C++, just typical &.

Most of these are either fairly niche, and not really necessary for writing idiomatic ISPC for most use cases, though.

pema99 avatar Apr 12 '22 00:04 pema99

@athas FYI

pema99 avatar Apr 12 '22 00:04 pema99

The CI failure seems to be a network issue

pema99 avatar Apr 19 '22 16:04 pema99