Skip to content
Anthony Liot edited this page Oct 14, 2013 · 20 revisions

For build your sample you simply need to use emcc for build you C/C++ sources. You can take a look to the Makefile inside the webcl samples folder.

The WebCL-translator add some build settings for have more info during the execution of the OpenCL/WebCL code.

Settings

  1. OPENCL_OLD_VERSION

    Enable the first version of WebCL-translator, this version it's compatible for Firefox and Webkit. It's not compatible with cl.hpp headers, doesn't implement all the OpenCL function. The CL/GL interoperability it's partially supported.

    By default the settings is disabled, and use the last version of WebCL-translator, only compatible with WebKit. With an implementation of all OpenCL function, support of cl.hpp header.

  2. OPENCL_DEBUG

    Print message inside the console browser, for more info. It's no so verbose, because some other settings option give more info.

  3. OPENCL_GRAB_TRACE

    This is one part of the webcl stack tracer. When you enable it, all the webcl function are grab. This option give access to new function webclPrintStackTrace(const char*, uint*). When you call it you can have the size of the stack tracer string and the stack tracer string.

     #ifdef __EMSCRIPTEN__
     void print_stack() {
         printf("\n___________________________________\n");
         cl_uint size = 0;
         webclPrintStackTrace(NULL,&size);
    
         char* webcl_stack = (char*)malloc(size+1);
         webcl_stack[size] = '\0';
    
         webclPrintStackTrace(webcl_stack,&size);
         printf("%s\n",webcl_stack);
    
         printf("___________________________________\n");
         free(webcl_stack);
     }
     #endif
    
  4. OPENCL_PRINT_TRACE

    This is second part of the webcl stack tracer. Some OpenCL sample can exit without call the same last function, and it's hard to call the webclPrintStackTrace in the good place. This settings it's like a flush of stack tracer. If it's enabled, after each call of OpenCL function. The stack tracer are print inside the console. When you use OPENCL_PRINT_TRACE is not necessary to call webclPrintStackTrace.

  5. OPENCL_PROFILE

    For profile your sample you can enable the console profile of the browser. When it's enabled you have access to two function webclBeginProfile(const char *) and webclEndProfile(). The first function enable the console profile and start the timer. The second stop the profile, the timer and print the time elapsed, and the state of the hashmap of webcl object. Currently, you can enclose a part of your code between this two function for profile it.

  6. OPENCL_CHECK_SET_POINTER

    Some OpenCL function take void* parameter, with the translator, some info are loose about the type of pointer parameter. For respect the type you need to call clSetTypePointer( channeltype ) before each call of OpenCL function who take a void* parameter. By default the type are Float but the translator support CL_SIGNED_INT8, CL_SIGNED_INT16, CL_SIGNED_INT32, CL_UNSIGNED_INT8, CL_UNSIGNED_INT16, CL_UNSIGNED_INT32, CL_FLOAT. This option print a message inside the console if you call a function who take a pointer without call clSetTypePointer before.

     clSetTypePointer(CL_FLOAT);                               
     err = clEnqueueReadBuffer( commands, output, CL_TRUE, 0, sizeof(float) * count, results, 0, NULL, NULL );  
    
  7. OPENCL_CHECK_VALID_OBJECT

    The sebcl-translator use an hash map of WebCLObject, for debug, you can enable this settings, in each acces to a WebCLObject inside the hash map, there is a check before if the object is inside or not, and print an error message if necessary.

How read Stack Tracer

Clone this wiki locally