webcl-firefox icon indicating copy to clipboard operation
webcl-firefox copied to clipboard

clCreateSubBuffer give an MISALIGNED_SUB_BUFFER_OFFSET

Open wolfviking0 opened this issue 10 years ago • 9 comments

Hi I have a sample using subbuffer, It's working on OpenCL and WebCL with Webkit but on the extension I have an error with MISALIGNED_SUB_BUFFER_OFFSET

clCreateBuffer(692911,1,128,0,18288) ->[object WebCLContext].createBuffer(1,128,null) =>Result (865895 : 0) - Message () - Exception () - Elapsed (2 ms ) clCreateSubBuffer(865895,1,4640,18296,18288) ->[object WebCLBuffer].createSubBuffer(1,64,64) =>Result (0 : 64) - Message () - Exception (origin must be a multiple of 128 bytes; was 64) - Elapsed (2 ms )

Object { name: "MISALIGNED_SUB_BUFFER_OFFSET", message: "origin must be a multiple of 128 bytes; was 64", ctx: "WebCLBuffer.createSubBuffer [webclmemoryobject.jsm:189]" } buffer.js:6639

wolfviking0 avatar Jun 22 '14 09:06 wolfviking0

What's the value returned by device.getInfo(WebCL.DEVICE_MEM_BASE_ADDR_ALIGN) on the device that you're using? The error message suggests that it's going to be 1024, which means that sub-buffers must be aligned to 128-byte (1024-bit) boundaries on that device. If that's the case, then the error message is valid according to the WebCL spec.

As to why WebKit-WebCL is not giving you that error message, I'd guess that it's not doing any error checking of its own, but relying on the underlying OpenCL driver, which may or may not enforce the alignment rule.

toaarnio avatar Aug 13 '14 12:08 toaarnio

@wolfviking0 Have you been able to fix or work around this issue?

toaarnio avatar Sep 11 '14 09:09 toaarnio

HI @toaarnio, if I aligned the sub buffer it's removing the error message but unfortunately is not working. The weird part is the result I receive. The sample in C++ OpenCL or WebCL with Webkit return :

Simple buffer and sub-buffer Example Number of platforms: 1 CL_PLATFORM_VENDOR: WEBCL_PLATFORM_VENDOR CL_DEVICE_TYPE: CL_DEVICE_TYPE_CPU CL_DEVICE_TYPE: CL_DEVICE_TYPE_GPU 0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 729 784 841 900 961 1024 1089 1156 1225 1296 1369 1444 1521 1600 1681 1764 1849 1936 2025 2116 2209 2304 2401 2500 2601 2704 2809 2916 3025 3136 3249 3364 3481 3600 3721 3844 3969 Program completed successfully

But on Firefox with extension the result is : Simple buffer and sub-buffer Example Number of platforms: 1 CL_PLATFORM_VENDOR: WEBCL_PLATFORM_VENDOR CL_DEVICE_TYPE: CL_DEVICE_TYPE_CPU CL_DEVICE_TYPE: CL_DEVICE_TYPE_GPU 0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 729 784 841 900 961 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 Program completed successfully

I have an error but I an not sure can change the result : clWaitForEvents(2,5269208) ->[object Object].waitForEvents([[object WebCLEvent],[object WebCLEvent]]) =>Result (eventWaitList[0]) - Message () - Exception (eventWaitList[1] did not have the same Context as eventWaitList[0]) - Elapsed (4 ms )

Are you familiar with this error ?

wolfviking0 avatar Sep 14 '14 09:09 wolfviking0

The clWaitForEvents error is because WebCL and OpenCL both require events in a wait list to belong to the same context, see www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clWaitForEvents.html. If you're not getting CL_INVALID_CONTEXT in the corresponding OpenCL app, then it means that your platform's OpenCL driver is not conformant.

Alternatively, there may be an error in our event wait list validation code. If the events do, in fact, belong to the same context, then you should not be getting this error.

Would you be able to check the OpenCL app to see whether the events belong to the same context or not? If they don't, then you should be able to fix the app by calling waitForEvents twice, once for each event.

As for the weird sub-buffer results, that may be a side-effect of the waitForEvents exception. Perhaps there's an event associated with the results becoming available, and now that event is not being waited on?

toaarnio avatar Sep 15 '14 08:09 toaarnio

Hi @toaarnio, if I use a for loop on each event it's working. But I print the context for each event and the context is the same :

I add inside the c++ code:

              for (int i = 0; i < events.size(); i++) {
                  cl_context info;
                  cl_int ret = clGetEventInfo(events[i], CL_EVENT_CONTEXT, sizeof(cl_context), (void *)&info, NULL);
                  printf("Event %d : %p -> Context : %p\n",i,&events[i],&info);
              }

The result is :

          Event 0 : 0x7fd8b8d28c80 -> Context : 0x7fff508cc938
          Event 1 : 0x7fd8b8d28c88 -> Context : 0x7fff508cc938

BTW the result is good now with the for loop on each event. But I use the same context for the events

wolfviking0 avatar Sep 15 '14 12:09 wolfviking0

That's weird. Can you post a link to your app so that I can debug?

toaarnio avatar Sep 15 '14 16:09 toaarnio

The sample webcl is (with the error):

http://wolfviking0.github.io/webcl-translator/build_book/index.html?sample=3&gl=off&title=Buffer%20and%20Sub-buffer

The original c++ version is : https://code.google.com/p/opencl-book-samples/source/browse/trunk/src/Chapter_7/SimpleBufferSubBuffer/simple.cpp

wolfviking0 avatar Sep 15 '14 16:09 wolfviking0

Hmm, I'm not seeing any error. Perhaps there was a bug in our event validation that's now been fixed? Coincidentally, I did do some clean-up in the eventWaitList validation code yesterday. Would you be able to get the latest "daily build" (http://toaarnio.github.io/webcl-test-suite/webcl-1.0.xpi) and see if you're still getting the error?

toaarnio avatar Sep 15 '14 16:09 toaarnio

Unfortunately I still have the error with the last version :(

wolfviking0 avatar Sep 15 '14 17:09 wolfviking0