OpenMP on the Emu architecture

The Emu architecture is a unique architecture featuring migrating threads and near-memory processing capabilities that cater to a wide variety of applications with sparse-math and cache-unfriendly operations. The Cilk programming model is currently the only programming model that can cater to the growing audience of scientific applications for this architecture. Given the sheer popularity and prevalence of OpenMP programs, there is a great customer-driven need to support it on the Emu architecture.
The recent development of the Tapir parallel IR constructs for expressing fork-join parallelism recovers optimization opportunities lost in translation of parallel programming constructs to opaque parallel runtime calls by mainstream compilers.
This work attempts to find a translation for core OpenMP constructs to Tapir IR. Subsequently, this IR can be lowered to calls into the OpenMP runtime, which can be further lowered on to calls specific to the Emu Architecture.
The high-level objectives of this work include:
1) Translation of the ‘omp’ parallel directive to establish the context of a parallel region. This will allow conformant support for directives nested inside parallel regions, such as the ‘omp for’ and the ‘omp parallel for’ directives.
2) Support for internal control variables – The OpenMP runtime expects internal control variables such as nthreads-var, which controls the number of threads requested for an encountered parallel region, to be defined. These variables are attached to a region’s data environment (which mainly consists of variables defined in the user code). We can achieve this by emitting them into the IR at the front end or in the passes. They can be associated with a Tapir syncregion corresponding to the parallel directive. These variables derive their initial values from runtime calls/environment variables, which we can cater to by inserting runtime calls in the IR.
3) Support the static schedule for ‘omp for’ and ‘omp parallel for’ directives.
4) Support ‘omp barrier’, ‘omp single’ and ‘omp master’.