Community
cancel
Showing results for 
Search instead for 
Did you mean: 
sirgienko
Employee
247 Views

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

Jump to solution

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
220 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

4 Replies
AbhishekD_Intel
Moderator
221 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

AbhishekD_Intel
Moderator
210 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

 

sirgienko
Employee
206 Views

Yes, this thread can be closed.

AbhishekD_Intel
Moderator
204 Views

Thank you for the confirmation we are closing this thread.

Please post a new thread if you have further issues.



Warm Regards,

Abhishek


Reply