Nvc++ (23.5) error message with long type for std::abs()

Hello,

The following code is OK (build and run fine):

#include <cmath>
int main() {
   int N = 10;
   int b[N];
   #pragma omp target teams distribute parallel for map(tofrom:b[0:N])
   for (int i = 0; i < N; i++)
      b[i] = std::abs(b[i]);
   return 0;
}

But when I switch to long:

#include <cmath>
int main() {
   long N = 10;
   long b[N];
   #pragma omp target teams distribute parallel for map(tofrom:b[0:N])
   for (long i = 0; i < N; i++)
      b[i] = std::abs(b[i]);
   return 0;
}

I got error message:
nvc++ -O3 -mp -target=gpu -I$CUDA_ROOT/include -L$CUDA_ROOT/lib64 -lcudart -o long long.cpp
VC+±S-1062-Support procedure called within a compute region - labs (long.cpp: 56)
NVC++/x86-64 Linux 23.5-0: compilation completed with severe errors

OpenMP crayCC compiler works with the second snippet.

Thanks, I am using nvc++ 23.5.

Pierre

If I switch to “long long” it works too, but I need to work as much as possible with “long” not “long long”:

#include <cmath>
int main() {
   long long N = 10;
   long long b[N];
   #pragma omp target teams distribute parallel for map(tofrom:b[0:N])
   for (long long i = 0; i < N; i++)
   {
      b[i] = std::abs(b[i]);
   }
   return 0;
}

Ok, I work around my issue with a cast to “long long”:

#include <cmath>
int main() {
   long N = 10;
   long b[N];
   #pragma omp target teams distribute parallel for map(tofrom:b[0:N])
   for (long i = 0; i < N; i++)
   {
      b[i] = std::abs((long long)b[i]);
   }
   return 0;
}

Hi Pierre,

Glad you found a work around. I tested the original program and was able to reproduce the error in 23.5, but it appears to have been fixed in 23.7.

% nvc++ -mp=gpu test.cpp -V23.5
NVC++-S-0000-Internal compiler error. Call in OpenACC region to support routine - labs (test.cpp: 56)
NVC++-S-0155-Compiler failed to translate accelerator region (see -Minfo messages)  (test.cpp: 56)
NVC++/x86-64 Linux 23.5-0: compilation completed with severe errors
% nvc++ -mp=gpu test.cpp -V23.7
%

-Mat

1 Like

Thanks Mat, good to know it has already been fixed. I will try to follow more closely the next releases, cause I have another nvc++ issue with long type used into target regions I should investigate.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.