Use of round function in C - OpenACC

I’m trying to run this minimal example.c:

#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <stdio.h>
#include <omp.h>

int main (int argc, char *argv[]) {

    int sizeV = 1000000;
    int range = 10;
    double *restrict numbers = malloc(sizeof(double)*sizeV);
    double *restrict results = malloc(sizeof(double)*sizeV);

    for (int i=0;i < sizeV;i++) {
        numbers[i] = (double) fmod(rand(),range);

    #pragma acc kernels
        for (int i=0;i< sizeV;i++) {
    	    results[i] = round(numbers[i]);


However, after compiling:

pgcc -lm   -fast -ta=tesla:managed -Minfo=accel example.c -o Test

this error is generated:

PGC-S-0155-Procedures called in a compute region must have acc routine information: round (example.c: 24)
PGC-S-0155-Accelerator region ignored; see -Minfo messages  (example.c: 21)
     21, Accelerator region ignored
     24, Accelerator restriction: call to 'round' with no acc routine information
PGC/x86-64 Linux 16.10-0: compilation completed with severe errors

Any clue?

OpenACC does not know what ‘round’ does.
So you need to define it.

What would work is something like

int j=numbers + 0.5D0;


But round is declared in math.h. like many other functions that do work with openacc (like sqrt()), so I don’t understand why this particular function does not work…?

I didn’t like my answer either. I have filed TPR 23646 to address the missing

We determined that “llround” does work in place of round.

So, it looks like an oversight.


TPR 23646 - OpenACC lacks support for ‘ROUND(i)’
has been corrected in the current 17.4 release. There is a
17.4 Community Edition.