Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
584 Discussions

DPC++ deadlock an application after using buffer with "write" access on host side

sirgienko
Employee
1,340 Views

As described in title, if you create buffer, get "write" access, fill memory via the accessor on host side, and then try to get read accessor on host side too, then you will be blocked forever. Looks like, that host side wait realizing some mutex lock, but I suspect, that the mutex should be released also on host side, so deadlock.
I know, that you can use buffer constructor, which receive host memory ptr (which can have needed data, which initialise before buffer construction), but if I am not mistaken, SYCL don't disallow to working with buffer via accessor on host side. And API also allow it, otherwise I couldn't write the code via existed SYCL API.

Minimal reproduce example is attached. File with building instruction, full backtrace and system description is attached too.

Labels (1)
0 Kudos
1 Solution
AbhishekD_Intel
Moderator
1,313 Views

Hi Nikita,

 

Moving towards your question, there is no such restriction on working with the buffer via host accessors. You can do that according to your scenario. But there are some important things which you have to follow while using the host accessor which will help you to resolve your problem.

 

Creating accessor of the access target host_buffer is a blocking operation that defines a requirement on the host and blocks the caller until the requirement is satisfied. So we need to call its destructor in order to stop the blocking operation.

You can put those accessor and there related processes in the scope so that it will automatically call its destructor and will execute the remaining operations without blocking. Below code snippet will help you.

 

 

{ //start of scope
            auto buf_w = buf2.get_access<access::mode::write>();
            for (size_t i = 0; i < ARRAY_SIZE; i++)
                <operations>
} //end of scope

 

 

I have also attached the modified code with necessary changes you also refer them.

 

Warm Regards,

Abhishek

 

View solution in original post

0 Kudos
4 Replies
AbhishekD_Intel
Moderator
1,314 Views

Hi Nikita,

 

Moving towards your question, there is no such restriction on working with the buffer via host accessors. You can do that according to your scenario. But there are some important things which you have to follow while using the host accessor which will help you to resolve your problem.

 

Creating accessor of the access target host_buffer is a blocking operation that defines a requirement on the host and blocks the caller until the requirement is satisfied. So we need to call its destructor in order to stop the blocking operation.

You can put those accessor and there related processes in the scope so that it will automatically call its destructor and will execute the remaining operations without blocking. Below code snippet will help you.

 

 

{ //start of scope
            auto buf_w = buf2.get_access<access::mode::write>();
            for (size_t i = 0; i < ARRAY_SIZE; i++)
                <operations>
} //end of scope

 

 

I have also attached the modified code with necessary changes you also refer them.

 

Warm Regards,

Abhishek

 

0 Kudos
AbhishekD_Intel
Moderator
1,303 Views

Hi Nikita,

Happy to know that the provided solution helped you. Please confirm if we can close this thread.

You can always post a new thread if you face any issue.

 

 

Warm Regards,

Abhishek

 

0 Kudos
sirgienko
Employee
1,299 Views
0 Kudos
AbhishekD_Intel
Moderator
1,297 Views

Thank you for the confirmation we are closing this thread.

Please post a new thread if you have further issues.



Warm Regards,

Abhishek


0 Kudos
Reply