Fix enqueueMapSVM for cl::vector and add unit test. (#110)
diff --git a/include/CL/opencl.hpp b/include/CL/opencl.hpp
index cc3d2b6..9203270 100644
--- a/include/CL/opencl.hpp
+++ b/include/CL/opencl.hpp
@@ -8151,7 +8151,7 @@
{
cl_event tmp;
cl_int err = detail::errHandler(::clEnqueueSVMMap(
- object_, blocking, flags, static_cast<void*>(container.data()), container.size(),
+ object_, blocking, flags, static_cast<void*>(container.data()), container.size()*sizeof(T),
(events != NULL) ? (cl_uint)events->size() : 0,
(events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL,
(event != NULL) ? &tmp : NULL),
diff --git a/tests/test_openclhpp.cpp b/tests/test_openclhpp.cpp
index 26ee554..f7f26c6 100644
--- a/tests/test_openclhpp.cpp
+++ b/tests/test_openclhpp.cpp
@@ -2346,6 +2346,14 @@
#endif
}
+void testEnqueueMapSVM()
+{
+#if CL_HPP_TARGET_OPENCL_VERSION >= 200
+ std::vector<int> vec(7);
+ clEnqueueSVMMap_ExpectAndReturn(commandQueuePool[0].get(), CL_TRUE, CL_MAP_READ|CL_MAP_WRITE, static_cast<void*>(vec.data()), vec.size()*sizeof(int), 0, NULL, NULL, CL_SUCCESS);
+ TEST_ASSERT_EQUAL(commandQueuePool[0].enqueueMapSVM(vec, CL_TRUE, CL_MAP_READ|CL_MAP_WRITE), CL_SUCCESS);
+#endif
+}
// Run after other tests to clear the default state in the header
// using special unit test bypasses.