mikeseven / node-opencl

Low-level OpenCL 1.x and 2.x bindgings for node.js
156 stars 33 forks source link

Using local memory gives invalid argument error #38

Closed milhidaka closed 8 years ago

milhidaka commented 8 years ago

cl.setKernelArg(kernel, idx, 'local', size) gives invalid argument error. It seems argument 2 ('local') is treated as local memory size. The patch may be as follows:

diff --git a/src/kernel.cpp b/src/kernel.cpp
index 5f4cf2e..69550a6
--- a/src/kernel.cpp
+++ b/src/kernel.cpp
@@ -294,10 +294,10 @@ NAN_METHOD(SetKernelArg) {

   if (local_arg) {
     // expect a size type
-    if (!info[2]->IsNumber())
+    if (!info[3]->IsNumber())
       THROW_ERR(CL_INVALID_ARG_VALUE);
     // local buffers are intialized with their size (data = NULL)
-    size_t local_size = info[2]->ToInteger()->Value();
+    size_t local_size = info[3]->ToInteger()->Value();
     err = ::clSetKernelArg(k->getRaw(), arg_idx, local_size, NULL);
   } else if ('*' == type_name[type_name.length() - 1] || type_name == "cl_mem"){
     // type must be a buffer (CLMem object)
mikeseven commented 8 years ago

fixed thanks to Andreas!