compilation error: unsupported statement type: opcode=JSRA

Hi there,

I am writing on the issue of unsupported statement type, with opcode=JSRA.

A simple test code is as follows:

#include <iostream>

class base
{
        public:
        inline virtual void increment(int& a) = 0;
        inline virtual void createDeviceData() = 0;
        inline virtual int get_n_array() = 0;
};

class child : public base
{
        public:
        child(int _n_array)
        {
          n_array = _n_array;
          array = new int[n_array];
        }
        inline void increment(int& a)
        {
          a++;
        }
        void createDeviceData()
        {
         #pragma acc enter data copyin(this) 
         #pragma acc enter data copyin(array[0:n_array]) 
        }
        int get_n_array()
        {
          return n_array;
        }
        private:
        int n_array;
        int* array;
};
int main()
{
        base* pointer = new child(10);
        pointer->createDeviceData();

  #pragma acc parallel loop independent
  for(int i=0; i< pointer->get_n_array(); i++)
  {
        int a=1;
        pointer->increment(a);
  }
        std::cout << "DONE!" << std::endl;
}

When I compile it with “pgc++ -acc -ta=nvidia -Minfo=accel temp.C”, the following errors arise:

PGCC-S-0155-Accelerator region ignored; see -Minfo messages (temp.C: 41)
main:
41, Accelerator region ignored
44, Accelerator restriction: loop contains unsupported statement type
47, Accelerator restriction: unsupported statement type: opcode=JSRA
child::createDeviceData():
27, Generating enter data copyin(this[:1],array[:n_array])
PGCC/x86 Linux 18.10-1: compilation completed with severe errors

Line 41 is “pointer->createDeviceData();”

I have seen errors such as “Accelerator restriction: Indirect function/procedure calls are not supported” in my real code. I wonder whether the two issues are similar. Any suggestions on the workarounds will be appreciated!

Thanks,
Shine

Hi Shine,

Sorry but virtual functions are not supported within device code at this time. It’s a feature that we’d like to support, but unfortunately has proven a challenge. Hopefully sometime in the future.

-Mat

Hi Mat,

Thanks for letting me know. For now I will check closer whether my real code truly requires virtual functions, and if so I will find some workarounds.

Thanks,
Shine