Issue 126342
Summary when offloading nested structs, sometimes "PluginInterface" error: Failure to synchronize stream (nil): Error in cuStreamSynchronize: an illegal memory access was encountered happens
Labels new issue
Assignees
Reporter bschulz81
    The following code has no memory problems. Upon investigating, it seems not to offload dQ and dR correctly in the function qr_decomposition in line 3792 which calls 
        create_in_struct(dA);
 create_out_struct(dQ);
        create_out_struct(dR);

that do the mappings with

template<typename T>
void inline create_in_struct(const datastruct<T>& dA)
{
    #pragma omp target enter data map(to: dA,dA.pdata[0:dA.pdatalength],dA.pextents[0:dA.prank],dA.pstrides[0:dA.prank])

}

template<typename T>
void inline create_out_struct(datastruct<T>& dA)
{
    #pragma omp target enter data map(to: dA) map(alloc: dA.pdata[0:dA.pdatalength]) map(to:dA.pextents[0:dA.prank],dA.pstrides[0:dA.prank])
}
template<typename T>



 and then calls 

gpu_qr_decomposition.

If one removes the lines 1863 -1997 in gpu_qr_decomposition, especially these lines:

 #pragma omp parallel for
    for (size_t i=0; i<Q.pdatalength; i++)
    {
 Q.pdata[i]=0;
    }
//
//
    #pragma omp parallel for
    for (size_t i=0; i<R.pdatalength; i++)
    {
        R.pdata[i]=0;
 }

then the code suddenly compiles...

The strange problem is that before, similar code is called for a cholesky and an lu decomposition.

here, the code works provided i compile it without optimization.

if i compile the code with -O2, then clang takes veeeeeeerry long to finish, and for the result, the lu decomposition crashes too...

There is no problem with the array sizes, as I have checked these, and these are just test cases with 9 elements (3x3 matrix).

[main_acc.cpp.txt](https://github.com/user-attachments/files/18716923/main_acc.cpp.txt)

[mdspan_acc.h.txt](https://github.com/user-attachments/files/18716924/mdspan_acc.h.txt)

[CMakeLists.txt](https://github.com/user-attachments/files/18716925/CMakeLists.txt)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to