Skip to content

Commit af4ae50

Browse files
authored
use the correct SYCL context for host USM allocations (ggml-org#7777)
Signed-off-by: Ben Ashbaugh <[email protected]>
1 parent 10ceba3 commit af4ae50

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ggml-sycl.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13089,10 +13089,12 @@ void *ggml_sycl_host_malloc(size_t size) try {
1308913089
return nullptr;
1309013090
}
1309113091

13092+
ggml_sycl_set_device(g_main_device);
13093+
dpct::queue_ptr main_stream = g_syclStreams[g_main_device][0];
13094+
1309213095
void * ptr = nullptr;
13093-
//allow to use dpct::get_in_order_queue() for host malloc
1309413096
dpct::err0 err = CHECK_TRY_ERROR(
13095-
ptr = (void *)sycl::malloc_host(size, dpct::get_in_order_queue()));
13097+
ptr = (void *)sycl::malloc_host(size, *main_stream));
1309613098

1309713099
if (err != 0) {
1309813100
// clear the error
@@ -13113,8 +13115,9 @@ catch (sycl::exception const &exc) {
1311313115
}
1311413116

1311513117
void ggml_sycl_host_free(void *ptr) try {
13116-
//allow to use dpct::get_in_order_queue() for host malloc
13117-
SYCL_CHECK(CHECK_TRY_ERROR(sycl::free(ptr, dpct::get_in_order_queue())));
13118+
ggml_sycl_set_device(g_main_device);
13119+
dpct::queue_ptr main_stream = g_syclStreams[g_main_device][0];
13120+
SYCL_CHECK(CHECK_TRY_ERROR(sycl::free(ptr, *main_stream)));
1311813121
}
1311913122
catch (sycl::exception const &exc) {
1312013123
std::cerr << exc.what() << "Exception caught at file:" << __FILE__

0 commit comments

Comments
 (0)