rise-lang / shine

The Shine compiler for the RISE language
https://rise-lang.org
MIT License
73 stars 8 forks source link

[BUG] Compilation of the generated OpenMP code fails (Canonical Loop Form) #189

Closed bpervan closed 3 years ago

bpervan commented 3 years ago

Describe the bug Consider the following expression:

val simple: ToBeTyped[Rise] = fun((3`.`int) ->: (3`.`int))(in =>
    in |> mapPar(fun(e => add(e)(l(1))))
)

which translates to:

void foo(int* output, int* e133){
    #pragma omp parallel for
    for (int i_162 = 0;(i_162 < 3);i_162 = (1 + i_162)) {
        output[i_162] = (e133[i_162] + 1);
    }
}

Trying to compile the following snippet yields error: invalid controlling predicate

It seems that the culprit(s) are parentheses around the testing expression, as the generated for loop doesn't conform with the so called Canonical Loop Form

To Reproduce Steps to reproduce the behavior:

  1. Translate an expression with mapPar primitive using OpenMP generator.
  2. Try compiling the snippet by invoking gcc -fopenmp -o snippet snippet.c

Expected behavior The generated block should be compilable by the OpenMP-implementing compiler

Platform (please complete the following information):

Bastacyclop commented 3 years ago

Duplicate of #17

bpervan commented 3 years ago

Indeed :see_no_evil: