Skip to content

Commit 32d3e1c

Browse files
committed
gh-231: add commentis with data copying workaround on img gpu
1 parent 87e9ff2 commit 32d3e1c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/storage/storage_manager_matrix.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ namespace spla {
149149
if (!cl_acc->is_img()) {
150150
cl_csr_read(s.get_n_rows(), cl_csr->values, cpu_csr->Ap.data(), cpu_csr->Aj.data(), cpu_csr->Ax.data(), *cl_csr, cl_acc->get_queue_default());
151151
} else {
152+
// On Imagination Technologies devices copying data to staging buffer created with CL_MEM_READ_ONLY flag does not affect this buffer.
153+
// According to the [documentation](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#clEnqueueCopyBuffer),
154+
// this flag should not affect copying, but you have to create a buffer without this flag to keep it correct.
152155
cl_csr_read(s.get_n_rows(), cl_csr->values, cpu_csr->Ap.data(), cpu_csr->Aj.data(), cpu_csr->Ax.data(), *cl_csr, cl_acc->get_queue_default(),
153156
CL_MEM_HOST_READ_ONLY | CL_MEM_ALLOC_HOST_PTR);
154157
}

src/storage/storage_manager_vector.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ namespace spla {
129129
if (!cl_acc->is_img()) {
130130
cl_dense_vec_read(s.get_n_rows(), cpu_dense->Ax.data(), *cl_dense, cl_acc->get_queue_default());
131131
} else {
132+
// On Imagination Technologies devices copying data to staging buffer created with CL_MEM_READ_ONLY flag does not affect this buffer.
133+
// According to the [documentation](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#clEnqueueCopyBuffer),
134+
// this flag should not affect copying, but you have to create a buffer without this flag to keep it correct.
132135
cl_dense_vec_read(s.get_n_rows(), cpu_dense->Ax.data(), *cl_dense, cl_acc->get_queue_default(),
133136
CL_MEM_HOST_READ_ONLY | CL_MEM_ALLOC_HOST_PTR);
134137
}
@@ -146,6 +149,9 @@ namespace spla {
146149
if (!cl_acc->is_img()) {
147150
cl_coo_vec_read(cl_coo->values, cpu_coo->Ai.data(), cpu_coo->Ax.data(), *cl_coo, cl_acc->get_queue_default());
148151
} else {
152+
// On Imagination Technologies devices copying data to staging buffer created with CL_MEM_READ_ONLY flag does not affect this buffer.
153+
// According to the [documentation](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#clEnqueueCopyBuffer),
154+
// this flag should not affect copying, but you have to create a buffer without this flag to keep it correct.
149155
cl_coo_vec_read(cl_coo->values, cpu_coo->Ai.data(), cpu_coo->Ax.data(), *cl_coo, cl_acc->get_queue_default(),
150156
CL_MEM_HOST_READ_ONLY | CL_MEM_ALLOC_HOST_PTR);
151157
}

0 commit comments

Comments
 (0)