Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Sylvain
Beginner
272 Views

OpenMP target data to intel GPU error with array

Jump to solution

Hello,

I try to offload computation to intel GPU with OpenMP, but I have a compiler core dump with non constant arrays with this code :

int main()
{
    int N=10;
    double a;
    double b;
    double c;

    for (int i=0; i<N; i++) {
        a = i;
        b = 1./i;
    }

    #pragma omp target data map(to:a,b) map(from:c)
    {
    #pragma omp target teams distribute parallel for simd
    for (int i=0; i<N; i++) {
        c = a+b;
    }
    }

    return 0;
}

For it to work, I either have to define N constant of use pointers instead of arrays.

I report this problem here, As I understood only C++ compiler included in oneAPI HPC Toolkit allows offloading to intel GPU.

My configuration :

  • Gentoo Linux
  • CPU i5-7300U with HD Graphics 620
  • oneAPI HPC Toolkit 2021.1 beta06
  • neo-20.16.16582
  • intel-graphics-compiler-1.0.3826
  • level-zero-0.91.10
  • I used "-qnextgen -fiopenmp -fopenmp-targets=spir64" for compilation

 

The error I have :

icpc -Wall  -O0 -qnextgen -fiopenmp -fopenmp-targets=spir64 -debug all  -xKABYLAKE   -I../ -I/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/compiler/lib/intel64_lin/ -c main.cpp -o obj/Release_icc/main.o
icpc -Wall  -O0 -qnextgen -fiopenmp -fopenmp-targets=spir64 -debug all  -xKABYLAKE   -I../ -I/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/compiler/lib/intel64_lin/ -c omp_vector.cpp -o obj/Release_icc/omp_vector.o
icpc -L/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/compiler/lib/intel64_lin/ -o bin/Release_icc/test_GPU obj/Release_icc/main.o obj/Release_icc/omp_vector.o  -qnextgen -fiopenmp -fopenmp-targets=spir64   
Stack dump:
0.    Program arguments: /opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv @/tmp/icpxargoWPXyv  
1.    Running pass 'LLVMToSPIRV' on module '/tmp/icpxspvout2X3Km5'.
 #0 0x000056148f158ab2 PrintStackTraceSignalHandler(void*) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x657ab2)
 #1 0x000056148f158e50 SignalHandler(int) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x657e50)
 #2 0x00007f49fde63670 __restore_rt (/lib64/libpthread.so.0+0x14670)
 #3 0x000056148ec4e484 SPIRV::LLVMToSPIRV::transType(llvm::Type*) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x14d484)
 #4 0x000056148ec53744 SPIRV::LLVMToSPIRV::transValueWithoutDecoration(llvm::Value*, SPIRV::SPIRVBasicBlock*, bool) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x152744)
 #5 0x000056148ec515ad SPIRV::LLVMToSPIRV::transValue(llvm::Value*, SPIRV::SPIRVBasicBlock*, bool) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x1505ad)
 #6 0x000056148ecc6ac3 SPIRV::LLVMToSPIRVDbgTran::transDbgArrayType(llvm::DICompositeType const*) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x1c5ac3)
 #7 0x000056148ecc637e SPIRV::LLVMToSPIRVDbgTran::transDbgEntryImpl(llvm::MDNode const*) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x1c537e)
 #8 0x000056148ecc4c7e SPIRV::LLVMToSPIRVDbgTran::transDbgEntry(llvm::MDNode const*) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x1c3c7e)
 #9 0x000056148ecc4814 SPIRV::LLVMToSPIRVDbgTran::transDebugMetadata() (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x1c3814)
#10 0x000056148ec4d79b SPIRV::LLVMToSPIRV::translate() (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x14c79b)
#11 0x000056148ec4d258 SPIRV::LLVMToSPIRV::runOnModule(llvm::Module&) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x14c258)
#12 0x000056148f03f4a0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x53e4a0)
#13 0x000056148ec63917 llvm::writeSpirv(llvm::Module*, SPIRV::TranslatorOpts const&, std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0x162917)
#14 0x000056148ebe821e main (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0xe721e)
#15 0x00007f49fdca3f1b __libc_start_main /usr/src/debug/sys-libs/glibc-2.29-r7/glibc-2.29/csu/../csu/libc-start.c:342:3
#16 0x000056148ebe32b7 _start (/opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv+0xe22b7)
icpc (NextGen): error #10105: /opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv: core dumped
icpc (NextGen): warning #10102: unknown signal(0)
icpc (NextGen): error #10106: Fatal error in /opt/intel/inteloneapi/compiler/2021.1-beta06/linux/bin/llvm-spirv, terminated by unknown

 

Thanks,

Sylvain

Tags (1)
0 Kudos

Accepted Solutions
AbhishekD_Intel
Moderator
272 Views

Hi Sylvain,

We exactly don't know the main reason for your above error but it is related to the stack memory of your code. That is most probably be due to the size of the defined array.

If you give const size to your array you will not get any error (like const int N=<size>) or you can also define N size as #define N <size> it will also work.

You can also try creating a dynamic array double *a = (double *)malloc( n * sizeof(double) );  and it will also work and will not throw any error.

 

The above 3 workarounds will solve your problem meanwhile, we will also investigate the exact cause of the error. Do let us know if it works.

 

 

Warm Regards,

Abhishek

View solution in original post

6 Replies
AbhishekD_Intel
Moderator
273 Views

Hi Sylvain,

We exactly don't know the main reason for your above error but it is related to the stack memory of your code. That is most probably be due to the size of the defined array.

If you give const size to your array you will not get any error (like const int N=<size>) or you can also define N size as #define N <size> it will also work.

You can also try creating a dynamic array double *a = (double *)malloc( n * sizeof(double) );  and it will also work and will not throw any error.

 

The above 3 workarounds will solve your problem meanwhile, we will also investigate the exact cause of the error. Do let us know if it works.

 

 

Warm Regards,

Abhishek

View solution in original post

Sylvain
Beginner
272 Views

Hello,

Thanks for your answer. The workarounds are solving the problem.

I hope anyway you will find why it is not working in this special case for next people encountering the problem.

Best regards,

Sylvain

AbhishekD_Intel
Moderator
272 Views

Hi Sylvain,

Actually while dealing with the stack for offload purpose we need to define the size and that size should not be variable. The compiler needs to know in advance how big is the array. If you assign its size through the "int" variable then its there is a chance that it may change though you have not to change it in your program whereas if its a constant value then it is known that this value will not change and can assign the exact space in stack.

Due to this reason you are getting stack dumped. But if there is some use case where you don't know the exact size of the array then you can go with a dynamic array.

I hope this is will help you.

 

Warm Regards,

Abhishek

 

Sylvain
Beginner
272 Views
Thank you, I understand the problem. But it would be nice if the compiler for GPU could give an error or warning to help find the problem, like CPU compilers. I suppose those compilers are not mature yet. Best regards, Sylvain
AbhishekD_Intel
Moderator
272 Views

Thank you for the suggestion we will forward your request to the concerned team.

As your issue got resolved, can we close the thread?

 

Warm Regards,

Abhishek

AbhishekD_Intel
Moderator
241 Views

Hi,

We hope your issue got resolved and we are closing this thread.


Thank you