]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
Revert "sycl:remove redundant memcopy in function ggml_backend_sycl_buffer_set_tensor...
authorNeo Zhang Jianyu <redacted>
Tue, 8 Apr 2025 07:03:21 +0000 (15:03 +0800)
committerGitHub <redacted>
Tue, 8 Apr 2025 07:03:21 +0000 (15:03 +0800)
* Revert "sycl: remove redundant memcopy in function ggml_backend_sycl_buffer_s…"

This reverts commit 518a01480eb3a7c80a4951b430db9dee55428310.

* Update ggml/src/ggml-sycl/ggml-sycl.cpp

* Update ggml/src/ggml-sycl/ggml-sycl.cpp

* rm tail space

ggml/src/ggml-sycl/ggml-sycl.cpp

index f6f288d99063915abb79e5b0c431e09da0b63cb8..89715eaea0753d7eb0150cd690bdeea1cb46c58b 100644 (file)
@@ -372,9 +372,14 @@ static void ggml_backend_sycl_buffer_set_tensor(ggml_backend_buffer_t buffer,
     auto stream = &(dpct::dev_mgr::instance().get_device(ctx->device).default_queue());
     SYCL_CHECK(
         CHECK_TRY_ERROR(dpct::dev_mgr::instance().get_device(ctx->device).queues_wait_and_throw()));
+    // Note: Use host buffer to save the data from mmap(), then copy to device. It's workaround for mmap() issue on PVC GPU.
+    // This function will be called during load model from disk. Use memory buffer replace dynamic won't save more time and brings potential memory leak risk here.
+    char* host_buf = (char*)malloc(size);
+    memcpy(host_buf, data, size);
     SYCL_CHECK(
-        CHECK_TRY_ERROR((*stream).memcpy((char *)tensor->data + offset, data, size)
+        CHECK_TRY_ERROR((*stream).memcpy((char *)tensor->data + offset, host_buf, size)
                              .wait()));
+    free(host_buf);
 }
 catch (sycl::exception const &exc) {
   std::cerr << exc.what() << "Exception caught at file:" << __FILE__