Specifying size of data structures in inlined code

Here is a small example on which I can reproduce the problem:

#include <stdio.h>
#include <stdlib.h>

void foo(char* buffer, int count)
        int i;
        for(i=0; i<count; i++)

int main(int argc, char* argv[])
        char* buffer = NULL;
        int i, count=atoi(argv[1]);
        buffer = (char*) malloc (sizeof(char) * count);

        if (!buffer)
                return 1;

        #pragma acc region copy(buffer[:count])
        foo(buffer, count);

        return 0;

Here’s the compiler message:

$ pgcc -ta=nvidia -Minfo source.c -c -Minline
PGC-W-0155-Accelerator region ignored; see -Minfo messages (source.c: 21)
21, Accelerator restriction: size of the GPU copy of an array depends on values computed in this loop
Accelerator region ignored
22, foo inlined, size=5, file source.c (6)
8, Accelerator restriction: size of the GPU copy of ‘…inline’ is unknown
Accelerator restriction: one or more arrays have unknown size


I believe the error is from the compiler not being able to determine the size of buffer/loop inside function foo(). It looks like the compiler renames the symbols from the function (…inline) when the ‘-Minline’ flag is used. Is it possible to indicate the size of the buffer in the pragma statement for the arrays used in the inlined loop?


Hi Ashay,

This is a known limitation with inlining and the PGI Accelerator model. We are working to address the issue but given the complexity of the problem, it has not be solved as of yet. While we have other similar examples, I added TPR#18588 to track the progress of your particular example.

The only work around in this case is to manually inline the function.


Thanks Mat!