Files
clang-p2996/openmp/runtime/test/parallel/omp_parallel_if.c
David Truby b72f1ec9fb [openmp][mlir] Lower parallel if to new fork_call_if function.
This patch adds a new runtime function `fork_call_if` and uses that
to lower parallel if statements when going through OpenMPIRBuilder.

This fixes an issue where the OpenMPIRBuilder passes all arguments to
fork_call as a struct but this struct is not filled corretly in the
non-if branch by handling the fork inside the runtime.

Differential Revision: https://reviews.llvm.org/D138495
2022-12-09 14:23:27 +00:00

42 lines
681 B
C

// RUN: %libomp-compile-and-run
// RUN: %libomp-irbuilder-compile-and-run
#include <stdio.h>
#include "omp_testsuite.h"
int test_omp_parallel_if()
{
int i;
int sum;
int known_sum;
int mysum;
int control=1;
sum =0;
known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ;
#pragma omp parallel private(i) if(control==0)
{
mysum = 0;
for (i = 1; i <= LOOPCOUNT; i++) {
mysum = mysum + i;
}
#pragma omp critical
{
sum = sum + mysum;
}
}
return (known_sum == sum);
}
int main()
{
int i;
int num_failed=0;
for(i = 0; i < REPETITIONS; i++) {
if(!test_omp_parallel_if()) {
num_failed++;
}
}
return num_failed;
}