Skip to content

Commit cfe9b51

Browse files
authored
[SYCLomatic] Fix the thread_lock variable dtor issue (#2247)
Signed-off-by: Jiang, Zhiwei <[email protected]>
1 parent 4c507c9 commit cfe9b51

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clang/runtime/dpct-rt/include/dpct/memory.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ static inline void *dpct_malloc(size_t &pitch, size_t x, size_t y,
976976
static inline void dpct_free(void *ptr,
977977
sycl::queue &q = get_default_queue()) {
978978
#ifndef DPCT_USM_LEVEL_NONE
979-
dpct::get_current_device().queues_wait_and_throw();
979+
dpct::get_device(dpct::get_device_id(q.get_device())).queues_wait_and_throw();
980980
#endif
981981
detail::dpct_free(ptr, q);
982982
}
@@ -1507,7 +1507,7 @@ class device_memory {
15071507

15081508
~device_memory() {
15091509
if (_device_ptr && !_reference)
1510-
dpct::dpct_free(_device_ptr);
1510+
dpct::dpct_free(_device_ptr, _q);
15111511
if (_host_ptr)
15121512
std::free(_host_ptr);
15131513
}
@@ -1584,6 +1584,7 @@ class device_memory {
15841584
_device_ptr(memory_ptr) {}
15851585

15861586
void allocate_device(sycl::queue &q) {
1587+
_q = q;
15871588
#ifndef DPCT_USM_LEVEL_NONE
15881589
if (Memory == shared) {
15891590
_device_ptr = (value_t *)sycl::malloc_shared(
@@ -1607,6 +1608,7 @@ class device_memory {
16071608
bool _reference;
16081609
value_t *_host_ptr;
16091610
value_t *_device_ptr;
1611+
sycl::queue _q;
16101612
};
16111613
template <class T, memory_region Memory>
16121614
class device_memory<T, Memory, 0> : public device_memory<T, Memory, 1> {

0 commit comments

Comments
 (0)