Target reduction in parallel region : Internal compiler error. unexpected ILM number operands

Hi,

The compiler nvc++ aborts on the following example.


include <stdio.h>

int main (void) {
#pragma omp parallel
{
int sum = 0;
#pragma omp target teams loop reduction(+:sum)
for(int i = 0 ; i < 20000; i++) {
sum += i;
}
printf(“sum2 = %d\n”,sum);
}
return 0;
}

I obtain:

NVC+±F-0000-Internal compiler error. unexpected ILM number operands for reduction pragma 0 (essai.c: 8)
NVC++/x86-64 Linux 25.1-0: compilation aborted

I use the command: “nvc++ -mp=gpu -O3 essai.c -o essai”

If I comment the first line “#pragma omp parallel” , the problem doesnot occur.

“nvc++ --version” returns
"nvc++ 25.1-0 64-bit target on x86-64 Linux -tp cascadelake "

Mickaël

Thanks Mickaël.

I’ve filed an issue report, TPR #37155, and sent it to engineering for investigation.

Note as a work around, you can switch to using the “distribute for” construct instead of “loop”

% cat test.c
#include <stdio.h>

int main (void) {
#pragma omp parallel
{
int sum=0;
#ifdef USE_DIST
#pragma omp target teams distribute parallel for reduction(+:sum)
#else
#pragma omp target teams loop reduction(+:sum)
#endif
for(int i = 0 ; i < 20000; i++) {
sum += i;
}
printf("sum2 = %d\n",sum);
}
return 0;
}
% nvc test.c -mp=gpu -DUSE_DIST
%

-Mat