Socket
Socket
Sign inDemoInstall

node-webcl

Package Overview
Dependencies
18
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.8.3 to 0.9.1

_MG_8737.png

113

examples/apple/qjulia/qjulia.js

@@ -29,3 +29,3 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../../../webcl');
webcl = require('../../../webcl');
clu = require('../../../lib/clUtils');

@@ -41,2 +41,4 @@ util = require('util');

}
else
webcl = window.webcl;

@@ -118,3 +120,3 @@ requestAnimationFrame = document.requestAnimationFrame;

var err=this.setupGraphics(canvas);
if(err != WebCL.SUCCESS)
if(err != webcl.SUCCESS)
return err;

@@ -127,3 +129,3 @@ this.initAntTweakBar(canvas);

var image_support = ComputeDeviceId.getInfo(WebCL.DEVICE_IMAGE_SUPPORT);
var image_support = ComputeDeviceId.getInfo(webcl.DEVICE_IMAGE_SUPPORT);
if (!image_support) {

@@ -135,7 +137,7 @@ printf("Unable to query device for image support");

log("Application requires images: Images not supported on this device.");
return WebCL.IMAGE_FORMAT_NOT_SUPPORTED;
return webcl.IMAGE_FORMAT_NOT_SUPPORTED;
}
err = this.setupComputeKernel();
if (err != WebCL.SUCCESS)
if (err != webcl.SUCCESS)
{

@@ -147,3 +149,3 @@ log("Failed to setup compute kernel! Error " + err);

err = this.createComputeResult();
if(err != WebCL.SUCCESS)
if(err != webcl.SUCCESS)
{

@@ -154,3 +156,3 @@ log ("Failed to create compute result! Error " + err);

return WebCL.SUCCESS;
return webcl.SUCCESS;
},

@@ -321,3 +323,3 @@

gl.activeTexture(gl.TEXTURE0);
return WebCL.SUCCESS;
return webcl.SUCCESS;
},

@@ -359,43 +361,27 @@ renderTexture: function( pvData )

//Pick platform
// var platformList=WebCL.getPlatforms();
// var platform=platformList[0];
// Pick platform
var platformList = webcl.getPlatforms();
var platform = platformList[0];
var devices = platform.getDevices(ComputeDeviceType ? webcl.DEVICE_TYPE_GPU : webcl.DEVICE_TYPE_DEFAULT);
ComputeDeviceId=devices[0];
ComputeDeviceType = device_type ? WebCL.DEVICE_TYPE_GPU : WebCL.DEVICE_TYPE_CPU;
ComputeContext = WebCL.createContext({
deviceType: ComputeDeviceType,
// platform: platform,
shareGroup: gl
});
// make sure we use a discrete GPU
for(var i=0;i<devices.length;i++) {
var vendor=devices[i].getInfo(webcl.DEVICE_VENDOR);
// log('found vendor '+vendor+', is Intel? '+(vendor.indexOf('Intel')>=0))
if(vendor.indexOf('Intel')==-1)
ComputeDeviceId=devices[i];
}
log('found '+devices.length+' devices, using device: '+ComputeDeviceId.getInfo(webcl.DEVICE_NAME));
var device_ids = ComputeContext.getInfo(WebCL.CONTEXT_DEVICES);
if(!device_ids)
{
alert("Error: Failed to retrieve compute devices for context!");
return -1;
if(!ComputeDeviceId.enableExtension('KHR_gl_sharing'))
throw new Error("Can NOT use GL sharing");
// create the OpenCL context
try {
ComputeContext = webcl.createContext(gl, ComputeDeviceId);
}
var device_found=false;
for(var i=0,l=device_ids.length;i<l;++i )
{
device_type=device_ids[i].getInfo(WebCL.DEVICE_TYPE);
if(device_type == ComputeDeviceType)
{
ComputeDeviceId = device_ids[i];
device_found = true;
break;
}
catch(err) {
throw "Error: Failed to create context! "+err;
}
if(!device_found)
{
alert("Error: Failed to locate compute device!");
return -1;
}
// get CL-GL extension
if(!ComputeDeviceId.enableExtension("KHR_gl_sharing")) {
log("CL-GL not available!");
process.exit(1);
}

@@ -413,8 +399,8 @@ // Create a command queue

//
var vendor_name = ComputeDeviceId.getInfo(WebCL.DEVICE_VENDOR);
var device_name = ComputeDeviceId.getInfo(WebCL.DEVICE_NAME);
var vendor_name = ComputeDeviceId.getInfo(webcl.DEVICE_VENDOR);
var device_name = ComputeDeviceId.getInfo(webcl.DEVICE_NAME);
log("Connecting to "+vendor_name+" "+device_name);
return WebCL.SUCCESS;
return webcl.SUCCESS;
},

@@ -458,3 +444,3 @@ setupComputeKernel:function() {

alert("Error: Failed to build program executable!\n"+
ComputeProgram.getBuildInfo(ComputeDeviceId, WebCL.PROGRAM_BUILD_LOG));
ComputeProgram.getBuildInfo(ComputeDeviceId, webcl.PROGRAM_BUILD_LOG));
return -1;

@@ -475,3 +461,3 @@ }

//
MaxWorkGroupSize = ComputeKernel.getWorkGroupInfo(ComputeDeviceId, WebCL.KERNEL_WORK_GROUP_SIZE);
MaxWorkGroupSize = ComputeKernel.getWorkGroupInfo(ComputeDeviceId, webcl.KERNEL_WORK_GROUP_SIZE);

@@ -484,3 +470,3 @@ log("MaxWorkGroupSize: " + MaxWorkGroupSize);

log("WorkGroupSize: " + WorkGroupSize);
return WebCL.SUCCESS;
return webcl.SUCCESS;
},

@@ -492,3 +478,3 @@ createComputeResult: function() {

log("Allocating compute result image in device memory...");
ComputeImage = ComputeContext.createFromGLTexture(WebCL.MEM_WRITE_ONLY, TextureTarget, 0, TextureId);
ComputeImage = ComputeContext.createFromGLTexture(webcl.MEM_WRITE_ONLY, TextureTarget, 0, TextureId);
if (!ComputeImage)

@@ -502,3 +488,3 @@ {

log("Allocating compute result buffer in device memory...");
ComputeResult = ComputeContext.createBuffer(WebCL.MEM_WRITE_ONLY, TextureTypeSize * 4 * TextureWidth * TextureHeight);
ComputeResult = ComputeContext.createBuffer(webcl.MEM_WRITE_ONLY, TextureTypeSize * 4 * TextureWidth * TextureHeight);
if (!ComputeResult)

@@ -509,3 +495,3 @@ {

}
return WebCL.SUCCESS;
return webcl.SUCCESS;
},

@@ -597,3 +583,3 @@ cleanup: function()

return WebCL.SUCCESS;
return webcl.SUCCESS;
},

@@ -741,3 +727,3 @@ reshape: function (evt)

if(!ComputeKernel || !ComputeResult)
return WebCL.SUCCESS;
return webcl.SUCCESS;

@@ -747,7 +733,8 @@ if(Animated || Update)

Update = false;
try {
ComputeKernel.setArg(0, ComputeResult);
ComputeKernel.setArg(1, MuC, WebCL.type.FLOAT | WebCL.type.VEC4);
ComputeKernel.setArg(2, ColorC, WebCL.type.FLOAT | WebCL.type.VEC4);
ComputeKernel.setArg(3, Epsilon, WebCL.type.FLOAT);
ComputeKernel.setArg(1, new Float32Array(MuC));
ComputeKernel.setArg(2, new Float32Array(ColorC));
ComputeKernel.setArg(3, new Float32Array([Epsilon]));
} catch (err) {

@@ -764,3 +751,3 @@ alert("Failed to set kernel args! " + err);

try {
ComputeCommands.enqueueNDRangeKernel(ComputeKernel, null, global, local);
ComputeCommands.enqueueNDRangeKernel(ComputeKernel, 2, null, global, local);
}

@@ -809,3 +796,3 @@ catch(err)

ComputeCommands.finish();
return WebCL.SUCCESS;
return webcl.SUCCESS;
},

@@ -815,3 +802,3 @@

ATB.Init();
ATB.Define(" GLOBAL help='Quaternion Julia using WebCL.' "); // Message added to the help bar.
ATB.Define(" GLOBAL help='Quaternion Julia using webcl.' "); // Message added to the help bar.
ATB.WindowSize(canvas.width,canvas.height);

@@ -850,3 +837,3 @@

clgl=new CLGL();
if(clgl.initialize(use_gpu)==WebCL.SUCCESS) {
if(clgl.initialize(use_gpu)==webcl.SUCCESS) {
function update() {

@@ -853,0 +840,0 @@ clgl.display();

@@ -29,3 +29,3 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
clu = require('../lib/clUtils');

@@ -37,8 +37,10 @@ util = require('util');

}
else
webcl = window.webcl;
//First check if the webcl extension is installed at all
if (WebCL == undefined) {
alert("Unfortunately your system does not support WebCL. " +
"Make sure that you have the WebCL extension installed.");
return;
if (webcl == undefined) {
alert("Unfortunately your system does not support webcl. " +
"Make sure that you have the webcl extension installed.");
process.exit(-1);
}

@@ -78,26 +80,23 @@

//Pick platform
var platformList=WebCL.getPlatforms();
var platformList=webcl.getPlatforms();
var platform=platformList[0];
//Query the set of GPU devices on this platform
var devices = platform.getDevices(WebCL.DEVICE_TYPE_ALL);
var devices = platform.getDevices(webcl.DEVICE_TYPE_ALL);
log(" # of Devices Available = "+devices.length);
var uiTargetDevice = clu.clamp(uiTargetDevice, 0, (devices.length - 1));
var device=devices[uiTargetDevice];
log(" Using Device "+ uiTargetDevice+": "+device.getInfo(WebCL.DEVICE_NAME));
log(" Using Device "+ uiTargetDevice+": "+device.getInfo(webcl.DEVICE_NAME));
var hasImageSupport=device.getInfo(WebCL.DEVICE_IMAGE_SUPPORT);
if(hasImageSupport != WebCL.TRUE) {
var hasImageSupport=device.getInfo(webcl.DEVICE_IMAGE_SUPPORT);
if(hasImageSupport != webcl.TRUE) {
log("No image support");
return;
process.exit(-1);
}
var numComputeUnits=device.getInfo(WebCL.DEVICE_MAX_COMPUTE_UNITS);
var numComputeUnits=device.getInfo(webcl.DEVICE_MAX_COMPUTE_UNITS);
log(' # of Compute Units = '+numComputeUnits);
log(' createContext...');
context=WebCL.createContext({
devices: device,
platform: platform
});
context=webcl.createContext(device);

@@ -109,5 +108,6 @@ // Create a command-queue

var InputFormat= {
order : WebCL.RGBA,
data_type : WebCL.UNSIGNED_INT8,
size : [ image.width, image.height ],
channelOrder : webcl.RGBA,
channelType : webcl.UNSIGNED_INT8,
width : image.width,
height : image.height,
rowPitch : image.pitch

@@ -117,9 +117,9 @@ };

//2D Image (Texture) on device
cmDevBufIn = context.createImage(WebCL.MEM_READ_ONLY | WebCL.MEM_USE_HOST_PTR, InputFormat, image.buffer);
cmDevBufIn = context.createImage(webcl.MEM_READ_ONLY | webcl.MEM_USE_HOST_PTR, InputFormat, image.buffer);
RowSampler = context.createSampler(false, WebCL.ADDRESS_CLAMP, WebCL.FILTER_NEAREST);
RowSampler = context.createSampler(false, webcl.ADDRESS_CLAMP, webcl.FILTER_NEAREST);
// Allocate the OpenCL intermediate and result buffer memory objects on the device GMEM
cmDevBufTemp = context.createBuffer(WebCL.MEM_READ_WRITE, szBuffBytes);
cmDevBufOut = context.createBuffer(WebCL.MEM_WRITE_ONLY, szBuffBytes);
cmDevBufTemp = context.createBuffer(webcl.MEM_READ_WRITE, szBuffBytes);
cmDevBufOut = context.createBuffer(webcl.MEM_WRITE_ONLY, szBuffBytes);

@@ -150,3 +150,3 @@ //Create the program

var uiOutput=new Uint8Array(szBuffBytes);
queue.enqueueReadBuffer(cmDevBufOut, WebCL.TRUE, 0, szBuffBytes, uiOutput);
queue.enqueueReadBuffer(cmDevBufOut, webcl.TRUE, 0, szBuffBytes, uiOutput);

@@ -163,9 +163,16 @@ // PNG uses 32-bit images, JPG can only work on 24-bit images

// (Image/texture version)
var aints=new Int32Array(3);
aints[0]=width;
aints[1]=height;
aints[2]=r;
var afloats=new Float32Array(1);
afloats[0]=fScale;
ckBoxRowsTex.setArg(0, cmDevBufIn);
ckBoxRowsTex.setArg(1, cmDevBufTemp);
ckBoxRowsTex.setArg(2, RowSampler);
ckBoxRowsTex.setArg(3, width, WebCL.type.UINT);
ckBoxRowsTex.setArg(4, height, WebCL.type.UINT);
ckBoxRowsTex.setArg(5, r, WebCL.type.INT);
ckBoxRowsTex.setArg(6, fScale, WebCL.type.FLOAT);
ckBoxRowsTex.setArg(3, aints);
ckBoxRowsTex.setArg(4, aints.subarray(1));
ckBoxRowsTex.setArg(5, aints.subarray(2));
ckBoxRowsTex.setArg(6, afloats);

@@ -175,6 +182,6 @@ // Set the Argument values for the column kernel

ckBoxColumns.setArg(1, cmDevBufOut);
ckBoxColumns.setArg(2, width, WebCL.type.UINT);
ckBoxColumns.setArg(3, height, WebCL.type.UINT);
ckBoxColumns.setArg(4, r, WebCL.type.INT);
ckBoxColumns.setArg(5, fScale, WebCL.type.FLOAT);
ckBoxColumns.setArg(2, aints);
ckBoxColumns.setArg(3, aints.subarray(1));
ckBoxColumns.setArg(4, aints.subarray(2));
ckBoxColumns.setArg(5, afloats);
}

@@ -194,3 +201,3 @@

log('enqueue image: origin='+szTexOrigin+", region="+szTexRegion);
queue.enqueueWriteImage(cmDevBufIn, WebCL.TRUE, szTexOrigin, szTexRegion, 0, 0, image.buffer);
queue.enqueueWriteImage(cmDevBufIn, webcl.TRUE, szTexOrigin, szTexRegion, 0, image.buffer);

@@ -208,3 +215,3 @@ // Set global and local work sizes for row kernel

//Launch row kernel
queue.enqueueNDRangeKernel(ckBoxRowsTex, null, szGlobalWorkSize, szLocalWorkSize);
queue.enqueueNDRangeKernel(ckBoxRowsTex, 2, null, szGlobalWorkSize, szLocalWorkSize);

@@ -219,3 +226,3 @@ //Set global and local work sizes for column kernel

//Launch column kernel
queue.enqueueNDRangeKernel(ckBoxColumns, null, szGlobalWorkSize, szLocalWorkSize);
queue.enqueueNDRangeKernel(ckBoxColumns, 2, null, szGlobalWorkSize, szLocalWorkSize);

@@ -222,0 +229,0 @@ //sync host

@@ -29,3 +29,3 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
clu = require('../lib/clUtils');

@@ -40,2 +40,4 @@ util = require('util');

}
else
webcl = window.webcl;

@@ -93,3 +95,3 @@ requestAnimationFrame = document.requestAnimationFrame;

var err = init_gl(canvas);
if (err != WebCL.SUCCESS)
if (err != webcl.SUCCESS)
return err;

@@ -105,8 +107,8 @@

resetKernelArgs(image.width, image.height, iRadius, fScale);
BoxFilterGPU(image, ComputePBO, iRadius, fScale);
ComputeCommands.finish();
return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -120,3 +122,3 @@

log('configure shared data');
// set up data parameter

@@ -141,3 +143,3 @@ var num_texels = image_width * image_height;

// Create OpenCL representation of OpenGL PBO
ComputePBO = ComputeContext.createFromGLBuffer(WebCL.MEM_WRITE_ONLY, pbo);
ComputePBO = ComputeContext.createFromGLBuffer(webcl.MEM_WRITE_ONLY, pbo);
if (!ComputePBO) {

@@ -170,9 +172,9 @@ alert("Error: Failed to create CL PBO buffer");

log(' create buffers');
var VertexPos = [ -1, -1,
1, -1,
1, 1,
var VertexPos = [ -1, -1,
1, -1,
1, 1,
-1, 1 ];
var TexCoords = [ 0, 0,
1, 0,
1, 1,
var TexCoords = [ 0, 0,
1, 0,
1, 1,
0, 1 ];

@@ -195,9 +197,9 @@

var shaders = {
"shader-vs" : [
"shader-vs" : [
"attribute vec3 aCoords;",
"attribute vec2 aTexCoords;",
"attribute vec2 aTexCoords;",
"varying vec2 vTexCoords;",
"void main(void) {",
"void main(void) {",
" gl_Position = vec4(aCoords, 1.0);",
" vTexCoords = aTexCoords;",
" vTexCoords = aTexCoords;",
"}" ].join("\n"),

@@ -284,3 +286,3 @@ "shader-fs" : [

gl.enableVertexAttribArray(shaderProgram.textureCoordAttribute);
shaderProgram.samplerUniform = gl.getUniformLocation(shaderProgram, "uSampler");

@@ -306,3 +308,3 @@ }

return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -341,40 +343,26 @@

log('init CL');
ComputeDeviceType = device_type ? WebCL.DEVICE_TYPE_GPU : WebCL.DEVICE_TYPE_DEFAULT;
// Pick platform
// var platformList = WebCL.getPlatforms();
// var platform = platformList[0];
var platformList = webcl.getPlatforms();
var platform = platformList[0];
var devices = platform.getDevices(device_type ? webcl.DEVICE_TYPE_GPU : webcl.DEVICE_TYPE_DEFAULT);
ComputeDeviceId=devices[0];
// create the OpenCL context
ComputeContext = WebCL.createContext({
deviceType: ComputeDeviceType,
shareGroup: gl,
// platform: platform
});
var device_ids = ComputeContext.getInfo(WebCL.CONTEXT_DEVICES);
if (!device_ids) {
alert("Error: Failed to retrieve compute devices for context!");
return -1;
// make sure we use a discrete GPU
for(var i=0;i<devices.length;i++) {
var vendor=devices[i].getInfo(webcl.DEVICE_VENDOR);
// log('found vendor '+vendor+', is Intel? '+(vendor.indexOf('Intel')>=0))
if(vendor.indexOf('Intel')==-1)
ComputeDeviceId=devices[i];
}
log('found '+devices.length+' devices, using device: '+ComputeDeviceId.getInfo(webcl.DEVICE_NAME));
var device_found = false;
for(var i=0,l=device_ids.length;i<l;++i ) {
device_type = device_ids[i].getInfo(WebCL.DEVICE_TYPE);
if (device_type == ComputeDeviceType) {
ComputeDeviceId = device_ids[i];
device_found = true;
break;
}
}
if(!ComputeDeviceId.enableExtension('KHR_gl_sharing'))
throw new Error("Can NOT use GL sharing");
if (!device_found) {
alert("Error: Failed to locate compute device!");
return -1;
}
// create the OpenCL context
ComputeContext = webcl.createContext(gl, ComputeDeviceId);
if(!ComputeContext)
throw new Error("Can NOT create context");
var exts=ComputeDeviceId.getSupportedExtensions();
log("Device extensions: "+exts);
ComputeDeviceId.enableExtension("KHR_gl_sharing");
// Create a command queue

@@ -389,15 +377,15 @@ //

// Report the device vendor and device name
//
var vendor_name = ComputeDeviceId.getInfo(WebCL.DEVICE_VENDOR);
var device_name = ComputeDeviceId.getInfo(WebCL.DEVICE_NAME);
//
var vendor_name = ComputeDeviceId.getInfo(webcl.DEVICE_VENDOR);
var device_name = ComputeDeviceId.getInfo(webcl.DEVICE_NAME);
log("Connecting to " + vendor_name + " " + device_name);
if (!ComputeDeviceId.getInfo(WebCL.DEVICE_IMAGE_SUPPORT)) {
if (!ComputeDeviceId.getInfo(webcl.DEVICE_IMAGE_SUPPORT)) {
log("Application requires images: Images not supported on this device.");
return WebCL.IMAGE_FORMAT_NOT_SUPPORTED;
return webcl.IMAGE_FORMAT_NOT_SUPPORTED;
}
err = init_cl_buffers();
if (err != WebCL.SUCCESS) {
if (err != webcl.SUCCESS) {
log("Failed to create compute result! Error " + err);

@@ -408,3 +396,3 @@ return err;

err = init_cl_kernels();
if (err != WebCL.SUCCESS) {
if (err != webcl.SUCCESS) {
log("Failed to setup compute kernel! Error " + err);

@@ -414,3 +402,3 @@ return err;

return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -445,3 +433,3 @@

alert("Error: Failed to build program executable!\n"
+ ComputeProgram.getBuildInfo(ComputeDeviceId, WebCL.PROGRAM_BUILD_LOG));
+ ComputeProgram.getBuildInfo(ComputeDeviceId, webcl.PROGRAM_BUILD_LOG));
return -1;

@@ -462,8 +450,8 @@ }

}
return WebCL.SUCCESS;
return webcl.SUCCESS;
}
function resetKernelArgs(image_width, image_height, r, scale) {
log('Reset kernel args to image ' + image_width + "x" + image_height + " r="
+ r + " scale=" + scale);
// log('Reset kernel args to image ' + image_width + "x" + image_height + " r="
// + r + " scale=" + scale);

@@ -475,7 +463,7 @@ // set the kernel args

ckBoxRowsTex.setArg(1, ComputeBufTemp);
ckBoxRowsTex.setArg(2, RowSampler, WebCL.type.SAMPLER);
ckBoxRowsTex.setArg(3, image_width, WebCL.type.INT);
ckBoxRowsTex.setArg(4, image_height, WebCL.type.INT);
ckBoxRowsTex.setArg(5, r, WebCL.type.INT);
ckBoxRowsTex.setArg(6, scale, WebCL.type.FLOAT);
ckBoxRowsTex.setArg(2, RowSampler);
ckBoxRowsTex.setArg(3, new Int32Array([image_width]));
ckBoxRowsTex.setArg(4, new Int32Array([image_height]));
ckBoxRowsTex.setArg(5, new Int32Array([r]));
ckBoxRowsTex.setArg(6, new Float32Array([scale]));
} catch (err) {

@@ -490,6 +478,6 @@ alert("Failed to set row kernel args! " + err);

ckBoxColumns.setArg(1, ComputePBO);
ckBoxColumns.setArg(2, image_width, WebCL.type.INT);
ckBoxColumns.setArg(3, image_height, WebCL.type.INT);
ckBoxColumns.setArg(4, r, WebCL.type.INT);
ckBoxColumns.setArg(5, scale, WebCL.type.FLOAT);
ckBoxColumns.setArg(2, new Int32Array([image_width]));
ckBoxColumns.setArg(3, new Int32Array([image_height]));
ckBoxColumns.setArg(4, new Int32Array([r]));
ckBoxColumns.setArg(5, new Float32Array([scale]));
} catch (err) {

@@ -503,6 +491,6 @@ alert("Failed to set column kernel args! " + err);

MaxWorkGroupSize = ckBoxRowsTex.getWorkGroupInfo(ComputeDeviceId,
WebCL.KERNEL_WORK_GROUP_SIZE);
webcl.KERNEL_WORK_GROUP_SIZE);
log(" MaxWorkGroupSize: " + MaxWorkGroupSize);
return WebCL.SUCCESS;
// log(" MaxWorkGroupSize: " + MaxWorkGroupSize);
return webcl.SUCCESS;
}

@@ -514,9 +502,10 @@

// 2D Image (Texture) on device
var InputFormat = {
order : WebCL.RGBA,
data_type : WebCL.UNSIGNED_INT8,
size: [ image.width, image.height ],
rowPitch: image.pitch
var InputFormat= {
channelOrder : webcl.RGBA,
channelType : webcl.UNSIGNED_INT8,
width : image.width,
height : image.height,
rowPitch : image.pitch
};
ComputeTexture = ComputeContext.createImage(WebCL.MEM_READ_ONLY | WebCL.MEM_USE_HOST_PTR, InputFormat, image);
ComputeTexture = ComputeContext.createImage(webcl.MEM_READ_ONLY | webcl.MEM_USE_HOST_PTR, InputFormat, image);
if (!ComputeTexture) {

@@ -527,3 +516,3 @@ alert("Error: Failed to create a Image2D on device");

RowSampler = ComputeContext.createSampler(false, WebCL.ADDRESS_CLAMP, WebCL.FILTER_NEAREST);
RowSampler = ComputeContext.createSampler(false, webcl.ADDRESS_CLAMP, webcl.FILTER_NEAREST);
if (!RowSampler) {

@@ -535,3 +524,3 @@ alert("Error: Failed to create a row sampler");

// Allocate the OpenCL intermediate and result buffer memory objects on the device GMEM
ComputeBufTemp = ComputeContext.createBuffer(WebCL.MEM_READ_WRITE, image.szBuffBytes);
ComputeBufTemp = ComputeContext.createBuffer(webcl.MEM_READ_WRITE, image.szBuffBytes);
if (!ComputeBufTemp) {

@@ -542,3 +531,3 @@ alert("Error: Failed to create temporary buffer");

return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -599,3 +588,3 @@

//DrawText(TextOffset[0], TextOffset[1], 1, (Animated == 0) ? "Press space to animate" : " ");
return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -610,3 +599,3 @@

function keydown(evt) {
log('process key: ' + evt.which);
// log('process key: ' + evt.which);
var oldr = iRadius;

@@ -650,3 +639,3 @@

ComputeCommands.finish();
// Update the texture from the pbo

@@ -660,3 +649,3 @@ gl.bindTexture(gl.TEXTURE_2D, TextureId);

return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -666,3 +655,3 @@

// Setup Kernel Args
ckBoxColumns.setArg(1, cmOutputBuffer, WebCL.type.MEM);
ckBoxColumns.setArg(1, cmOutputBuffer);

@@ -672,5 +661,11 @@ // 2D Image (Texture)

var TexRegion = [ image.width, image.height, 1 ]; // Size of texture region to operate on
ComputeCommands.enqueueWriteImage(ComputeTexture, WebCL.TRUE, TexOrigin,
TexRegion, 0, 0, image);
try {
ComputeCommands.enqueueWriteImage(ComputeTexture, webcl.TRUE, TexOrigin,
TexRegion, 0, image);
}
catch(ex) {
log("Error enqueuing image")
log(ex.name)
log(ex.stack)
}
// Set global and local work sizes for row kernel

@@ -681,3 +676,3 @@ var local = [ uiNumOutputPix, 1 ];

try {
ComputeCommands.enqueueNDRangeKernel(ckBoxRowsTex, null, global, local);
ComputeCommands.enqueueNDRangeKernel(ckBoxRowsTex, 2, null, global, local);
} catch (err) {

@@ -693,3 +688,3 @@ alert("Failed to enqueue row kernel! " + err);

try {
ComputeCommands.enqueueNDRangeKernel(ckBoxColumns, null, global, local);
ComputeCommands.enqueueNDRangeKernel(ckBoxColumns, 2, null, global, local);
} catch (err) {

@@ -704,11 +699,11 @@ alert("Failed to enqueue column kernel! " + err);

image = new Image();
image.onload=function() {
image.onload=function() {
console.log("Loaded image: " + image.src);
log("Image Width = " + image.width + ", Height = " + image.height + ", bpp = 32");
log("Image Width = " + image.width + ", Height = " + image.height + ", bpp = "+image.pitch);
image.szBuffBytes = image.height * image.pitch;
Width=image.width;
Height=image.height;
// init window
if(initialize(use_gpu)==WebCL.SUCCESS) {
if(initialize(use_gpu)==webcl.SUCCESS) {
function update() {

@@ -715,0 +710,0 @@ display();

@@ -29,3 +29,3 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
clu = require('../lib/clUtils');

@@ -35,17 +35,19 @@ util = require('util');

}
else
webcl = window.webcl;
//list of platforms
log("OpenCL SW Info:\n");
var platforms=WebCL.getPlatforms();
var platforms=webcl.getPlatforms();
console.log('Found '+platforms.length+' plaforms');
platforms.forEach(function(p) {
//log(" Plaftorm ID: 0x"+p.getID().toString(16));
log(" PLATFORM_NAME: \t"+p.getInfo(WebCL.PLATFORM_NAME));
log(" PLATFORM_PROFILE: \t"+p.getInfo(WebCL.PLATFORM_PROFILE));
log(" PLATFORM_VERSION: \t"+p.getInfo(WebCL.PLATFORM_VERSION));
log(" PLATFORM_VENDOR: \t"+p.getInfo(WebCL.PLATFORM_VENDOR));
log(" PLATFORM_NAME: \t"+p.getInfo(webcl.PLATFORM_NAME));
log(" PLATFORM_PROFILE: \t"+p.getInfo(webcl.PLATFORM_PROFILE));
log(" PLATFORM_VERSION: \t"+p.getInfo(webcl.PLATFORM_VERSION));
log(" PLATFORM_VENDOR: \t"+p.getInfo(webcl.PLATFORM_VENDOR));
// PLATFORM_EXTENSIONS: get platform extensions, and if any then parse & log the string onto separate lines
log(" PLATFORM_EXTENSIONS:");
var platform_ext_string=p.getInfo(WebCL.PLATFORM_EXTENSIONS);
var platform_ext_string=p.getInfo(webcl.PLATFORM_EXTENSIONS);
if (platform_ext_string.length > 0)

@@ -64,7 +66,7 @@ {

log("OpenCL Device Info:\n");
var devices = p.getDevices(WebCL.DEVICE_TYPE_ALL);
var devices = p.getDevices(webcl.DEVICE_TYPE_ALL);
log('Found '+devices.length+' devices');
devices.forEach(function(device) {
log(" ---------------------------------");
log(' Device: '+device.getInfo(WebCL.DEVICE_NAME));
log(' Device: '+device.getInfo(webcl.DEVICE_NAME));
log(" ---------------------------------");

@@ -76,5 +78,3 @@ printDeviceInfo(device);

try {
context = WebCL.createContext({
devices: device,
platform: p} );
context = webcl.createContext(device);
}

@@ -91,7 +91,7 @@ catch(ex) {

var ctxDevices=context.getInfo(WebCL.CONTEXT_DEVICES);
var ctxDevices=context.getInfo(webcl.CONTEXT_DEVICES);
// Determine and show image format support
// 2D
ImageFormats=context.getSupportedImageFormats(WebCL.MEM_READ_ONLY, WebCL.MEM_OBJECT_IMAGE2D);
ImageFormats=context.getSupportedImageFormats(webcl.MEM_READ_ONLY, webcl.MEM_OBJECT_IMAGE2D);
uiNumSupportedFormats=ImageFormats.length;

@@ -106,4 +106,4 @@

log(clu.sprintf(" %-6u%-16s%-22s", (j + 1),
oclImageFormatString(ImageFormats[j].order),
oclImageFormatString(ImageFormats[j].data_type)));
oclImageFormatString(ImageFormats[j].channelOrder),
oclImageFormatString(ImageFormats[j].channelType)));
}

@@ -113,3 +113,3 @@ log("");

// 3D
ImageFormats=context.getSupportedImageFormats(WebCL.MEM_READ_ONLY, WebCL.MEM_OBJECT_IMAGE3D);
ImageFormats=context.getSupportedImageFormats(webcl.MEM_READ_ONLY, webcl.MEM_OBJECT_IMAGE3D);
uiNumSupportedFormats=ImageFormats.length;

@@ -124,4 +124,4 @@

log(clu.sprintf(" %-6u%-16s%-22s", (j + 1),
oclImageFormatString(ImageFormats[j].order),
oclImageFormatString(ImageFormats[j].data_type)));
oclImageFormatString(ImageFormats[j].channelOrder),
oclImageFormatString(ImageFormats[j].channelType)));
}

@@ -132,9 +132,11 @@ log("");

// Size of basic types
log(" size of char: \t"+WebCL.size.CHAR);
log(" size of short: \t"+WebCL.size.SHORT);
log(" size of int: \t"+WebCL.size.INT);
log(" size of long: \t"+WebCL.size.LONG);
log(" size of float: \t"+WebCL.size.FLOAT);
log(" size of double: \t"+WebCL.size.DOUBLE);
log(" size of half: \t"+WebCL.size.HALF);
log(" size of char: \t"+Int8Array.BYTES_PER_ELEMENT);
log(" size of short: \t"+Int16Array.BYTES_PER_ELEMENT);
log(" size of int: \t"+Int32Array.BYTES_PER_ELEMENT);
log(" size of long: \t"+Int32Array.BYTES_PER_ELEMENT);
log(" size of float: \t"+Float32Array.BYTES_PER_ELEMENT);
if(typeof Float64Array !== 'undefined')
log(" size of double: \t"+Float64Array.BYTES_PER_ELEMENT);
if(typeof Float16Array !== 'undefined')
log(" size of half: \t"+Float16Array.BYTES_PER_ELEMENT);
});

@@ -144,21 +146,21 @@

{
log(" DEVICE_NAME: \t\t\t"+device.getInfo(WebCL.DEVICE_NAME));
log(" DEVICE_VENDOR: \t\t\t"+device.getInfo(WebCL.DEVICE_VENDOR));
log(" DRIVER_VERSION: \t\t\t"+device.getInfo(WebCL.DRIVER_VERSION));
log(" DEVICE_VERSION: \t\t\t"+device.getInfo(WebCL.DEVICE_VERSION));
log(" DEVICE_PROFILE: \t\t\t"+device.getInfo(WebCL.DEVICE_PROFILE));
log(" DEVICE_PLATFORM: \t\t\t0x"+device.getInfo(WebCL.DEVICE_PLATFORM).toString(16));
log(" DEVICE_OPENCL_C_VERSION: \t\t"+device.getInfo(WebCL.DEVICE_OPENCL_C_VERSION));
var type=parseInt(device.getInfo(WebCL.DEVICE_TYPE));
log(" DEVICE_NAME: \t\t\t"+device.getInfo(webcl.DEVICE_NAME));
log(" DEVICE_VENDOR: \t\t\t"+device.getInfo(webcl.DEVICE_VENDOR));
log(" DRIVER_VERSION: \t\t\t"+device.getInfo(webcl.DRIVER_VERSION));
log(" DEVICE_VERSION: \t\t\t"+device.getInfo(webcl.DEVICE_VERSION));
log(" DEVICE_PROFILE: \t\t\t"+device.getInfo(webcl.DEVICE_PROFILE));
log(" DEVICE_PLATFORM: \t\t\t0x"+device.getInfo(webcl.DEVICE_PLATFORM).toString(16));
log(" DEVICE_OPENCL_C_VERSION: \t\t"+device.getInfo(webcl.DEVICE_OPENCL_C_VERSION));
var type=parseInt(device.getInfo(webcl.DEVICE_TYPE));
var type_strings=[];
if( type & WebCL.DEVICE_TYPE_CPU )
if( type & webcl.DEVICE_TYPE_CPU )
type_strings.push("cpu");
if( type & WebCL.DEVICE_TYPE_GPU )
if( type & webcl.DEVICE_TYPE_GPU )
type_strings.push("gpu");
if( type & WebCL.DEVICE_TYPE_ACCELERATOR )
if( type & webcl.DEVICE_TYPE_ACCELERATOR )
type_strings.push("accelerator");
if( type & WebCL.DEVICE_TYPE_DEFAULT )
if( type & webcl.DEVICE_TYPE_DEFAULT )
type_strings.push("default");
// FIXME: 1.2
//if( type & WebCL.DEVICE_TYPE_CUSTOM )
//if( type & webcl.DEVICE_TYPE_CUSTOM )
// type_strings.push("custom");

@@ -168,58 +170,58 @@ log(" DEVICE_TYPE:\t\t\t"+type_strings.join(" "));

var compute_units=0;
log(" DEVICE_MAX_COMPUTE_UNITS:\t\t"+(compute_units=device.getInfo(WebCL.DEVICE_MAX_COMPUTE_UNITS)));
log(" DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t"+device.getInfo(WebCL.DEVICE_MAX_WORK_ITEM_DIMENSIONS));
log(" DEVICE_MAX_COMPUTE_UNITS:\t\t"+(compute_units=device.getInfo(webcl.DEVICE_MAX_COMPUTE_UNITS)));
log(" DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t"+device.getInfo(webcl.DEVICE_MAX_WORK_ITEM_DIMENSIONS));
var workitem_sizes=device.getInfo(WebCL.DEVICE_MAX_WORK_ITEM_SIZES);
var workitem_sizes=device.getInfo(webcl.DEVICE_MAX_WORK_ITEM_SIZES);
log(" DEVICE_MAX_WORK_ITEM_SIZES:\t"+workitem_sizes.join(" / "));
log(" DEVICE_MAX_WORK_GROUP_SIZE:\t"+device.getInfo(WebCL.DEVICE_MAX_WORK_GROUP_SIZE));
log(" DEVICE_MAX_CLOCK_FREQUENCY:\t"+device.getInfo(WebCL.DEVICE_MAX_CLOCK_FREQUENCY)+" MHz");
log(" DEVICE_ADDRESS_BITS:\t\t"+device.getInfo(WebCL.DEVICE_ADDRESS_BITS));
log(" DEVICE_MAX_MEM_ALLOC_SIZE:\t\t"+(device.getInfo(WebCL.DEVICE_MAX_MEM_ALLOC_SIZE) / (1024 * 1024))+" MBytes");
log(" DEVICE_GLOBAL_MEM_SIZE:\t\t"+(device.getInfo(WebCL.DEVICE_GLOBAL_MEM_SIZE) / (1024 * 1024))+" MBytes");
log(" DEVICE_ERROR_CORRECTION_SUPPORT:\t"+(device.getInfo(WebCL.DEVICE_ERROR_CORRECTION_SUPPORT) == WebCL.TRUE ? "yes" : "no"));
log(" DEVICE_MAX_WORK_GROUP_SIZE:\t"+device.getInfo(webcl.DEVICE_MAX_WORK_GROUP_SIZE));
log(" DEVICE_MAX_CLOCK_FREQUENCY:\t"+device.getInfo(webcl.DEVICE_MAX_CLOCK_FREQUENCY)+" MHz");
log(" DEVICE_ADDRESS_BITS:\t\t"+device.getInfo(webcl.DEVICE_ADDRESS_BITS));
log(" DEVICE_MAX_MEM_ALLOC_SIZE:\t\t"+(device.getInfo(webcl.DEVICE_MAX_MEM_ALLOC_SIZE) / (1024 * 1024))+" MBytes");
log(" DEVICE_GLOBAL_MEM_SIZE:\t\t"+(device.getInfo(webcl.DEVICE_GLOBAL_MEM_SIZE) / (1024 * 1024))+" MBytes");
log(" DEVICE_ERROR_CORRECTION_SUPPORT:\t"+(device.getInfo(webcl.DEVICE_ERROR_CORRECTION_SUPPORT) == webcl.TRUE ? "yes" : "no"));
// DEVICE_LOCAL_MEM_TYPE
var local_mem_type=device.getInfo(WebCL.DEVICE_LOCAL_MEM_TYPE);
if( cache_type === WebCL.NONE )
var local_mem_type=device.getInfo(webcl.DEVICE_LOCAL_MEM_TYPE);
if( cache_type === webcl.NONE )
log(" DEVICE_LOCAL_MEM_TYPE:\t\tNONE");
if( cache_type === WebCL.LOCAL )
if( cache_type === webcl.LOCAL )
log(" DEVICE_LOCAL_MEM_TYPE:\t\tLOCAL");
if( cache_type === WebCL.GLOBAL )
if( cache_type === webcl.GLOBAL )
log(" DEVICE_LOCAL_MEM_TYPE:\t\tGLOBAL");
log(" DEVICE_LOCAL_MEM_SIZE:\t\t"+(device.getInfo(WebCL.DEVICE_LOCAL_MEM_SIZE) / 1024)+" KBytes");
log(" DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t"+(device.getInfo(WebCL.DEVICE_MAX_CONSTANT_BUFFER_SIZE) / 1024)+" KBytes");
log(" DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t"+(device.getInfo(WebCL.DEVICE_MAX_CONSTANT_BUFFER_SIZE) / 1024)+" KBytes");
log(" DEVICE_LOCAL_MEM_SIZE:\t\t"+(device.getInfo(webcl.DEVICE_LOCAL_MEM_SIZE) / 1024)+" KBytes");
log(" DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t"+(device.getInfo(webcl.DEVICE_MAX_CONSTANT_BUFFER_SIZE) / 1024)+" KBytes");
log(" DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t"+(device.getInfo(webcl.DEVICE_MAX_CONSTANT_BUFFER_SIZE) / 1024)+" KBytes");
log(" DEVICE_MAX_SAMPLERS:\t"+device.getInfo(WebCL.DEVICE_MAX_SAMPLERS));
log(" DEVICE_MAX_PARAMETER_SIZE:\t"+device.getInfo(WebCL.DEVICE_MAX_PARAMETER_SIZE));
log(" DEVICE_MEM_BASE_ADDR_ALIGN:\t"+device.getInfo(WebCL.DEVICE_MEM_BASE_ADDR_ALIGN));
log(" DEVICE_MIN_DATA_TYPE_ALIGN_SIZE:\t"+device.getInfo(WebCL.DEVICE_MIN_DATA_TYPE_ALIGN_SIZE));
log(" DEVICE_MAX_SAMPLERS:\t"+device.getInfo(webcl.DEVICE_MAX_SAMPLERS));
log(" DEVICE_MAX_PARAMETER_SIZE:\t"+device.getInfo(webcl.DEVICE_MAX_PARAMETER_SIZE));
log(" DEVICE_MEM_BASE_ADDR_ALIGN:\t"+device.getInfo(webcl.DEVICE_MEM_BASE_ADDR_ALIGN));
log(" DEVICE_MIN_DATA_TYPE_ALIGN_SIZE:\t"+device.getInfo(webcl.DEVICE_MIN_DATA_TYPE_ALIGN_SIZE));
var cache_type=device.getInfo(WebCL.DEVICE_GLOBAL_MEM_CACHE_TYPE);
if( cache_type === WebCL.NONE )
var cache_type=device.getInfo(webcl.DEVICE_GLOBAL_MEM_CACHE_TYPE);
if( cache_type === webcl.NONE )
log(" DEVICE_GLOBAL_MEM_CACHE_TYPE:\t\tNONE");
if( cache_type === WebCL.READ_ONLY_CACHE )
if( cache_type === webcl.READ_ONLY_CACHE )
log(" DEVICE_GLOBAL_MEM_CACHE_TYPE:\t\tREAD_ONLY_CACHE");
if( cache_type === WebCL.READ_WRITE_CACHE )
if( cache_type === webcl.READ_WRITE_CACHE )
log(" DEVICE_GLOBAL_MEM_CACHE_TYPE:\t\tREAD_WRITE_CACHE");
log(" DEVICE_GLOBAL_MEM_CACHE_SIZE:\t\t"+(device.getInfo(WebCL.DEVICE_GLOBAL_MEM_CACHE_SIZE) / (1024))+" KBytes");
log(" DEVICE_GLOBAL_MEM_CACHELINE_SIZE:\t\t"+device.getInfo(WebCL.DEVICE_GLOBAL_MEM_CACHELINE_SIZE)+" Bytes");
log(" DEVICE_GLOBAL_MEM_CACHE_SIZE:\t\t"+(device.getInfo(webcl.DEVICE_GLOBAL_MEM_CACHE_SIZE) / (1024))+" KBytes");
log(" DEVICE_GLOBAL_MEM_CACHELINE_SIZE:\t\t"+device.getInfo(webcl.DEVICE_GLOBAL_MEM_CACHELINE_SIZE)+" Bytes");
log(" DEVICE_MAX_CONSTANT_ARGS:\t"+device.getInfo(WebCL.DEVICE_MAX_CONSTANT_ARGS));
log(" DEVICE_HOST_UNIFIED_MEMORY:\t"+device.getInfo(WebCL.DEVICE_HOST_UNIFIED_MEMORY));
log(" DEVICE_PROFILING_TIMER_RESOLUTION:\t"+device.getInfo(WebCL.DEVICE_PROFILING_TIMER_RESOLUTION));
log(" DEVICE_ENDIAN_LITTLE:\t"+device.getInfo(WebCL.DEVICE_ENDIAN_LITTLE));
log(" DEVICE_MAX_CONSTANT_ARGS:\t"+device.getInfo(webcl.DEVICE_MAX_CONSTANT_ARGS));
log(" DEVICE_HOST_UNIFIED_MEMORY:\t"+device.getInfo(webcl.DEVICE_HOST_UNIFIED_MEMORY));
log(" DEVICE_PROFILING_TIMER_RESOLUTION:\t"+device.getInfo(webcl.DEVICE_PROFILING_TIMER_RESOLUTION));
log(" DEVICE_ENDIAN_LITTLE:\t"+device.getInfo(webcl.DEVICE_ENDIAN_LITTLE));
log(" DEVICE_AVAILABLE:\t"+device.getInfo(WebCL.DEVICE_AVAILABLE));
log(" DEVICE_COMPILER_AVAILABLE:\t"+device.getInfo(WebCL.DEVICE_COMPILER_AVAILABLE));
log(" DEVICE_AVAILABLE:\t"+device.getInfo(webcl.DEVICE_AVAILABLE));
log(" DEVICE_COMPILER_AVAILABLE:\t"+device.getInfo(webcl.DEVICE_COMPILER_AVAILABLE));
// DEVICE_EXECUTION_CAPABILITIES
var execution_capabilities=device.getInfo(WebCL.DEVICE_EXECUTION_CAPABILITIES);
var execution_capabilities=device.getInfo(webcl.DEVICE_EXECUTION_CAPABILITIES);
var execution_capabilities_strings=[];
if( execution_capabilities & WebCL.EXEC_KERNEL )
if( execution_capabilities & webcl.EXEC_KERNEL )
execution_capabilities_strings.push("kernel");
if( execution_capabilities & WebCL.EXEC_NATIVE_KERNEL )
if( execution_capabilities & webcl.EXEC_NATIVE_KERNEL )
execution_capabilities_strings.push("native-kernel");

@@ -229,7 +231,7 @@ log(" DEVICE_EXECUTION_CAPABILITIES:\t\t"+execution_capabilities_strings.join(" "));

// DEVICE_QUEUE_PROPERTIES
var queue_properties=device.getInfo(WebCL.DEVICE_QUEUE_PROPERTIES);
var queue_properties=device.getInfo(webcl.DEVICE_QUEUE_PROPERTIES);
var queue_properties_strings=[];
if( queue_properties & WebCL.QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE )
if( queue_properties & webcl.QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE )
queue_properties_strings.push("out-of-order-exec-mode");
if( queue_properties & WebCL.QUEUE_PROFILING_ENABLE )
if( queue_properties & webcl.QUEUE_PROFILING_ENABLE )
queue_properties_strings.push("profiling");

@@ -239,5 +241,5 @@ log(" DEVICE_QUEUE_PROPERTIES:\t\t"+queue_properties_strings.join(" "));

// image support
log(" DEVICE_IMAGE_SUPPORT:\t\t"+device.getInfo(WebCL.DEVICE_IMAGE_SUPPORT));
log(" DEVICE_MAX_READ_IMAGE_ARGS:\t"+device.getInfo(WebCL.DEVICE_MAX_READ_IMAGE_ARGS));
log(" DEVICE_MAX_WRITE_IMAGE_ARGS:\t"+device.getInfo(WebCL.DEVICE_MAX_WRITE_IMAGE_ARGS));
log(" DEVICE_IMAGE_SUPPORT:\t\t"+device.getInfo(webcl.DEVICE_IMAGE_SUPPORT));
log(" DEVICE_MAX_READ_IMAGE_ARGS:\t"+device.getInfo(webcl.DEVICE_MAX_READ_IMAGE_ARGS));
log(" DEVICE_MAX_WRITE_IMAGE_ARGS:\t"+device.getInfo(webcl.DEVICE_MAX_WRITE_IMAGE_ARGS));

@@ -249,15 +251,15 @@ function fp_config_info(type, name)

var fp_config_strings=[];
if( fp_config & WebCL.FP_DENORM )
if( fp_config & webcl.FP_DENORM )
fp_config_strings.push("denorms");
if( fp_config & WebCL.FP_INF_NAN )
if( fp_config & webcl.FP_INF_NAN )
fp_config_strings.push("INF-quietNaNs");
if( fp_config & WebCL.FP_ROUND_TO_NEAREST )
if( fp_config & webcl.FP_ROUND_TO_NEAREST )
fp_config_strings.push("round-to-nearest");
if( fp_config & WebCL.FP_ROUND_TO_ZERO )
if( fp_config & webcl.FP_ROUND_TO_ZERO )
fp_config_strings.push("round-to-zero");
if( fp_config & WebCL.FP_ROUND_TO_INF )
if( fp_config & webcl.FP_ROUND_TO_INF )
fp_config_strings.push("round-to-inf");
if( fp_config & WebCL.FP_FMA )
if( fp_config & webcl.FP_FMA )
fp_config_strings.push("fma");
if( fp_config & WebCL.FP_SOFT_FLOAT )
if( fp_config & webcl.FP_SOFT_FLOAT )
fp_config_strings.push("soft-float");

@@ -268,3 +270,3 @@ log(" "+name+":\t\t"+fp_config_strings.join(" "));

try {
fp_config_info(WebCL.DEVICE_HALF_FP_CONFIG, "DEVICE_HALF_FP_CONFIG");
fp_config_info(webcl.DEVICE_HALF_FP_CONFIG, "DEVICE_HALF_FP_CONFIG");
}

@@ -275,6 +277,6 @@ catch(ex) {

fp_config_info(WebCL.DEVICE_SINGLE_FP_CONFIG, "DEVICE_SINGLE_FP_CONFIG");
fp_config_info(webcl.DEVICE_SINGLE_FP_CONFIG, "DEVICE_SINGLE_FP_CONFIG");
try {
fp_config_info(WebCL.DEVICE_DOUBLE_FP_CONFIG, "DEVICE_DOUBLE_FP_CONFIG");
fp_config_info(webcl.DEVICE_DOUBLE_FP_CONFIG, "DEVICE_DOUBLE_FP_CONFIG");
}

@@ -286,11 +288,11 @@ catch(ex) {

log("\n DEVICE_IMAGE <dim>");
log("\t\t\t\t\t2D_MAX_WIDTH\t "+device.getInfo(WebCL.DEVICE_IMAGE2D_MAX_WIDTH));
log("\t\t\t\t\t2D_MAX_HEIGHT\t "+device.getInfo(WebCL.DEVICE_IMAGE2D_MAX_HEIGHT));
log("\t\t\t\t\t3D_MAX_WIDTH\t "+device.getInfo(WebCL.DEVICE_IMAGE3D_MAX_WIDTH));
log("\t\t\t\t\t3D_MAX_HEIGHT\t "+device.getInfo(WebCL.DEVICE_IMAGE3D_MAX_HEIGHT));
log("\t\t\t\t\t3D_MAX_DEPTH\t "+device.getInfo(WebCL.DEVICE_IMAGE3D_MAX_DEPTH));
log("\t\t\t\t\t2D_MAX_WIDTH\t "+device.getInfo(webcl.DEVICE_IMAGE2D_MAX_WIDTH));
log("\t\t\t\t\t2D_MAX_HEIGHT\t "+device.getInfo(webcl.DEVICE_IMAGE2D_MAX_HEIGHT));
log("\t\t\t\t\t3D_MAX_WIDTH\t "+device.getInfo(webcl.DEVICE_IMAGE3D_MAX_WIDTH));
log("\t\t\t\t\t3D_MAX_HEIGHT\t "+device.getInfo(webcl.DEVICE_IMAGE3D_MAX_HEIGHT));
log("\t\t\t\t\t3D_MAX_DEPTH\t "+device.getInfo(webcl.DEVICE_IMAGE3D_MAX_DEPTH));
// DEVICE_EXTENSIONS: get device extensions, and if any then parse & log the string onto separate lines
log("\n DEVICE_EXTENSIONS:");
var device_string=device.getInfo(WebCL.DEVICE_EXTENSIONS);
var device_string=device.getInfo(webcl.DEVICE_EXTENSIONS);
var nv_device_attibute_query=false;

@@ -311,12 +313,12 @@ if (device_string.length > 0)

{
var compute_capability_major=device.getInfo(WebCL.DEVICE_COMPUTE_CAPABILITY_MAJOR_NV);
var compute_capability_minor=device.getInfo(WebCL.DEVICE_COMPUTE_CAPABILITY_MINOR_NV);
var compute_capability_major=device.getInfo(webcl.DEVICE_COMPUTE_CAPABILITY_MAJOR_NV);
var compute_capability_minor=device.getInfo(webcl.DEVICE_COMPUTE_CAPABILITY_MINOR_NV);
log("\n DEVICE_COMPUTE_CAPABILITY_NV:\t"+compute_capability_major+'.'+compute_capability_minor);
log(" NUMBER OF MULTIPROCESSORS:\t\t"+compute_units); // this is the same value reported by DEVICE_MAX_COMPUTE_UNITS
log(" NUMBER OF CUDA CORES:\t\t\t"+NV_ConvertSMVer2Cores(compute_capability_major, compute_capability_minor) * compute_units);
log(" DEVICE_REGISTERS_PER_BLOCK_NV:\t"+device.getInfo(WebCL.DEVICE_REGISTERS_PER_BLOCK_NV));
log(" DEVICE_WARP_SIZE_NV:\t\t"+device.getInfo(WebCL.DEVICE_WARP_SIZE_NV));
log(" DEVICE_GPU_OVERLAP_NV:\t\t"+(device.getInfo(WebCL.DEVICE_GPU_OVERLAP_NV) == WebCL.TRUE ? "TRUE" : "FALSE"));
log(" DEVICE_KERNEL_EXEC_TIMEOUT_NV:\t"+(device.getInfo(WebCL.DEVICE_KERNEL_EXEC_TIMEOUT_NV) == WebCL.TRUE ? "TRUE" : "FALSE"));
log(" DEVICE_INTEGRATED_MEMORY_NV:\t"+(device.getInfo(WebCL.DEVICE_INTEGRATED_MEMORY_NV) == WebCL.TRUE ? "TRUE" : "FALSE"));
log(" DEVICE_REGISTERS_PER_BLOCK_NV:\t"+device.getInfo(webcl.DEVICE_REGISTERS_PER_BLOCK_NV));
log(" DEVICE_WARP_SIZE_NV:\t\t"+device.getInfo(webcl.DEVICE_WARP_SIZE_NV));
log(" DEVICE_GPU_OVERLAP_NV:\t\t"+(device.getInfo(webcl.DEVICE_GPU_OVERLAP_NV) == webcl.TRUE ? "TRUE" : "FALSE"));
log(" DEVICE_KERNEL_EXEC_TIMEOUT_NV:\t"+(device.getInfo(webcl.DEVICE_KERNEL_EXEC_TIMEOUT_NV) == webcl.TRUE ? "TRUE" : "FALSE"));
log(" DEVICE_INTEGRATED_MEMORY_NV:\t"+(device.getInfo(webcl.DEVICE_INTEGRATED_MEMORY_NV) == webcl.TRUE ? "TRUE" : "FALSE"));
}

@@ -327,8 +329,8 @@

var vec_width= [
device.getInfo(WebCL.DEVICE_PREFERRED_VECTOR_WIDTH_CHAR),
device.getInfo(WebCL.DEVICE_PREFERRED_VECTOR_WIDTH_SHORT),
device.getInfo(WebCL.DEVICE_PREFERRED_VECTOR_WIDTH_INT),
device.getInfo(WebCL.DEVICE_PREFERRED_VECTOR_WIDTH_LONG),
device.getInfo(WebCL.DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT),
device.getInfo(WebCL.DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE),
device.getInfo(webcl.DEVICE_PREFERRED_VECTOR_WIDTH_CHAR),
device.getInfo(webcl.DEVICE_PREFERRED_VECTOR_WIDTH_SHORT),
device.getInfo(webcl.DEVICE_PREFERRED_VECTOR_WIDTH_INT),
device.getInfo(webcl.DEVICE_PREFERRED_VECTOR_WIDTH_LONG),
device.getInfo(webcl.DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT),
device.getInfo(webcl.DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE),
];

@@ -340,8 +342,8 @@ log('\tCHAR '+vec_width[0]+', SHORT '+vec_width[1]+', INT '+vec_width[2]+', LONG '+vec_width[3]+

var vec_native_width= [
device.getInfo(WebCL.DEVICE_NATIVE_VECTOR_WIDTH_CHAR),
device.getInfo(WebCL.DEVICE_NATIVE_VECTOR_WIDTH_SHORT),
device.getInfo(WebCL.DEVICE_NATIVE_VECTOR_WIDTH_INT),
device.getInfo(WebCL.DEVICE_NATIVE_VECTOR_WIDTH_LONG),
device.getInfo(WebCL.DEVICE_NATIVE_VECTOR_WIDTH_FLOAT),
device.getInfo(WebCL.DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE),
device.getInfo(webcl.DEVICE_NATIVE_VECTOR_WIDTH_CHAR),
device.getInfo(webcl.DEVICE_NATIVE_VECTOR_WIDTH_SHORT),
device.getInfo(webcl.DEVICE_NATIVE_VECTOR_WIDTH_INT),
device.getInfo(webcl.DEVICE_NATIVE_VECTOR_WIDTH_LONG),
device.getInfo(webcl.DEVICE_NATIVE_VECTOR_WIDTH_FLOAT),
device.getInfo(webcl.DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE),
];

@@ -382,29 +384,29 @@ log('\tCHAR '+vec_native_width[0]+', SHORT '+vec_native_width[1]+', INT '+vec_native_width[2]+

// channel_order
if (uiImageFormat == WebCL.R)return "R";
if (uiImageFormat == WebCL.A)return "A";
if (uiImageFormat == WebCL.RG)return "RG";
if (uiImageFormat == WebCL.RA)return "RA";
if (uiImageFormat == WebCL.RGB)return "RGB";
if (uiImageFormat == WebCL.RGBA)return "RGBA";
if (uiImageFormat == WebCL.BGRA)return "BGRA";
if (uiImageFormat == WebCL.ARGB)return "ARGB";
if (uiImageFormat == WebCL.INTENSITY)return "INTENSITY";
if (uiImageFormat == WebCL.LUMINANCE)return "LUMINANCE";
if (uiImageFormat == webcl.R)return "R";
if (uiImageFormat == webcl.A)return "A";
if (uiImageFormat == webcl.RG)return "RG";
if (uiImageFormat == webcl.RA)return "RA";
if (uiImageFormat == webcl.RGB)return "RGB";
if (uiImageFormat == webcl.RGBA)return "RGBA";
if (uiImageFormat == webcl.BGRA)return "BGRA";
if (uiImageFormat == webcl.ARGB)return "ARGB";
if (uiImageFormat == webcl.INTENSITY)return "INTENSITY";
if (uiImageFormat == webcl.LUMINANCE)return "LUMINANCE";
// channel_type
if (uiImageFormat == WebCL.SNORM_INT8)return "SNORM_INT8";
if (uiImageFormat == WebCL.SNORM_INT16)return "SNORM_INT16";
if (uiImageFormat == WebCL.UNORM_INT8)return "UNORM_INT8";
if (uiImageFormat == WebCL.UNORM_INT16)return "UNORM_INT16";
if (uiImageFormat == WebCL.UNORM_SHORT_565)return "UNORM_SHORT_565";
if (uiImageFormat == WebCL.UNORM_SHORT_555)return "UNORM_SHORT_555";
if (uiImageFormat == WebCL.UNORM_INT_101010)return "UNORM_INT_101010";
if (uiImageFormat == WebCL.SIGNED_INT8)return "SIGNED_INT8";
if (uiImageFormat == WebCL.SIGNED_INT16)return "SIGNED_INT16";
if (uiImageFormat == WebCL.SIGNED_INT32)return "SIGNED_INT32";
if (uiImageFormat == WebCL.UNSIGNED_INT8)return "UNSIGNED_INT8";
if (uiImageFormat == WebCL.UNSIGNED_INT16)return "UNSIGNED_INT16";
if (uiImageFormat == WebCL.UNSIGNED_INT32)return "UNSIGNED_INT32";
if (uiImageFormat == WebCL.HALF_FLOAT)return "HALF_FLOAT";
if (uiImageFormat == WebCL.FLOAT)return "FLOAT";
if (uiImageFormat == webcl.SNORM_INT8)return "SNORM_INT8";
if (uiImageFormat == webcl.SNORM_INT16)return "SNORM_INT16";
if (uiImageFormat == webcl.UNORM_INT8)return "UNORM_INT8";
if (uiImageFormat == webcl.UNORM_INT16)return "UNORM_INT16";
if (uiImageFormat == webcl.UNORM_SHORT_565)return "UNORM_SHORT_565";
if (uiImageFormat == webcl.UNORM_SHORT_555)return "UNORM_SHORT_555";
if (uiImageFormat == webcl.UNORM_INT_101010)return "UNORM_INT_101010";
if (uiImageFormat == webcl.SIGNED_INT8)return "SIGNED_INT8";
if (uiImageFormat == webcl.SIGNED_INT16)return "SIGNED_INT16";
if (uiImageFormat == webcl.SIGNED_INT32)return "SIGNED_INT32";
if (uiImageFormat == webcl.UNSIGNED_INT8)return "UNSIGNED_INT8";
if (uiImageFormat == webcl.UNSIGNED_INT16)return "UNSIGNED_INT16";
if (uiImageFormat == webcl.UNSIGNED_INT32)return "UNSIGNED_INT32";
if (uiImageFormat == webcl.HALF_FLOAT)return "HALF_FLOAT";
if (uiImageFormat == webcl.FLOAT)return "FLOAT";

@@ -411,0 +413,0 @@ // unknown constant

@@ -29,3 +29,3 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
clu = require('../lib/clUtils');

@@ -37,7 +37,9 @@ util = require("util"),

}
else
webcl = window.webcl;
//First check if the webcl extension is installed at all
if (WebCL == undefined) {
alert("Unfortunately your system does not support WebCL. " +
"Make sure that you have the WebCL extension installed.");
if (webcl == undefined) {
alert("Unfortunately your system does not support webcl. " +
"Make sure that you have the webcl extension installed.");
process.exit(-1);

@@ -65,42 +67,13 @@ }

//Pick platform
// var platformList=WebCL.getPlatforms();
// var platform=platformList[0];
// create GPU context for this platform
var context=WebCL.createContext({
deviceType: WebCL.DEVICE_TYPE_GPU,
// platform: platform
});
var context=webcl.createContext(webcl.DEVICE_TYPE_GPU);
// find the device for this context
var devices = context.getInfo(WebCL.CONTEXT_DEVICES);
if(!devices) {
alert("Error: Failed to retrieve compute devices for context!");
return -1;
}
var device_found=false;
var device;
for(var i=0,l=devices.length;i<l;++i )
{
var device_type=devices[i].getInfo(WebCL.DEVICE_TYPE);
if(device_type == WebCL.DEVICE_TYPE_GPU)
{
device = devices[i];
device_found = true;
break;
}
}
if(!device_found)
{
alert("Error: Failed to locate compute device!");
return -1;
}
var devices = context.getInfo(webcl.CONTEXT_DEVICES);
device=devices[0];
// Report the device vendor and device name
//
var vendor_name = device.getInfo(WebCL.DEVICE_VENDOR);
var device_name = device.getInfo(WebCL.DEVICE_NAME);
var vendor_name = device.getInfo(webcl.DEVICE_VENDOR);
var device_name = device.getInfo(webcl.DEVICE_NAME);

@@ -115,8 +88,14 @@ log("Connecting to: "+vendor_name+" "+device_name);

//Build program
program.build(device);
try {
program.build(device);
} catch (err) {
log('Error building program: ' + err);
log(program.getBuildInfo(device, webcl.PROGRAM_BUILD_LOG));
process.exit(-1);
}
// create device buffers
try {
cmPinnedBufIn = context.createBuffer(WebCL.MEM_READ_ONLY | WebCL.MEM_ALLOC_HOST_PTR, image.size);
cmPinnedBufOut = context.createBuffer(WebCL.MEM_WRITE_ONLY | WebCL.MEM_ALLOC_HOST_PTR, image.size);
cmPinnedBufIn = context.createBuffer(webcl.MEM_READ_ONLY | webcl.MEM_ALLOC_HOST_PTR, image.size);
cmPinnedBufOut = context.createBuffer(webcl.MEM_WRITE_ONLY | webcl.MEM_ALLOC_HOST_PTR, image.size);
}

@@ -133,10 +112,18 @@ catch(err) {

catch(err) {
console.log(program.getBuildInfo(device,WebCL.PROGRAM_BUILD_LOG));
console.log(program.getBuildInfo(device,webcl.PROGRAM_BUILD_LOG));
}
// Set the arguments to our compute kernel
var aints=new Int32Array(3);
aints.set([image.width, image.height, 0]);
try {
kernel.setArg(0, cmPinnedBufIn);
kernel.setArg(1, cmPinnedBufOut);
kernel.setArg(2, image.width, WebCL.type.UINT);
kernel.setArg(3, image.height, WebCL.type.UINT);
kernel.setArg(2, aints);
// kernel.setArg(3, aints.subarray(1));
}
catch(ex) {
log(ex);
process.exit(-1);
}

@@ -148,3 +135,3 @@ //Create command queue

// Get the maximum work group size for executing the kernel on the device
var localWS=[ kernel.getWorkGroupInfo(device, WebCL.KERNEL_WORK_GROUP_SIZE) ];
var localWS=[ kernel.getWorkGroupInfo(device, webcl.KERNEL_WORK_GROUP_SIZE) ];
var globalWS = [ localWS[0] * clu.DivUp(image.size, localWS[0]) ];

@@ -159,3 +146,3 @@

// Execute (enqueue) kernel
queue.enqueueNDRangeKernel(kernel,
queue.enqueueNDRangeKernel(kernel, 1,
null,

@@ -165,5 +152,5 @@ globalWS,

queue.enqueueReadBuffer(cmPinnedBufOut, false, 0, out.length, out);
queue.enqueueReadBuffer(cmPinnedBufOut, false, 0, out.length, out);
queue.finish(); //Finish all the operations
queue.finish(); //Finish all the operations

@@ -170,0 +157,0 @@ return out;

@@ -29,3 +29,3 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../../webcl');
webcl = require('../../webcl');
clu = require('../../lib/clUtils');

@@ -44,2 +44,4 @@ util = require('util');

}
else
webcl = window.webcl;

@@ -100,3 +102,3 @@ log = console.log;

// init WebCL
// init webcl
var compute=Compute();

@@ -103,0 +105,0 @@ try {

/*
* Compute contains all WebCL initializations and runtime for our kernel
* Compute contains all webcl initializations and runtime for our kernel
* that update a texture.

@@ -84,7 +84,11 @@ */

var clKernel = orig.getKernel();
var amu=new Float32Array(4); amu.set(mu);
var adiffuse=new Float32Array(4); adiffuse.set(diffuse);
var aeps=new Float32Array(1); aeps.set(Epsilon);
try {
// Set the Argument values for the row kernel
clKernel.setArg(2, mu, WebCL.type.FLOAT | WebCL.type.VEC4);
clKernel.setArg(3, diffuse, WebCL.type.FLOAT | WebCL.type.VEC4);
clKernel.setArg(4, Epsilon, WebCL.type.FLOAT);
clKernel.setArg(2, amu);
clKernel.setArg(3, adiffuse);
clKernel.setArg(4, aeps);
} catch (err) {

@@ -91,0 +95,0 @@ throw "Failed to set Julia kernel args! " + err;

/*
* Compute contains all WebCL initializations and runtime for our kernel
* Compute contains all webcl initializations and runtime for our kernel
* that update a texture.

@@ -10,3 +10,3 @@ */

var /* cl_device_id */ clDevice;
var /* cl_device_type */ clDeviceType = WebCL.DEVICE_TYPE_GPU;
var /* cl_device_type */ clDeviceType = webcl.DEVICE_TYPE_GPU;
var /* cl_image */ clTexture;

@@ -21,3 +21,3 @@ var /* cl_kernel */ clKernel;

/*
* Initialize WebCL context sharing WebGL context
* Initialize webcl context sharing WebGL context
*

@@ -39,12 +39,22 @@ * @param gl WebGLContext

// Pick platform
// var platformList = WebCL.getPlatforms();
// var platform = platformList[0];
var platformList = webcl.getPlatforms();
var platform = platformList[0];
var devices = platform.getDevices(clDeviceType ? webcl.DEVICE_TYPE_GPU : webcl.DEVICE_TYPE_DEFAULT);
clDevice=devices[0];
// make sure we use a discrete GPU
for(var i=0;i<devices.length;i++) {
var vendor=devices[i].getInfo(webcl.DEVICE_VENDOR);
// log('found vendor '+vendor+', is Intel? '+(vendor.indexOf('Intel')>=0))
if(vendor.indexOf('Intel')==-1)
clDevice=devices[i];
}
log('found '+devices.length+' devices, using device: '+clDevice.getInfo(webcl.DEVICE_NAME));
if(!clDevice.enableExtension('KHR_gl_sharing'))
throw new Error("Can NOT use GL sharing");
// create the OpenCL context
try {
clContext = WebCL.createContext({
deviceType: clDeviceType,
shareGroup: gl,
// platform: platform
});
clContext = webcl.createContext(gl, clDevice);
}

@@ -55,30 +65,2 @@ catch(err) {

var device_ids = clContext.getInfo(WebCL.CONTEXT_DEVICES);
if (!device_ids) {
throw "Error: Failed to retrieve compute devices for context!";
}
// check we have the right device type
var device_found = false;
for(var i=0,l=device_ids.length;i<l;++i ) {
device_type = device_ids[i].getInfo(WebCL.DEVICE_TYPE);
if (device_type == clDeviceType) {
clDevice = device_ids[i];
device_found = true;
break;
}
}
if (!device_found)
throw "Error: Failed to locate compute device!";
if (!clDevice.getInfo(WebCL.DEVICE_IMAGE_SUPPORT))
throw "Application requires images: Images not supported on this device.";
// get CL-GL extension
if(!clDevice.enableExtension("KHR_gl_sharing")) {
log("CL-GL not available!");
process.exit(1);
}
// Create a command queue

@@ -93,11 +75,11 @@ try {

// Report the device vendor and device name
var vendor_name = clDevice.getInfo(WebCL.DEVICE_VENDOR);
var device_name = clDevice.getInfo(WebCL.DEVICE_NAME);
var vendor_name = clDevice.getInfo(webcl.DEVICE_VENDOR);
var device_name = clDevice.getInfo(webcl.DEVICE_NAME);
log(" Connecting to " + vendor_name + " " + device_name);
log(" Global mem cache size: " + (clDevice.getInfo(WebCL.DEVICE_GLOBAL_MEM_CACHE_SIZE)/1024) + "kB " );
log(" Local mem size : " + (clDevice.getInfo(WebCL.DEVICE_LOCAL_MEM_SIZE)/1024) + "kB " );
log(" Max compute units : " + clDevice.getInfo(WebCL.DEVICE_MAX_COMPUTE_UNITS));
log(" Max work-item sizes : "+clDevice.getInfo(WebCL.DEVICE_MAX_WORK_ITEM_SIZES));
log(" Max work-group size : "+clDevice.getInfo(WebCL.DEVICE_MAX_WORK_GROUP_SIZE));
log(" Global mem cache size: " + (clDevice.getInfo(webcl.DEVICE_GLOBAL_MEM_CACHE_SIZE)/1024) + "kB " );
log(" Local mem size : " + (clDevice.getInfo(webcl.DEVICE_LOCAL_MEM_SIZE)/1024) + "kB " );
log(" Max compute units : " + clDevice.getInfo(webcl.DEVICE_MAX_COMPUTE_UNITS));
log(" Max work-item sizes : "+clDevice.getInfo(webcl.DEVICE_MAX_WORK_ITEM_SIZES));
log(" Max work-group size : "+clDevice.getInfo(webcl.DEVICE_MAX_WORK_GROUP_SIZE));

@@ -109,3 +91,3 @@ init_cl_buffers();

/*
* Initialize WebCL kernels
* Initialize webcl kernels
*/

@@ -156,3 +138,3 @@ function init_cl_kernels() {

throw "Error: Failed to build program executable!\n"
+ clProgram.getBuildInfo(clDevice, WebCL.PROGRAM_BUILD_LOG);
+ clProgram.getBuildInfo(clDevice, webcl.PROGRAM_BUILD_LOG);
}

@@ -169,7 +151,7 @@

// Get the device intrinsics for executing the kernel on the device
max_workgroup_size = clKernel.getWorkGroupInfo(clDevice, WebCL.KERNEL_WORK_GROUP_SIZE);
warp_size=clKernel.getWorkGroupInfo(clDevice, WebCL.KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE);
max_workgroup_size = clKernel.getWorkGroupInfo(clDevice, webcl.KERNEL_WORK_GROUP_SIZE);
warp_size=clKernel.getWorkGroupInfo(clDevice, webcl.KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE);
log(' max workgroup size: '+max_workgroup_size);
log(' local mem used : '+clKernel.getWorkGroupInfo(clDevice, WebCL.KERNEL_LOCAL_MEM_SIZE)+" bytes");
log(' private mem used : '+clKernel.getWorkGroupInfo(clDevice, WebCL.KERNEL_PRIVATE_MEM_SIZE)+" bytes");
log(' local mem used : '+clKernel.getWorkGroupInfo(clDevice, webcl.KERNEL_LOCAL_MEM_SIZE)+" bytes");
log(' private mem used : '+clKernel.getWorkGroupInfo(clDevice, webcl.KERNEL_PRIVATE_MEM_SIZE)+" bytes");
log(' warp size : '+warp_size);

@@ -192,3 +174,3 @@ }

clKernel.setArg(0, clTexture);
clKernel.setArg(1, time, WebCL.type.FLOAT);
clKernel.setArg(1, new Float32Array([time]));
} catch (err) {

@@ -200,3 +182,3 @@ throw "Failed to set kernel args! " + err;

/*
* Initialize WebCL buffers
* Initialize webcl buffers
*/

@@ -211,3 +193,3 @@ function init_cl_buffers() {

* @param gl WebGLContext
* @param glTexture WebGLTexture to share with WebCL
* @param glTexture WebGLTexture to share with webcl
*/

@@ -221,3 +203,3 @@ function configure_shared_data(gfx, glTexture) {

try {
clTexture = clContext.createFromGLTexture(WebCL.MEM_WRITE_ONLY,
clTexture = clContext.createFromGLTexture(webcl.MEM_WRITE_ONLY,
gl.TEXTURE_2D, 0, glTexture);

@@ -254,3 +236,3 @@ } catch (ex) {

try {
clQueue.enqueueNDRangeKernel(clKernel, null, global, local);
clQueue.enqueueNDRangeKernel(clKernel, 2, null, global, local);
} catch (err) {

@@ -257,0 +239,0 @@ throw "Failed to enqueue kernel! " + err;

@@ -232,3 +232,3 @@ var nodejs = (typeof window === 'undefined');

ATB.Init();
ATB.Define(" GLOBAL help='WebGL interop with WebCL' "); // Message added to the help bar.
ATB.Define(" GLOBAL help='WebGL interop with webcl' "); // Message added to the help bar.
ATB.WindowSize(canvas.width, canvas.height);

@@ -235,0 +235,0 @@

@@ -29,3 +29,3 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
clu = require('../lib/clUtils');

@@ -42,2 +42,4 @@ util = require('util');

}
else
webcl = window.webcl;

@@ -47,6 +49,6 @@ requestAnimationFrame = document.requestAnimationFrame;

//First check if the webcl extension is installed at all
if (WebCL == undefined) {
alert("Unfortunately your system does not support WebCL. "
+ "Make sure that you have the WebCL extension installed.");
return;
if (webcl == undefined) {
alert("Unfortunately your system does not support webcl. "
+ "Make sure that you have the webcl extension installed.");
process.exit(-1);
}

@@ -113,51 +115,22 @@

if(0) {
// Pick platform
var platformList = WebCL.getPlatforms();
cpPlatform = platformList[0];
var platformList = webcl.getPlatforms();
var platform = platformList[0];
var devices = platform.getDevices(webcl.DEVICE_TYPE_GPU);
device=devices[0];
// Query the set of GPU devices on this platform
cdDevices = cpPlatform.getDevices(WebCL.DEVICE_TYPE_GPU);
log(" # of Devices Available = " + cdDevices.length);
var device = cdDevices[0];
log(" Using Device 0: " + device.getInfo(WebCL.DEVICE_NAME)+" from "+device.getInfo(WebCL.DEVICE_VENDOR));
if(device.getInfo(WebCL.DEVICE_VENDOR).indexOf("Intel")>=0) {
device = cdDevices[1];
log(" Using Device 1: " + device.getInfo(WebCL.DEVICE_NAME)+" from "+device.getInfo(WebCL.DEVICE_VENDOR));
// make sure we use a discrete GPU
for(var i=0;i<devices.length;i++) {
var vendor=devices[i].getInfo(webcl.DEVICE_VENDOR);
// log('found vendor '+vendor+', is Intel? '+(vendor.indexOf('Intel')>=0))
if(vendor.indexOf('Intel')==-1)
device=devices[i];
}
log('using device: '+device.getInfo(webcl.DEVICE_VENDOR).trim()+' '+device.getInfo(webcl.DEVICE_NAME));
// get CL-GL extension
if(!device.enableExtension("KHR_gl_sharing")) {
log("CL-GL not available!");
process.exit(1);
}
if(!device.enableExtension('KHR_gl_sharing'))
throw new Error("Can NOT use GL sharing");
var extensions = device.getInfo(WebCL.DEVICE_EXTENSIONS);
var hasGLSupport = extensions.search(/gl.sharing/i) >= 0;
log(hasGLSupport ? "GL-CL extension available ;-)" : "No GL support");
if (!hasGLSupport)
return;
cxGPUContext = webcl.createContext(gl, device);
// create the OpenCL context
cxGPUContext = WebCL.createContext({
devices: device,
shareGroup: gl,
platform: cpPlatform
});
}
else {
/*
* This uses default platform with CL-GL interop
*/
cxGPUContext = WebCL.createContext({
deviceType: WebCL.DEVICE_TYPE_GPU,
shareGroup: gl,
});
var devices=cxGPUContext.getInfo(WebCL.CONTEXT_DEVICES);
device=devices[0];
log('using device: '+device.getInfo(WebCL.DEVICE_VENDOR).trim()+' '+device.getInfo(WebCL.DEVICE_NAME));
}
// create a command-queue

@@ -176,5 +149,5 @@ cqCommandQueue = cxGPUContext.createCommandQueue(device, 0);

}
log("Build Status: " + cpProgram.getBuildInfo(device, WebCL.PROGRAM_BUILD_STATUS));
log("Build Options: " + cpProgram.getBuildInfo(device, WebCL.PROGRAM_BUILD_OPTIONS));
log("Build Log: " + cpProgram.getBuildInfo(device, WebCL.PROGRAM_BUILD_LOG));
log("Build Status: " + cpProgram.getBuildInfo(device, webcl.PROGRAM_BUILD_STATUS));
log("Build Options: " + cpProgram.getBuildInfo(device, webcl.PROGRAM_BUILD_OPTIONS));
log("Build Log: " + cpProgram.getBuildInfo(device, webcl.PROGRAM_BUILD_LOG));

@@ -194,5 +167,13 @@ // create the kernel

ckKernel.setArg(0, vbo_cl);
ckKernel.setArg(1, mesh_width, WebCL.type.UINT);
ckKernel.setArg(2, mesh_height, WebCL.type.UINT);
// way 1
// ckKernel.setArg(1, new Int32Array([mesh_width]));
// ckKernel.setArg(2, new Int32Array([mesh_height]));
// way 2
var aints=new Int32Array([mesh_width,mesh_height]);
var aints2=aints.subarray(1);
ckKernel.setArg(1, aints);
ckKernel.setArg(2, aints.subarray(1));
// run OpenCL kernel once to generate vertex positions

@@ -317,4 +298,4 @@ runKernel(0);

// Set arg 3 and execute the kernel
ckKernel.setArg(3, time, WebCL.type.FLOAT);
cqCommandQueue.enqueueNDRangeKernel(ckKernel, null, szGlobalWorkSize, null);
ckKernel.setArg(3, new Float32Array([time]));
cqCommandQueue.enqueueNDRangeKernel(ckKernel, 2, null, szGlobalWorkSize, null);

@@ -338,3 +319,3 @@ // unmap buffer object

// create OpenCL buffer from GL VBO
vbo_cl = cxGPUContext.createFromGLBuffer(WebCL.MEM_WRITE_ONLY, vbo);
vbo_cl = cxGPUContext.createFromGLBuffer(webcl.MEM_WRITE_ONLY, vbo);
}

@@ -341,0 +322,0 @@

@@ -29,12 +29,14 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
clu = require('../lib/clUtils');
log=console.log;
}
else
webcl = window.webcl;
//First check if the WebCL extension is installed at all
if (WebCL == undefined) {
alert("Unfortunately your system does not support WebCL. " +
"Make sure that you have the WebCL extension installed.");
return;
//First check if the webcl extension is installed at all
if (webcl == undefined) {
alert("Unfortunately your system does not support webcl. " +
"Make sure that you have the webcl extension installed.");
process.exit(-1);
}

@@ -55,15 +57,12 @@

//Pick platform
var platformList=WebCL.getPlatforms();
var platformList=webcl.getPlatforms();
platform=platformList[0];
log('using platform: '+platform.getInfo(WebCL.PLATFORM_NAME));
log('using platform: '+platform.getInfo(webcl.PLATFORM_NAME));
//Query the set of devices on this platform
devices = platform.getDevices(WebCL.DEVICE_TYPE_DEFAULT);
log('using device: '+devices[0].getInfo(WebCL.DEVICE_NAME));
devices = platform.getDevices(webcl.DEVICE_TYPE_DEFAULT);
log('using device: '+devices[0].getInfo(webcl.DEVICE_NAME));
// create GPU context for this platform
context=WebCL.createContext({
deviceType: WebCL.DEVICE_TYPE_DEFAULT,
platform: platform
});
context=webcl.createContext(webcl.DEVICE_TYPE_DEFAULT);

@@ -88,7 +87,7 @@ kernelSourceCode = [

// Create buffer for A and B and copy host contents
aBuffer = context.createBuffer(WebCL.MEM_READ_ONLY, size);
bBuffer = context.createBuffer(WebCL.MEM_READ_ONLY, size);
aBuffer = context.createBuffer(webcl.MEM_READ_ONLY, size);
bBuffer = context.createBuffer(webcl.MEM_READ_ONLY, size);
// Create buffer for C to read results
cBuffer = context.createBuffer(WebCL.MEM_WRITE_ONLY, size);
cBuffer = context.createBuffer(webcl.MEM_WRITE_ONLY, size);

@@ -100,3 +99,3 @@ // Create kernel object

catch(err) {
console.log(program.getBuildInfo(devices[0],WebCL.PROGRAM_BUILD_LOG));
console.log(program.getBuildInfo(devices[0],webcl.PROGRAM_BUILD_LOG));
}

@@ -108,3 +107,3 @@

kernel.setArg(2, cBuffer);
kernel.setArg(3, BUFFER_SIZE, WebCL.type.UINT);
kernel.setArg(3, new Uint32Array([BUFFER_SIZE]));

@@ -127,3 +126,3 @@ // Create command queue

log("using enqueueNDRangeKernel");
queue.enqueueNDRangeKernel(kernel,
queue.enqueueNDRangeKernel(kernel, 1,
null,

@@ -151,5 +150,5 @@ globalWS,

// test release all CL objects
// WebCL.releaseAll();
// webcl.releaseAll();
// if no manual cleanup specified, WebCL.releaseAll() is called at exit of program
// if no manual cleanup specified, webcl.releaseAll() is called at exit of program
}

@@ -156,0 +155,0 @@

@@ -29,11 +29,13 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
clu = require('../lib/clUtils');
log=console.log;
}
else
webcl = window.webcl;
//First check if the WebCL extension is installed at all
if (WebCL == undefined) {
alert("Unfortunately your system does not support WebCL. " +
"Make sure that you have the WebCL extension installed.");
//First check if the webcl extension is installed at all
if (webcl == undefined) {
alert("Unfortunately your system does not support webcl. " +
"Make sure that you have the webcl extension installed.");
process.exit(-1);

@@ -56,13 +58,6 @@ }

// //Pick platform
// var platformList=WebCL.getPlatforms();
// platform=platformList[0];
// create GPU context for this platform
var context=null;
try {
context=WebCL.createContext({
deviceType: WebCL.DEVICE_TYPE_GPU,
// platform: platform
});
context=webcl.createContext(webcl.DEVICE_TYPE_GPU);
}

@@ -73,7 +68,7 @@ catch(ex) {

var devices=context.getInfo(WebCL.CONTEXT_DEVICES);
var devices=context.getInfo(webcl.CONTEXT_DEVICES);
device=devices[0];
log('using device: '+device.getInfo(WebCL.DEVICE_VENDOR).trim()+
' '+device.getInfo(WebCL.DEVICE_NAME));
log('using device: '+device.getInfo(webcl.DEVICE_VENDOR).trim()+
' '+device.getInfo(webcl.DEVICE_NAME));

@@ -102,3 +97,3 @@ kernelSourceCode = [

catch(err) {
console.log(program.getBuildInfo(device,WebCL.PROGRAM_BUILD_LOG));
console.log(program.getBuildInfo(device,webcl.PROGRAM_BUILD_LOG));
}

@@ -110,9 +105,9 @@

//Create buffer for A and copy host contents
aBuffer = context.createBuffer(WebCL.MEM_READ_ONLY | WebCL.MEM_USE_HOST_PTR, size, A);
aBuffer = context.createBuffer(webcl.MEM_READ_ONLY | webcl.MEM_USE_HOST_PTR, size, A);
//Create buffer for B and copy host contents
bBuffer = context.createBuffer(WebCL.MEM_READ_ONLY | WebCL.MEM_USE_HOST_PTR, size, B);
bBuffer = context.createBuffer(webcl.MEM_READ_ONLY | webcl.MEM_USE_HOST_PTR, size, B);
//Create buffer for that uses the host ptr C
cBuffer = context.createBuffer(WebCL.MEM_WRITE_ONLY | WebCL.MEM_USE_HOST_PTR, size, C);
cBuffer = context.createBuffer(webcl.MEM_WRITE_ONLY | webcl.MEM_USE_HOST_PTR, size, C);

@@ -123,3 +118,3 @@ //Set kernel args

kernel.setArg(2, cBuffer);
kernel.setArg(3, BUFFER_SIZE, WebCL.type.UINT);
kernel.setArg(3, new Uint32Array([BUFFER_SIZE]));

@@ -136,3 +131,3 @@ // Execute the OpenCL kernel on the list

// Execute (enqueue) kernel
queue.enqueueNDRangeKernel(kernel,
queue.enqueueNDRangeKernel(kernel, 1,
null,

@@ -147,4 +142,4 @@ globalWS,

cBuffer,
WebCL.TRUE, // block
WebCL.MAP_READ,
webcl.TRUE, // block
webcl.MAP_READ,
0,

@@ -187,3 +182,3 @@ size);

// context.release();
//WebCL.releaseAll();
//webcl.releaseAll();
}

@@ -190,0 +185,0 @@

{
"name": "node-webcl",
"version": "0.8.3",
"version": "0.9.1",
"description": "A WebCL implementation for desktops with NodeJS",

@@ -20,3 +20,3 @@ "main": "webcl.js",

"type": "BSD",
"url": "https://github.com/Motorola-Mobility/node-webcl/blob/master/LICENSES"
"url": "https://github.com/mikeseven/node-webcl/blob/master/LICENSES"
}

@@ -26,3 +26,3 @@ ],

"type": "git",
"url": "https://github.com/Motorola-Mobility/node-webcl"
"url": "https://github.com/mikeseven/node-webcl"
},

@@ -37,3 +37,3 @@ "directories": {

"scripts": {
"install": "node-gyp rebuild"
"install": "node-gyp rebuild --msvs_version=2013"
},

@@ -43,4 +43,8 @@ "dependencies": {

"node-image": ">=0.7.1",
"nan": "^0.8.0"
"nan": "~1.2.0"
},
"devDependencies": {
"chai": "*",
"mocha": "*"
}
}

@@ -30,3 +30,3 @@ Introduction

- [node-webgl][NODE_WEBGL]. This module is used for samples using WebGL interoperability with WebCL.
In turns, [node-webgl][NODE_WEBGL] relies on [node-glfw][NODE_GLFW] that relies on [GLFW][GLFW], [GLEW][GLEW], [AntTweakBar][ANTTWEAKBAR]. See node-webgl and node-glfw for instructions on how to install these modules.
In turns, [node-webgl][NODE_WEBGL] relies on [node-glfw][NODE_GLFW] that relies on [GLFW][GLFW], [GLEW][GLEW], [AntTweakBar][ANTTWEAKBAR], and FreeImage. See node-webgl and node-glfw for instructions on how to install these modules.

@@ -33,0 +33,0 @@ - OpenCL 1.1 must be installed on your machine. Typically, this means your machine has a not too old graphic card (maybe not more than 3 years old) and its latest graphic drivers installed.

@@ -31,6 +31,8 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
require('../webcl');
clu = require('../lib/clUtils');
log=console.log;
}
else
WebCL = window.webcl;

@@ -50,6 +52,6 @@ //defines, project

//First check if the WebCL extension is installed at all
if (WebCL == undefined) {
if (typeof webcl === 'undefined') {
alert("Unfortunately your system does not support WebCL. " +
"Make sure that you have the WebCL extension installed.");
return;
process.exit(-1);
}

@@ -60,6 +62,3 @@

try {
ctx=WebCL.createContext({
deviceType: WebCL.DEVICE_TYPE_ALL,
platform: WebCL.getPlatforms()[0]
});
ctx=webcl.createContext(webcl.DEVICE_TYPE_ALL);
}

@@ -70,16 +69,16 @@ catch(ex) {

var devices=ctx.getInfo(WebCL.CONTEXT_DEVICES);
var devices=ctx.getInfo(webcl.CONTEXT_DEVICES);
log("Found "+devices.length+" devices");
devices.forEach(function(d) {
d.units=d.getInfo(WebCL.DEVICE_MAX_COMPUTE_UNITS);
d.clock=d.getInfo(WebCL.DEVICE_MAX_CLOCK_FREQUENCY);
//var timerRes=d.getInfo(WebCL.DEVICE_PROFILING_TIMER_RESOLUTION);
d.type=d.getInfo(WebCL.DEVICE_TYPE);
d.endian=(d.getInfo(WebCL.DEVICE_ENDIAN_LITTLE) ? "LITTLE" : "BIG");
d.name=d.getInfo(WebCL.DEVICE_NAME);
d.units=d.getInfo(webcl.DEVICE_MAX_COMPUTE_UNITS);
d.clock=d.getInfo(webcl.DEVICE_MAX_CLOCK_FREQUENCY);
//var timerRes=d.getInfo(webcl.DEVICE_PROFILING_TIMER_RESOLUTION);
d.type=d.getInfo(webcl.DEVICE_TYPE);
d.endian=(d.getInfo(webcl.DEVICE_ENDIAN_LITTLE) ? "LITTLE" : "BIG");
d.name=d.getInfo(webcl.DEVICE_NAME);
if(d.type==WebCL.DEVICE_TYPE_CPU) d.type="CPU";
else if(d.type==WebCL.DEVICE_TYPE_GPU) d.type="GPU";
else if(d.type==WebCL.DEVICE_TYPE_ACCELERATOR) d.type="ACCELERATOR";
if(d.type==webcl.DEVICE_TYPE_CPU) d.type="CPU";
else if(d.type==webcl.DEVICE_TYPE_GPU) d.type="GPU";
else if(d.type==webcl.DEVICE_TYPE_ACCELERATOR) d.type="ACCELERATOR";
else d.type="DEFAULT";

@@ -116,3 +115,3 @@

cqCommandQueue = ctx.createCommandQueue(devices[device], WebCL.QUEUE_PROFILING_ENABLE);
cqCommandQueue = ctx.createCommandQueue(devices[device], webcl.QUEUE_PROFILING_ENABLE);
}

@@ -237,6 +236,6 @@

// Create a host buffer
cmPinnedData = ctx.createBuffer(WebCL.MEM_READ_WRITE | WebCL.MEM_ALLOC_HOST_PTR, memSize);
cmPinnedData = ctx.createBuffer(webcl.MEM_READ_WRITE | webcl.MEM_ALLOC_HOST_PTR, memSize);
// Get a mapped pointer
h_data = cqCommandQueue.enqueueMapBuffer(cmPinnedData, WebCL.TRUE, WebCL.MAP_WRITE, 0, memSize);
h_data = cqCommandQueue.enqueueMapBuffer(cmPinnedData, webcl.TRUE, webcl.MAP_WRITE, 0, memSize);

@@ -261,3 +260,3 @@ //initialize

// allocate device memory
cmDevData = ctx.createBuffer(WebCL.MEM_READ_WRITE, memSize);
cmDevData = ctx.createBuffer(webcl.MEM_READ_WRITE, memSize);

@@ -267,8 +266,8 @@ // initialize device memory

// Get a mapped pointer
h_data = cqCommandQueue.enqueueMapBuffer(cmPinnedData, WebCL.TRUE, WebCL.MAP_WRITE, 0, memSize);
h_data = cqCommandQueue.enqueueMapBuffer(cmPinnedData, webcl.TRUE, webcl.MAP_WRITE, 0, memSize);
cqCommandQueue.enqueueWriteBuffer(cmDevData, WebCL.FALSE, 0, memSize, h_data);
cqCommandQueue.enqueueWriteBuffer(cmDevData, webcl.FALSE, 0, memSize, h_data);
}
else {
ciErrNum = cqCommandQueue.enqueueWriteBuffer(cmDevData, WebCL.FALSE, 0, memSize, h_data);
ciErrNum = cqCommandQueue.enqueueWriteBuffer(cmDevData, webcl.FALSE, 0, memSize, h_data);
}

@@ -282,3 +281,3 @@

for(var i = 0; i < MEMCOPY_ITERATIONS; i++) {
ciErrNum = cqCommandQueue.enqueueReadBuffer(cmDevData, WebCL.FALSE, 0, memSize, h_data);
ciErrNum = cqCommandQueue.enqueueReadBuffer(cmDevData, webcl.FALSE, 0, memSize, h_data);
}

@@ -289,3 +288,3 @@ cqCommandQueue.finish();

// MAPPED: mapped pointers to device buffer for conventional pointer access
var dm_idata = cqCommandQueue.enqueueMapBuffer(cmDevData, WebCL.TRUE, WebCL.MAP_WRITE, 0, memSize);
var dm_idata = cqCommandQueue.enqueueMapBuffer(cmDevData, webcl.TRUE, webcl.MAP_WRITE, 0, memSize);

@@ -329,6 +328,6 @@ for(var i = 0; i < MEMCOPY_ITERATIONS; i++) {

// Create a host buffer
cmPinnedData = ctx.createBuffer(WebCL.MEM_READ_WRITE | WebCL.MEM_ALLOC_HOST_PTR, memSize);
cmPinnedData = ctx.createBuffer(webcl.MEM_READ_WRITE | webcl.MEM_ALLOC_HOST_PTR, memSize);
// Get a mapped pointer
h_data = cqCommandQueue.enqueueMapBuffer(cmPinnedData, WebCL.TRUE, WebCL.MAP_WRITE, 0, memSize);
h_data = cqCommandQueue.enqueueMapBuffer(cmPinnedData, webcl.TRUE, webcl.MAP_WRITE, 0, memSize);

@@ -355,3 +354,3 @@ // initialize

// allocate device memory
cmDevData = ctx.createBuffer(WebCL.MEM_READ_WRITE, memSize);
cmDevData = ctx.createBuffer(webcl.MEM_READ_WRITE, memSize);

@@ -365,3 +364,3 @@ // Sync queue to host, start timer 0, and copy data from Host to GPU

// Get a mapped pointer
h_data = cqCommandQueue.enqueueMapBuffer(cmPinnedData, WebCL.TRUE, WebCL.MAP_READ, 0, memSize);
h_data = cqCommandQueue.enqueueMapBuffer(cmPinnedData, webcl.TRUE, webcl.MAP_READ, 0, memSize);
}

@@ -371,3 +370,3 @@

for(var i = 0; i < MEMCOPY_ITERATIONS; i++) {
ciErrNum = cqCommandQueue.enqueueWriteBuffer(cmDevData, WebCL.FALSE, 0, memSize, h_data);
ciErrNum = cqCommandQueue.enqueueWriteBuffer(cmDevData, webcl.FALSE, 0, memSize, h_data);
}

@@ -378,5 +377,5 @@ cqCommandQueue.finish();

// MAPPED: mapped pointers to device buffer and conventional pointer access
var dm_idata = cqCommandQueue.enqueueMapBuffer(cmDevData, WebCL.TRUE, WebCL.MAP_WRITE, 0, memSize);
var dm_idata = cqCommandQueue.enqueueMapBuffer(cmDevData, webcl.TRUE, webcl.MAP_WRITE, 0, memSize);
if(memMode == PINNED ) {
h_data = cqCommandQueue.enqueueMapBuffer(cmPinnedData, WebCL.TRUE, WebCL.MAP_READ, 0, memSize);
h_data = cqCommandQueue.enqueueMapBuffer(cmPinnedData, webcl.TRUE, webcl.MAP_READ, 0, memSize);
}

@@ -424,6 +423,6 @@

// allocate device input and output memory and initialize the device input memory
var d_idata = ctx.createBuffer(WebCL.MEM_READ_ONLY, memSize);
var d_odata = ctx.createBuffer(WebCL.MEM_WRITE_ONLY, memSize);
var d_idata = ctx.createBuffer(webcl.MEM_READ_ONLY, memSize);
var d_odata = ctx.createBuffer(webcl.MEM_WRITE_ONLY, memSize);
cqCommandQueue.enqueueWriteBuffer(d_idata, WebCL.TRUE, 0, memSize, h_idata);
cqCommandQueue.enqueueWriteBuffer(d_idata, webcl.TRUE, 0, memSize, h_idata);

@@ -430,0 +429,0 @@ // Sync queue to host, start timer 0, and copy data from one GPU buffer to another GPU bufffer

@@ -29,6 +29,8 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
require('../webcl');
log = console.log;
exit = process.exit;
}
else
webcl = window.webcl;

@@ -51,3 +53,4 @@ // kernel callback

var check = WebCL.TRUE;
log('data: '+data+' size: '+data.length)
var check = true;
//var str="";

@@ -57,3 +60,3 @@ for(i=0; i<4096; i++) {

if(data[i] != 5.0) {
check = WebCL.FALSE;
check = false;
break;

@@ -84,16 +87,13 @@ }

//Pick platform
var platformList=WebCL.getPlatforms();
var platformList=webcl.getPlatforms();
platform=platformList[0];
log('using platform: '+platform.getInfo(WebCL.PLATFORM_NAME));
log('using platform: '+platform.getInfo(webcl.PLATFORM_NAME));
//Query the set of devices on this platform
var devices = platform.getDevices(WebCL.DEVICE_TYPE_GPU);
var devices = platform.getDevices(webcl.DEVICE_TYPE_GPU);
device=devices[0];
log('using device: '+device.getInfo(WebCL.DEVICE_NAME));
log('using device: '+device.getInfo(webcl.DEVICE_NAME));
// create GPU context for this platform
var context=WebCL.createContext({
devices: device,
platform: platform
} ,'Error occured in context', function(err,data){
var context=webcl.createContext(device ,'Error occured in context', function(err,data){
log(data+" : "+err);

@@ -127,3 +127,3 @@ exit(1);

log('build program error');
var info=program.getBuildInfo(device, WebCL.PROGRAM_BUILD_LOG);
var info=program.getBuildInfo(device, webcl.PROGRAM_BUILD_LOG);
log(info);

@@ -144,3 +144,3 @@ exit(1);

try {
data_buffer = context.createBuffer(WebCL.MEM_WRITE_ONLY, 4096*4);
data_buffer = context.createBuffer(webcl.MEM_WRITE_ONLY, 4096*4);
} catch(ex) {

@@ -172,3 +172,3 @@ log("Couldn't create a buffer. "+ex);

try {
kernel_event=new WebCL.WebCLEvent();
kernel_event=new webcl.WebCLEvent();
queue.enqueueTask(kernel , null, kernel_event);

@@ -183,3 +183,3 @@ } catch(ex) {

try {
read_event=new WebCL.WebCLEvent();
read_event=new webcl.WebCLEvent();
queue.enqueueReadBuffer(data_buffer, false, 0, 4096*4, data, null, read_event);

@@ -193,4 +193,4 @@ } catch(ex) {

log('set event callbacks');
kernel_event.setCallback(WebCL.COMPLETE, kernel_complete, "The kernel finished successfully.");
read_event.setCallback(WebCL.COMPLETE, read_complete, data);
kernel_event.setCallback(webcl.COMPLETE, kernel_complete, "The kernel finished successfully.");
read_event.setCallback(webcl.COMPLETE, read_complete, data);

@@ -203,4 +203,3 @@ // test 1: queue should finish with event completed

log('Wait for events to complete');
var event_list=[kernel_event, read_event];
WebCL.waitForEvents(event_list);
webcl.waitForEvents([kernel_event, read_event]);

@@ -213,9 +212,8 @@ // test 3: spin on all event completions

// while(1) {
// var ret=ev.getInfo(WebCL.EVENT_COMMAND_EXECUTION_STATUS);
// if(ret == WebCL.COMPLETE)
// var ret=ev.getInfo(webcl.EVENT_COMMAND_EXECUTION_STATUS);
// if(ret == webcl.COMPLETE)
// break;
// }
// }
log("main app thread END");
})();

@@ -29,6 +29,8 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
log = console.log;
exit = process.exit;
}
else
webcl = window.webcl;

@@ -62,3 +64,3 @@ /* CL objects */

var check = WebCL.TRUE;
var check = webcl.TRUE;
//var str="";

@@ -68,3 +70,3 @@ for(i=0; i<4096; i++) {

if(data[i] != 5.0) {
check = WebCL.FALSE;
check = webcl.FALSE;
break;

@@ -91,3 +93,3 @@ }

try {
data_buffer = context.createBuffer(WebCL.MEM_WRITE_ONLY, 4096*4);
data_buffer = context.createBuffer(webcl.MEM_WRITE_ONLY, 4096*4);
} catch(ex) {

@@ -116,3 +118,3 @@ log("Couldn't create a buffer. "+ex);

try {
kernel_event=new WebCL.WebCLEvent();
kernel_event=new webcl.WebCLEvent();
queue.enqueueTask(kernel , null, kernel_event);

@@ -127,3 +129,3 @@ } catch(ex) {

try {
read_event=new WebCL.WebCLEvent();
read_event=new webcl.WebCLEvent();
queue.enqueueReadBuffer(data_buffer, false, 0, 4096*4, data, null, read_event);

@@ -137,3 +139,3 @@ } catch(ex) {

try {
kernel_event.setCallback(WebCL.COMPLETE, kernel_complete, "The kernel finished successfully.");
kernel_event.setCallback(webcl.COMPLETE, kernel_complete, "The kernel finished successfully.");
} catch(ex) {

@@ -143,3 +145,3 @@ log("Couldn't set callback for event. "+ex);

}
read_event.setCallback(WebCL.COMPLETE, read_complete, data);
read_event.setCallback(webcl.COMPLETE, read_complete, data);

@@ -155,8 +157,8 @@ queue.finish(); // wait for everything to finish

//Pick platform
var platformList=WebCL.getPlatforms();
var platformList=webcl.getPlatforms();
platform=platformList[0];
log('using platform: '+platform.getInfo(WebCL.PLATFORM_NAME));
log('using platform: '+platform.getInfo(webcl.PLATFORM_NAME));
//Query the set of devices on this platform
var devices = platform.getDevices(WebCL.DEVICE_TYPE_GPU);
var devices = platform.getDevices(webcl.DEVICE_TYPE_GPU);

@@ -166,3 +168,3 @@ // make sure we use a discrete GPU (Intel embedded GPU don't support event correctly)

for(var i=0;i<devices.length;i++) {
var vendor=devices[i].getInfo(WebCL.DEVICE_VENDOR).trim().toUpperCase();
var vendor=devices[i].getInfo(webcl.DEVICE_VENDOR).trim().toUpperCase();
if(vendor==='NVIDIA' || vendor==='AMD' || vendor.indexOf('ADVANCED MICRO DEVICES')>=0) {

@@ -178,12 +180,7 @@ device=devices[i];

log('using device: '+device.getInfo(WebCL.DEVICE_VENDOR).trim()+
' '+device.getInfo(WebCL.DEVICE_NAME).trim());
log('using device: '+device.getInfo(webcl.DEVICE_VENDOR).trim()+
' '+device.getInfo(webcl.DEVICE_NAME).trim());
// create GPU context for this platform
context=WebCL.createContext({
devices: device,
platform: platform
} ,'Error occured in context', function(err,data){
log(data+" : "+err);
});
context=webcl.createContext(device);

@@ -208,6 +205,6 @@ /* Build the program and create a kernel */

try {
program.build(device, null, 'compil done', program_built);
program.build(device, null, program_built);
} catch(ex) {
/* Find size of log and print to std output */
var info=program.getBuildInfo(device, WebCL.PROGRAM_BUILD_LOG);
var info=program.getBuildInfo(device, webcl.PROGRAM_BUILD_LOG);
log(info);

@@ -220,11 +217,11 @@ exit(1);

// sleeping the main thread to let events propagate
function sleep() {
if(!done) {
log('sleeping 0.5s');
setTimeout(sleep, 500);
}
}
sleep();
// function sleep() {
// if(!done) {
// log('sleeping 0.5s');
// setTimeout(sleep, 500);
// }
// }
// sleep();
}
main();

@@ -29,3 +29,3 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
clu = require('../lib/clUtils');

@@ -40,2 +40,4 @@ util = require('util');

}
else
webcl = window.webcl;

@@ -54,3 +56,3 @@ requestAnimationFrame = document.requestAnimationFrame;

var /* cl_device_id */ ComputeDevice;
var /* cl_device_type */ ComputeDeviceType = WebCL.DEVICE_TYPE_GPU;
var /* cl_device_type */ ComputeDeviceType = webcl.DEVICE_TYPE_GPU;
var /* cl_image */ ComputePBO;

@@ -64,2 +66,3 @@ var /* cl_kernel */ ckCompute;

var Update = false;
var iRadius = 1; //???
var newWidth, newHeight; // only when reshape

@@ -87,3 +90,3 @@

var err = init_gl(canvas);
if (err != WebCL.SUCCESS)
if (err != webcl.SUCCESS)
return err;

@@ -99,3 +102,3 @@

return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -128,3 +131,3 @@

try {
ComputePBO = ComputeContext.createFromGLTexture(WebCL.MEM_WRITE_ONLY, gl.TEXTURE_2D, 0, TextureId);
ComputePBO = ComputeContext.createFromGLTexture(webcl.MEM_WRITE_ONLY, gl.TEXTURE_2D, 0, TextureId);
}

@@ -271,3 +274,3 @@ catch(ex) {

return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -283,55 +286,42 @@

// Pick platform
// var platformList = WebCL.getPlatforms();
// var platform = platformList[0];
var platformList = webcl.getPlatforms();
var platform = platformList[0];
var devices = platform.getDevices(webcl.DEVICE_TYPE_GPU);
ComputeDevice=devices[0];
// create the OpenCL context
ComputeContext = WebCL.createContext({
deviceType: ComputeDeviceType,
shareGroup: gl,
// platform: platform
});
var device_ids = ComputeContext.getInfo(WebCL.CONTEXT_DEVICES);
if (!device_ids) {
alert("Error: Failed to retrieve compute devices for context!");
return -1;
// make sure we use a discrete GPU
for(var i=0;i<devices.length;i++) {
var vendor=devices[i].getInfo(webcl.DEVICE_VENDOR);
// log('found vendor '+vendor+', is Intel? '+(vendor.indexOf('Intel')>=0))
if(vendor.indexOf('Intel')==-1)
ComputeDevice=devices[i];
}
log('found '+devices.length+' devices, using device: '+ComputeDevice.getInfo(webcl.DEVICE_NAME));
var device_found = false;
for(var i=0,l=device_ids.length;i<l;++i ) {
device_type = device_ids[i].getInfo(WebCL.DEVICE_TYPE);
if (device_type == ComputeDeviceType) {
ComputeDevice = device_ids[i];
device_found = true;
break;
}
}
if(!ComputeDevice.enableExtension('KHR_gl_sharing'))
throw new Error("Can NOT use GL sharing");
if (!device_found) {
alert("Error: Failed to locate compute device!");
return -1;
}
// create the OpenCL context
ComputeContext = webcl.createContext(gl, ComputeDevice);
if(!ComputeContext)
throw new Error("Can NOT create context");
// Create a command queue
//
ComputeCommands = ComputeContext.createCommandQueue(ComputeDevice, 0);
if (!ComputeCommands) {
alert("Error: Failed to create a command queue!");
return -1;
}
ComputeCommands = ComputeContext.createCommandQueue(ComputeDevice);
if (!ComputeCommands)
throw new Error("Failed to create a command queue!");
// Report the device vendor and device name
//
var vendor_name = ComputeDevice.getInfo(WebCL.DEVICE_VENDOR);
var device_name = ComputeDevice.getInfo(WebCL.DEVICE_NAME);
var vendor_name = ComputeDevice.getInfo(webcl.DEVICE_VENDOR);
var device_name = ComputeDevice.getInfo(webcl.DEVICE_NAME);
log("Connecting to " + vendor_name + " " + device_name);
if (!ComputeDevice.getInfo(WebCL.DEVICE_IMAGE_SUPPORT)) {
if (!ComputeDevice.getInfo(webcl.DEVICE_IMAGE_SUPPORT)) {
log("Application requires images: Images not supported on this device.");
return WebCL.IMAGE_FORMAT_NOT_SUPPORTED;
return webcl.IMAGE_FORMAT_NOT_SUPPORTED;
}
err = init_cl_buffers();
if (err != WebCL.SUCCESS) {
if (err != webcl.SUCCESS) {
log("Failed to create compute result! Error " + err);

@@ -342,3 +332,3 @@ return err;

err = init_cl_kernels();
if (err != WebCL.SUCCESS) {
if (err != webcl.SUCCESS) {
log("Failed to setup compute kernel! Error " + err);

@@ -348,3 +338,3 @@ return err;

return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -381,3 +371,3 @@

alert("Error: Failed to build program executable!\n"
+ ComputeProgram.getBuildInfo(ComputeDevice, WebCL.PROGRAM_BUILD_LOG));
+ ComputeProgram.getBuildInfo(ComputeDevice, webcl.PROGRAM_BUILD_LOG));
return -1;

@@ -398,7 +388,7 @@ }

//
max_workgroup_size = ckCompute.getWorkGroupInfo(ComputeDevice, WebCL.KERNEL_WORK_GROUP_SIZE);
max_workitem_sizes=ComputeDevice.getInfo(WebCL.DEVICE_MAX_WORK_ITEM_SIZES);
max_workgroup_size = ckCompute.getWorkGroupInfo(ComputeDevice, webcl.KERNEL_WORK_GROUP_SIZE);
max_workitem_sizes=ComputeDevice.getInfo(webcl.DEVICE_MAX_WORK_ITEM_SIZES);
log(' max workgroup size: '+max_workgroup_size);
log(' max workitem sizes: '+max_workitem_sizes);
return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -418,3 +408,3 @@

return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -425,3 +415,3 @@

return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -502,3 +492,3 @@

//DrawText(TextOffset[0], TextOffset[1], 1, (Animated == 0) ? "Press space to animate" : " ");
return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -540,3 +530,3 @@

try {
ComputeCommands.enqueueNDRangeKernel(ckCompute, null, global, local);
ComputeCommands.enqueueNDRangeKernel(ckCompute, 2, null, global, local);
} catch (err) {

@@ -554,3 +544,3 @@ alert("Failed to enqueue row kernel! " + err);

return WebCL.SUCCESS;
return webcl.SUCCESS;
}

@@ -560,3 +550,3 @@

// init window
if(initialize()==WebCL.SUCCESS) {
if(initialize()==webcl.SUCCESS) {
function update() {

@@ -563,0 +553,0 @@ display();

@@ -29,6 +29,8 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
log = console.log;
exit = process.exit;
}
else
webcl = window.webcl;

@@ -66,36 +68,44 @@ function read_complete(status, data) {

/* Create a device and context */
log('creating context');
/* Create a device and context */
// Pick platform
var platformList=webcl.getPlatforms();
platform=platformList[0];
log('found '+platformList.length+' platforms, using platform: '+platform.getInfo(webcl.PLATFORM_NAME));
// //Pick platform
// var platformList=WebCL.getPlatforms();
// platform=platformList[0];
// log('using platform: '+platform.getInfo(WebCL.PLATFORM_NAME));
// //Query the set of devices on this platform
// var devices = platform.getDevices(WebCL.DEVICE_TYPE_DEFAULT);
//Query the set of devices on this platform
var devices = platform.getDevices(webcl.DEVICE_TYPE_ALL);
// make sure we use a discrete GPU
// device=devices[0];
// log('using device: '+device.getInfo(WebCL.DEVICE_NAME));
// for(var i=0;i<devices.length;i++) {
// var vendor=devices[i].getInfo(webcl.DEVICE_VENDOR);
// if(vendor.indexOf('Intel')==-1)
// device=devices[i];
// }
// log('found '+devices.length+' devices, using device: '+device.getInfo(webcl.DEVICE_NAME));
// // create GPU context for this platform
// var context=WebCL.createContext({
// devices: device,
// platform: platform
// });
// create GPU context for this platform
var context=null;
try {
context=WebCL.createContext({
deviceType: WebCL.DEVICE_TYPE_ALL,
// platform: platform
});
//context=webcl.createContext(device);
// context=webcl.createContext(devices);
// device=devices[0];
context=webcl.createContext(platform, webcl.DEVICE_TYPE_GPU);
devices=context.getInfo(webcl.CONTEXT_DEVICES);
device=devices[0];
for(var i=0;i<devices.length;i++) {
var vendor=devices[i].getInfo(webcl.DEVICE_VENDOR);
// log('found vendor '+vendor+', is Intel? '+vendor.indexOf('Intel'))
if(vendor.indexOf('Intel')==-1)
device=devices[i];
}
log('using device: '+device.getInfo(webcl.DEVICE_NAME));
}
catch(ex) {
throw new Error("Can't create CL context");
throw new Error("Can't create CL context "+ex);
exit(-1);
}
var devices=context.getInfo(WebCL.CONTEXT_DEVICES);
log("Found "+devices.length+" devices");
var device=devices[0];
/* Build the program and create a kernel */

@@ -124,6 +134,7 @@ var source = [

try {
program.build(devices);
program.build(device);
} catch(ex) {
/* Find size of log and print to std output */
var info=program.getBuildInfo(devices[0], WebCL.PROGRAM_BUILD_LOG);
log("Error building program");
var info=program.getBuildInfo(devices, webcl.PROGRAM_BUILD_LOG);
log(info);

@@ -142,3 +153,3 @@ exit(1);

try {
data_buffer = context.createBuffer(WebCL.MEM_READ_WRITE | WebCL.MEM_COPY_HOST_PTR, data.byteLength, data);
data_buffer = context.createBuffer(webcl.MEM_READ_WRITE | webcl.MEM_COPY_HOST_PTR, data.byteLength, data);
} catch(ex) {

@@ -152,3 +163,3 @@ log("Couldn't create a buffer. "+ex);

kernel.setArg(0, data_buffer);
kernel.setArg(1, num_ints, WebCL.type.INT);
kernel.setArg(1, new Int32Array([num_ints]));
} catch(ex) {

@@ -161,3 +172,3 @@ log("Couldn't set a kernel argument. "+ex);

try {
queue = context.createCommandQueue(device, WebCL.QUEUE_PROFILING_ENABLE);
queue = context.createCommandQueue(device, webcl.QUEUE_PROFILING_ENABLE);
} catch(ex) {

@@ -170,8 +181,8 @@ log("Couldn't create a command queue for profiling. "+ex);

for(var i=0;i<NUM_ITERATIONS;i++) {
var prof_event=new WebCL.WebCLEvent();
var prof_event=new webcl.WebCLEvent();
/* Enqueue kernel */
try {
queue.enqueueNDRangeKernel(kernel, null, [num_items], null, null, prof_event);
queue.enqueueNDRangeKernel(kernel, 1, null, [num_items], null, null, prof_event);
} catch(ex) {
log("Couldn't enqueue the kernel. "+ex);
log("Couldn't enqueue the kernel. "+ex.name);
exit(1);

@@ -183,4 +194,4 @@ }

time_start = prof_event.getProfilingInfo(WebCL.PROFILING_COMMAND_START);
time_end = prof_event.getProfilingInfo(WebCL.PROFILING_COMMAND_END);
time_start = prof_event.getProfilingInfo(webcl.PROFILING_COMMAND_START);
time_end = prof_event.getProfilingInfo(webcl.PROFILING_COMMAND_END);
//log("time: start="+time_start+" end="+time_end);

@@ -187,0 +198,0 @@ total_time += time_end - time_start;

@@ -29,6 +29,8 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
log = console.log;
exit = process.exit;
}
else
webcl = window.webcl;

@@ -54,3 +56,3 @@ function read_complete(status, data) {

var NUM_ITERATIONS = 2000;
var PROFILE_READ = false; // profile read vs. map buffer
var PROFILE_READ = true; // profile read vs. map buffer

@@ -63,30 +65,11 @@ /* Initialize data */

// //Pick platform
// var platformList=WebCL.getPlatforms();
// platform=platformList[0];
// log('using platform: '+platform.getInfo(WebCL.PLATFORM_NAME));
// //Query the set of devices on this platform
// var devices = platform.getDevices(WebCL.DEVICE_TYPE_DEFAULT);
// device=devices[0];
// log('using device: '+device.getInfo(WebCL.DEVICE_NAME));
// // create GPU context for this platform
// var context=WebCL.createContext({
// devices: device,
// platform: platform
// });
var context=null;
try {
context=WebCL.createContext({
deviceType: WebCL.DEVICE_TYPE_GPU,
// platform: platform
});
context=webcl.createContext(webcl.DEVICE_TYPE_GPU);
}
catch(ex) {
throw new Exception("Can't create CL context");
throw new Error("Can't create CL context. "+ex);
}
var devices=context.getInfo(WebCL.CONTEXT_DEVICES);
var devices=context.getInfo(webcl.CONTEXT_DEVICES);
log("Found "+devices.length+" devices");

@@ -117,3 +100,3 @@ var device=devices[0];

/* Find size of log and print to std output */
var info=program.getBuildInfo(devices[0], WebCL.PROGRAM_BUILD_LOG);
var info=program.getBuildInfo(devices[0], webcl.PROGRAM_BUILD_LOG);
log(info);

@@ -132,3 +115,3 @@ exit(1);

try {
data_buffer = context.createBuffer(WebCL.MEM_WRITE_ONLY, NUM_BYTES);
data_buffer = context.createBuffer(webcl.MEM_WRITE_ONLY, NUM_BYTES);
} catch(ex) {

@@ -149,7 +132,8 @@ log("Couldn't create a buffer. "+ex);

var num_vectors = NUM_BYTES/16;
kernel.setArg(1, num_vectors, WebCL.type.INT);
kernel.setArg(1, new Int32Array([num_vectors]));
/* Create a command queue */
try {
queue = context.createCommandQueue(device, WebCL.QUEUE_PROFILING_ENABLE);
queue = context.createCommandQueue(device, webcl.QUEUE_PROFILING_ENABLE);
} catch(ex) {

@@ -163,3 +147,3 @@ log("Couldn't create a command queue for profiling. "+ex);

for(var i=0;i<NUM_ITERATIONS;i++) {
var prof_event=new WebCL.WebCLEvent();
var prof_event=new webcl.WebCLEvent();
loop_start=new Date().getTime();

@@ -187,3 +171,3 @@

try {
mapped_memory = queue.enqueueMapBuffer(data_buffer, true, WebCL.MAP_READ, 0, data.byteLength, null, prof_event);
mapped_memory = queue.enqueueMapBuffer(data_buffer, true, webcl.MAP_READ, 0, data.byteLength, null, prof_event);
if(mapped_memory[0]!=5) {

@@ -199,4 +183,4 @@ Throw("Kernel didn't work or mapping is wrong");

/* Get profiling information */
time_start = prof_event.getProfilingInfo(WebCL.PROFILING_COMMAND_START);
time_end = prof_event.getProfilingInfo(WebCL.PROFILING_COMMAND_END);
time_start = prof_event.getProfilingInfo(webcl.PROFILING_COMMAND_START);
time_end = prof_event.getProfilingInfo(webcl.PROFILING_COMMAND_END);
total_time += time_end - time_start;

@@ -203,0 +187,0 @@

@@ -29,6 +29,8 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
log = console.log;
exit = process.exit;
}
else
webcl = window.webcl;

@@ -56,13 +58,13 @@ (function main() {

// //Pick platform
var platformList=WebCL.getPlatforms();
var platformList=webcl.getPlatforms();
platform=platformList[0];
log('using platform: '+platform.getInfo(WebCL.PLATFORM_NAME));
log('using platform: '+platform.getInfo(webcl.PLATFORM_NAME));
// //Query the set of devices on this platform
// var devices = platform.getDevices(WebCL.DEVICE_TYPE_DEFAULT);
// var devices = platform.getDevices(webcl.DEVICE_TYPE_DEFAULT);
// device=devices[0];
// log('using device: '+device.getInfo(WebCL.DEVICE_NAME));
// log('using device: '+device.getInfo(webcl.DEVICE_NAME));
// // create GPU context for this platform
// var context=WebCL.createContext({
// var context=webcl.createContext({
// devices: device,

@@ -74,6 +76,3 @@ // platform: platform

try {
context=WebCL.createContext({
deviceType: WebCL.DEVICE_TYPE_GPU,
platform: platform
});
context=webcl.createContext(webcl.DEVICE_TYPE_GPU);
}

@@ -84,3 +83,3 @@ catch(ex) {

var devices=context.getInfo(WebCL.CONTEXT_DEVICES);
var devices=context.getInfo(webcl.CONTEXT_DEVICES);
log("Found "+devices.length+" devices");

@@ -182,3 +181,3 @@ var device=devices[0];

/* Find size of log and print to std output */
var info=program.getBuildInfo(devices[0], WebCL.PROGRAM_BUILD_LOG);
var info=program.getBuildInfo(devices[0], webcl.PROGRAM_BUILD_LOG);
log(info);

@@ -197,3 +196,3 @@ exit(1);

try {
data_buffer = context.createBuffer(WebCL.MEM_WRITE_ONLY, NUM_ELEMS*Uint32Array.BYTES_PER_ELEMENT);
data_buffer = context.createBuffer(webcl.MEM_WRITE_ONLY, NUM_ELEMS*Uint32Array.BYTES_PER_ELEMENT);
} catch(ex) {

@@ -205,3 +204,3 @@ log("Couldn't create a buffer. "+ex);

try {
ret_buffer = context.createBuffer(WebCL.MEM_WRITE_ONLY, 1*Uint32Array.BYTES_PER_ELEMENT);
ret_buffer = context.createBuffer(webcl.MEM_WRITE_ONLY, 1*Uint32Array.BYTES_PER_ELEMENT);
} catch(ex) {

@@ -215,3 +214,3 @@ log("Couldn't create a buffer. "+ex);

kernel.setArg(0, data_buffer);
kernel.setArg(1, NUM_ELEMS, WebCL.type.UINT); /* Tell kernel number of elements */
kernel.setArg(1, new Int32Array([NUM_ELEMS])); /* Tell kernel number of elements */
kernel.setArg(2, ret_buffer); /* Pass pointer to returned number of values */

@@ -218,0 +217,0 @@

@@ -29,6 +29,8 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

if(nodejs) {
WebCL = require('../webcl');
webcl = require('../webcl');
log = console.log;
exit = process.exit;
}
else
webcl = window.webcl;

@@ -60,14 +62,14 @@ function read_complete(event, data) {

// //Pick platform
// var platformList=WebCL.getPlatforms();
// var platformList=webcl.getPlatforms();
// platform=platformList[0];
// log('using platform: '+platform.getInfo(WebCL.PLATFORM_NAME));
// log('using platform: '+platform.getInfo(webcl.PLATFORM_NAME));
// //Query the set of devices on this platform
// var devices = platform.getDevices(WebCL.DEVICE_TYPE_GPU);
// var devices = platform.getDevices(webcl.DEVICE_TYPE_GPU);
// device=devices[0];
// log('using device: '+device.getInfo(WebCL.DEVICE_NAME));
// log('using device: '+device.getInfo(webcl.DEVICE_NAME));
// // create GPU context for this platform
// var context=WebCL.createContext({
// var context=webcl.createContext({
// devices: device,

@@ -79,6 +81,3 @@ // platform: platform

try {
context=WebCL.createContext({
deviceType: WebCL.DEVICE_TYPE_ALL,
// platform: platform
});
context=webcl.createContext(webcl.DEVICE_TYPE_ALL);
}

@@ -89,3 +88,3 @@ catch(ex) {

var devices=context.getInfo(WebCL.CONTEXT_DEVICES);
var devices=context.getInfo(webcl.CONTEXT_DEVICES);
log("Found "+devices.length+" devices");

@@ -114,3 +113,3 @@ var device=devices[0];

/* Find size of log and print to std output */
var info=program.getBuildInfo(devices[0], WebCL.PROGRAM_BUILD_LOG);
var info=program.getBuildInfo(devices[0], webcl.PROGRAM_BUILD_LOG);
log(info);

@@ -129,3 +128,3 @@ exit(1);

try {
data_buffer = context.createBuffer(WebCL.MEM_READ_WRITE | WebCL.MEM_COPY_HOST_PTR, 4*Float32Array.BYTES_PER_ELEMENT,data);
data_buffer = context.createBuffer(webcl.MEM_READ_WRITE | webcl.MEM_COPY_HOST_PTR, 4*Float32Array.BYTES_PER_ELEMENT,data);
} catch(ex) {

@@ -146,3 +145,3 @@ log("Couldn't create a buffer. "+ex);

try {
queue = context.createCommandQueue(device, WebCL.QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE);
queue = context.createCommandQueue(device, webcl.QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE);
} catch(ex) {

@@ -157,3 +156,3 @@ log("Couldn't create an out of order command queue, using in-order queue. "+ex);

} catch(ex) {
log("Couldn't enqueue the kernel");
log("Couldn't create UserEvent. "+ex);
exit(1);

@@ -164,3 +163,3 @@ }

try {
kernel_event=new WebCL.WebCLEvent();
kernel_event=new webcl.WebCLEvent();
queue.enqueueTask(kernel , [user_event], kernel_event);

@@ -174,3 +173,3 @@ } catch(ex) {

try {
read_event=new WebCL.WebCLEvent();
read_event=new webcl.WebCLEvent();
queue.enqueueReadBuffer(data_buffer, false, 0, data.byteLength, data, [ kernel_event ], read_event);

@@ -184,3 +183,3 @@ } catch(ex) {

try {
read_event.setCallback(WebCL.COMPLETE, read_complete, data);
read_event.setCallback(webcl.COMPLETE, read_complete, data);
} catch(ex) {

@@ -194,3 +193,3 @@ log("Couldn't set callback for read event. "+ex);

/* Set user event to success */
user_event.setUserEventStatus(WebCL.SUCCESS);
user_event.setStatus(webcl.SUCCESS);

@@ -197,0 +196,0 @@ queue.finish();

@@ -31,42 +31,59 @@ // Copyright (c) 2011-2012, Motorola Mobility, Inc.

module.exports = cl;
module.exports=cl;
global.webcl=cl;
global.WebCLPlatform=cl.WebCLPlatform;
global.WebCLDevice=cl.WebCLDevice;
global.WebCLContext=cl.WebCLContext;
global.WebCLCommandQueue=cl.WebCLCommandQueue;
global.WebCLEvent=cl.WebCLEvent;
global.WebCLBuffer=cl.WebCLBuffer;
global.WebCLImage=cl.WebCLImage;
global.WebCLSampler=cl.WebCLSampler;
global.WebCLUserEvent=cl.WebCLUserEvent;
global.WebCLException=cl.WebCLException;
global.WebCLProgram=cl.WebCLProgram;
global.WebCLKernel=cl.WebCLKernel;
global.WebCLImageDescriptor=cl.WebCLImageDescriptor;
cl.size = {};
cl.size.CHAR = cl.size_CHAR;
cl.size.SHORT = cl.size_SHORT;
cl.size.INT = cl.size_INT;
cl.size.LONG = cl.size_LONG;
cl.size.FLOAT = cl.size_FLOAT;
cl.size.DOUBLE = cl.size_DOUBLE;
cl.size.HALF = cl.size_HALF;
// cl.size = {};
// cl.size.CHAR = cl.size_CHAR;
// cl.size.SHORT = cl.size_SHORT;
// cl.size.INT = cl.size_INT;
// cl.size.LONG = cl.size_LONG;
// cl.size.FLOAT = cl.size_FLOAT;
// cl.size.DOUBLE = cl.size_DOUBLE;
// cl.size.HALF = cl.size_HALF;
cl.type = {};
cl.type.CHAR = 0;
cl.type.UCHAR = 1;
cl.type.SHORT = 2;
cl.type.USHORT = 3;
cl.type.INT = 4;
cl.type.UINT = 5;
cl.type.LONG = 6;
cl.type.ULONG = 7;
cl.type.FLOAT = 8;
cl.type.HALF = 9;
cl.type.DOUBLE = 10;
cl.type.QUAD = 11;
cl.type.LONG_LONG = 12;
// cl.type = {};
// cl.type.CHAR = 0;
// cl.type.UCHAR = 1;
// cl.type.SHORT = 2;
// cl.type.USHORT = 3;
// cl.type.INT = 4;
// cl.type.UINT = 5;
// cl.type.LONG = 6;
// cl.type.ULONG = 7;
// cl.type.FLOAT = 8;
// cl.type.HALF = 9;
// cl.type.DOUBLE = 10;
// cl.type.QUAD = 11;
// cl.type.LONG_LONG = 12;
cl.type.VEC2 = 1 << 16;
cl.type.VEC3 = 1 << 17;
cl.type.VEC4 = 1 << 18;
cl.type.VEC8 = 1 << 19;
cl.type.VEC16 = 1 << 20;
// cl.type.VEC2 = 1 << 16;
// cl.type.VEC3 = 1 << 17;
// cl.type.VEC4 = 1 << 18;
// cl.type.VEC8 = 1 << 19;
// cl.type.VEC16 = 1 << 20;
cl.type.LOCAL_MEMORY_SIZE = 0xFF;
// cl.type.LOCAL_MEMORY_SIZE = 0xFF;
// make sure all OpenCL resources are released at node exit
process.on('exit',function() {
WebCL.releaseAll();
cl.releaseAll(1);
});
// process.on('SIGINT', function () {
// cl.releaseAll(-1);
// });
//////////////////////////////

@@ -101,15 +118,19 @@ // WebCL object

var _createContext = cl.createContext;
cl.createContext = function (properties, data, callback) {
if (!((properties===null || typeof properties === 'undefined' || typeof properties === 'object') &&
(callback===null || typeof callback === 'undefined' || typeof callback === 'function')
)) {
throw new TypeError('Expected createContext(optional WebCLContextProperties properties, optional any data, optional function callback)');
cl.createContext = function (arg1, arg2, arg3) {
if (!(typeof arg1 === 'number' || checkObjectType(arg1, 'WebCLPlatform') || checkObjectType(arg1, 'WebCLDevice') ||
typeof arg1 === 'object' || arguments.length==0 ||
typeof arg3 === 'number')
) {
throw new TypeError('Expected createContext(optional CLenum deviceType = WebCL.DEVICE_TYPE_DEFAULT)\n'
+'or createContext(WebCLPlatform platform, optional CLenum deviceType = WebCL.DEVICE_TYPE_DEFAULT)\n'
+'or createContext(WebCLDevice device)\n'
+'or createContext(WebCLDevice[] devices)\n'
+'or createContext(WebGLRenderingContext gl, optional CLenum deviceType = WebCL.DEVICE_TYPE_DEFAULT);\n'
+'or createContext(WebGLRenderingContext gl, WebCLPlatform platform, optional CLenum deviceType = WebCL.DEVICE_TYPE_DEFAULT);\n'
+'or createContext(WebGLRenderingContext gl, WebCLDevice device);\n'
+'or createContext(WebGLRenderingContext gl, sequence<WebCLDevice> devices);');
}
var ctx = _createContext(properties, data, callback);
// automatically enables CLGL extension for default device
if(ctx && properties.shareGroup && !properties.device) {
var devices=ctx.getInfo(WebCL.CONTEXT_DEVICES);
devices[0].enableExtension('KHR_gl_sharing');
}
var ctx = _createContext(arg1, arg2, arg3);
return ctx;

@@ -120,4 +141,5 @@ }

cl.waitForEvents = function (events, callback) {
if (!(arguments.length === 1 && typeof events === 'object' )) {
throw new TypeError('Expected waitForEvents(WebCLEvent[] events)');
if (!(arguments.length >= 1 && typeof events === 'object' &&
(typeof callback === 'undefined' || typeof callback === 'function'))) {
throw new TypeError('Expected waitForEvents(WebCLEvent[] events, optional callback)');
}

@@ -128,4 +150,4 @@ return _waitForEvents(events, callback);

var _releaseAll = cl.releaseAll;
cl.releaseAll = function () {
return _releaseAll();
cl.releaseAll = function (atExit) {
return _releaseAll(atExit);
}

@@ -147,11 +169,12 @@

cl.WebCLCommandQueue.prototype.enqueueNDRangeKernel=function (kernel, offsets, globals, locals, event_list, event) {
if (!(arguments.length>= 4 && checkObjectType(kernel, 'WebCLKernel') &&
typeof offsets === 'object' && typeof globals === 'object' && typeof locals === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
cl.WebCLCommandQueue.prototype.enqueueNDRangeKernel=function (kernel, workDim, offsets, globals, locals, event_list, event) {
if (!(arguments.length>= 4 && checkObjectType(kernel, 'WebCLKernel') && (typeof workDim === 'number') &&
typeof offsets === 'object' && typeof globals === 'object' &&
(locals==null || typeof locals === 'undefined' || typeof locals === 'object') &&
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {
throw new TypeError('Expected WebCLCommandQueue.enqueueNDRangeKernel(WebCLKernel kernel, int[3] offsets, int[3] globals, int[3] locals, WebCLEvent[] event_list, WebCLEvent event)');
throw new TypeError('Expected WebCLCommandQueue.enqueueNDRangeKernel(WebCLKernel kernel, int workDim, int[3] offsets, int[3] globals, int[3] locals, WebCLEvent[] event_list, WebCLEvent event)');
}
return this._enqueueNDRangeKernel(kernel, offsets, globals, locals, event_list, event);
return this._enqueueNDRangeKernel(kernel, workDim, offsets, globals, locals, event_list, event);
}

@@ -161,4 +184,4 @@

if (!(arguments.length >= 1 && checkObjectType(kernel, 'WebCLKernel') &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -170,15 +193,15 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueTask(WebCLKernel kernel, WebCLEvent[] event_list, WebCLEvent event)');

cl.WebCLCommandQueue.prototype.enqueueWriteBuffer=function (buffer, blocking_write, offset, cb, ptr, event_list, event) {
cl.WebCLCommandQueue.prototype.enqueueWriteBuffer=function (buffer, blocking_write, offset, sizeInBytes, ptr, event_list, event) {
if (!(arguments.length >= 5 &&
checkObjectType(buffer, 'WebCLBuffer') &&
(typeof blocking_write === 'boolean' || typeof blocking_write === 'number') &&
typeof offset === 'number' && typeof cb === 'number' &&
typeof offset === 'number' && typeof sizeInBytes === 'number' &&
typeof ptr === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {
throw new TypeError('Expected WebCLCommandQueue.enqueueWriteBuffer(WebCLBuffer buffer, boolean blocking_write, ' +
'uint offset, uint cb, ArrayBuffer ptr, WebCLEvent[] event_list, WebCLEvent event)');
'uint offset, uint sizeInBytes, ArrayBuffer ptr, WebCLEvent[] event_list, WebCLEvent event)');
}
return this._enqueueWriteBuffer(buffer, blocking_write, offset, cb, ptr, event_list, event);
return this._enqueueWriteBuffer(buffer, blocking_write, offset, sizeInBytes, ptr, event_list, event);
}

@@ -193,4 +216,4 @@

typeof ptr === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event == null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -206,8 +229,8 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueReadBuffer(WebCLBuffer buffer, boolean blocking_read, ' +

event_list, event) {
if (!(arguments.length >= 5 &&
if (!(arguments.length >= 5 &&
checkObjectType(src_buffer, 'WebCLBuffer') &&
checkObjectType(dst_buffer, 'WebCLBuffer') &&
typeof src_offset === 'number' && typeof dst_offset === 'number' && typeof size === 'number' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -235,4 +258,4 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueCopyBuffer(WebCLBuffer src_buffer, WebCLBuffer dst_buffer, ' +

typeof ptr === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -265,4 +288,4 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueWriteBufferRect(WebCLBuffer memory_object, ' +

typeof ptr === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -293,4 +316,4 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueReadBufferRect(WebCLBuffer buffer, ' +

typeof dst_row_pitch === 'number' && typeof dst_slice_pitch === 'number' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -310,5 +333,5 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueCopyBufferRect(WebCLBuffer src_buffer, WebCLBuffer dst_buffer, ' +

cl.WebCLCommandQueue.prototype.enqueueWriteImage=function (image, blocking_write, origin, region, row_pitch, slice_pitch, ptr, event_list, event) {
cl.WebCLCommandQueue.prototype.enqueueWriteImage=function (image, blocking_write, origin, region, row_pitch, ptr, event_list, event) {
//console.log('checking object: type: '+Object.prototype.toString.call(ptr)+' for typeof: '+typeof(ptr));
if (!(arguments.length >= 7 &&
if (!(arguments.length >= 6 &&
checkObjectType(image, 'WebCLImage') &&

@@ -318,16 +341,15 @@ typeof origin === 'object' &&

typeof row_pitch === 'number' &&
typeof slice_pitch === 'number' &&
typeof ptr === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {
throw new TypeError('Expected WebCLCommandQueue.enqueueWriteImage(WebCLImage image, boolean blocking_write, ' +
'int[3] origin, int[3] region, int row_pitch, int slice_pitch, ArrayBuffer ptr, WebCLEvent[] event_list, WebCLEvent event)');
'int[3] origin, int[3] region, int row_pitch, ArrayBuffer ptr, WebCLEvent[] event_list, WebCLEvent event)');
}
return this._enqueueWriteImage(image, blocking_write, origin, region, row_pitch, slice_pitch, ptr, event_list, event);
return this._enqueueWriteImage(image, blocking_write, origin, region, row_pitch, ptr, event_list, event);
}
cl.WebCLCommandQueue.prototype.enqueueReadImage=function (image, blocking_read, origin, region, row_pitch, slice_pitch,
cl.WebCLCommandQueue.prototype.enqueueReadImage=function (image, blocking_read, origin, region, row_pitch,
ptr, event_list, event) {
if (!(arguments.length >= 7 &&
if (!(arguments.length >= 6 &&
checkObjectType(image, 'WebCLImage') &&

@@ -337,12 +359,11 @@ typeof origin === 'object' &&

typeof row_pitch === 'number' &&
typeof slice_pitch === 'number' &&
typeof ptr === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {
throw new TypeError('Expected WebCLCommandQueue.enqueueReadImage(WebCLImage image, boolean blocking_write, ' +
'uint[3] region, uint row_pitch, uint slice_pitch, ' +
'ArrayBuffer ptr, WebCLEvent[] event_list, WebCLEvent event)');
'uint[3] region, uint row_pitch, ' +
'ArrayBuffer ptr, optional WebCLEvent[] event_list, optional WebCLEvent event)');
}
return this._enqueueReadImage(image, blocking_read, origin, region, row_pitch, slice_pitch, ptr, event_list, event);
return this._enqueueReadImage(image, blocking_read, origin, region, row_pitch, ptr, event_list, event);
}

@@ -352,3 +373,3 @@

event_list, event) {
if (!(arguments.length >= 5 &&
if (!(arguments.length >= 5 &&
checkObjectType(src_image, 'WebCLImage') &&

@@ -359,4 +380,4 @@ checkObjectType(dst_image, 'WebCLImage') &&

typeof region === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event == null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -372,3 +393,3 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueCopyImage(WebCLImage src_image, WebCLImage dst_image, ' +

event_list, event) {
if (!(arguments.length >= 5 &&
if (!(arguments.length >= 5 &&
checkObjectType(src_image, 'WebCLImage') &&

@@ -379,4 +400,4 @@ checkObjectType(dst_buffer, 'WebCLBuffer') &&

typeof dst_offset === 'number' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -392,3 +413,3 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueCopyImageToBuffer(WebCLImage src_image, WebCLBuffer dst_buffer, ' +

region, event_list, event) {
if (!(arguments.length >= 5 &&
if (!(arguments.length >= 5 &&
checkObjectType(src_buffer, 'WebCLBuffer') &&

@@ -399,4 +420,4 @@ checkObjectType(dst_image, 'WebCLImage') &&

typeof region === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -410,10 +431,10 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueCopyBufferToImage(WebCLBuffer src_buffer, WebCLImage dst_image, ' +

cl.WebCLCommandQueue.prototype.enqueueMapBuffer=function (memory_object, blocking, flags, offset, size, event_list, event) {
if (!(arguments.length >= 5 &&
if (!(arguments.length >= 5 &&
checkObjectType(memory_object, 'WebCLBuffer') &&
(typeof blocking === 'boolean' || typeof blocking === 'number') &&
typeof flags === 'number' &&
typeof offset === 'number' &&
typeof size === 'number' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
typeof flags === 'number' &&
typeof offset === 'number' &&
typeof size === 'number' &&
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -427,10 +448,10 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueMapBuffer(WebCLBuffer memory_object, boolean blocking, CLenum flags, uint offset, uint size, WebCLEvent[] event_list, WebCLEvent event)');

cl.WebCLCommandQueue.prototype.enqueueMapImage=function (memory_object, blocking, flags, origin, region, event_list, event) {
if (!(arguments.length >= 5 &&
if (!(arguments.length >= 5 &&
checkObjectType(memory_object, 'WebCLImage') &&
(typeof blocking === 'boolean' || typeof blocking === 'number') &&
typeof flags === 'number' &&
typeof origin === 'number' &&
typeof region === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
typeof flags === 'number' &&
typeof origin === 'number' &&
typeof region === 'object' &&
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -443,7 +464,7 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueMapImage(WebCLImage memory_object, boolean blocking, CLenum flags, uint origin, WebCLRegion region, WebCLEvent[] event_list, WebCLEvent event)');

cl.WebCLCommandQueue.prototype.enqueueUnmapMemObject=function (memory_object, region, event_list, event) {
if (!(arguments.length >= 2 &&
if (!(arguments.length >= 2 &&
(checkObjectType(memory_object, 'WebCLBuffer') || checkObjectType(memory_object, 'WebCLImage')) &&
typeof region === 'object' &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
typeof region === 'object' &&
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -455,15 +476,12 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueUnmapMemObject(WebCLMemoryObject memory_object, ArrayBuffer region, WebCLEvent[] event_list, WebCLEvent event)');

cl.WebCLCommandQueue.prototype.enqueueMarker=function (event_list, event) {
if (!(arguments.length >= 0 &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {
throw new TypeError('Expected WebCLCommandQueue.enqueueMarker(WebCLEvent[] event_list, WebCLEvent event)');
cl.WebCLCommandQueue.prototype.enqueueMarker=function (event) {
if (!(arguments.length == 1 && checkObjectType(event, 'WebCLEvent'))) {
throw new TypeError('Expected WebCLCommandQueue.enqueueMarker(WebCLEvent event)');
}
return this._enqueueMarker(event_list, event);
return this._enqueueMarker(event);
}
cl.WebCLCommandQueue.prototype.enqueueWaitForEvents=function (event_wait_list) {
if (!(arguments.length >=0 &&
(typeof event_list === 'undefined' || typeof event_list === 'object') )) {
if (!(arguments.length >=0 &&
(typeof event_list === 'undefined' || event_list==null || typeof event_list === 'object') )) {
throw new TypeError('Expected WebCLCommandQueue.enqueueWaitForEvents(WebCLEvent[] event_wait_list)');

@@ -476,4 +494,4 @@ }

if (!(arguments.length >= 0 &&
(typeof event_list === 'undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
(event_list==null || typeof event_list === 'undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -493,4 +511,5 @@ throw new TypeError('Expected WebCLCommandQueue.enqueueBarrier(WebCLEvent[] event_list, WebCLEvent event)');

cl.WebCLCommandQueue.prototype.finish=function (callback) {
if (!(arguments.length === 0)) {
throw new TypeError('Expected WebCLCommandQueue.finish()');
if (!(arguments.length == 0 ||
(arguments.length==1 && typeof callback === 'function'))) {
throw new TypeError('Expected WebCLCommandQueue.finish(optional callback)');
}

@@ -502,8 +521,8 @@ return this._finish(callback);

if(!cl.WebCLDevice.prototype.enable_extensions.KHR_gl_sharing.enabled) {
throw new Error('WEBCL_EXTENSION_NOT_ENABLED');
throw new WebCLException('WEBCL_EXTENSION_NOT_ENABLED');
}
if (!(arguments.length >= 1 &&
typeof mem_objects === 'object' &&
(typeof event_list==='undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
if (!(arguments.length >= 1 &&
typeof mem_objects === 'object' &&
(event_list==null || typeof event_list==='undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -517,8 +536,8 @@ throw new TypeError('Expected WebCLEvent WebCLGL.enqueueAcquireGLObjects(WebCLMemoryObject[] mem_objects, WebCLEvent[] event_list, WebCLEvent event)');

if(!cl.WebCLDevice.prototype.enable_extensions.KHR_gl_sharing.enabled) {
throw new Error('WEBCL_EXTENSION_NOT_ENABLED');
throw new WebCLException('WEBCL_EXTENSION_NOT_ENABLED');
}
if (!(arguments.length >= 1 &&
typeof mem_objects === 'object' &&
(typeof event_list==='undefined' || typeof event_list === 'object') &&
(typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
if (!(arguments.length >= 1 &&
typeof mem_objects === 'object' &&
(event_list==null || typeof event_list==='undefined' || typeof event_list === 'object') &&
(event==null || typeof event === 'undefined' || checkObjectType(event, 'WebCLEvent'))
)) {

@@ -554,3 +573,3 @@ throw new TypeError('Expected WebCLEvent WebCLGL.enqueueReleaseGLObjects(WebCLMemoryObject[] mem_objects, WebCLEvent[] event_list, WebCLEvent event)');

},
KDR_fp64: {
KHR_fp64: {
enabled: false,

@@ -588,9 +607,10 @@ cl_name: null,

cl.WebCLDevice.prototype.enableExtension=function (name) {
// log(this.enable_extensions);
if(this.enable_extensions[name]) {
this.enable_extensions[name].enabled=true;
cl.WebCLDevice.prototype.enableExtension=function (param_name) {
if (!(arguments.length === 1 && typeof param_name === 'string')) {
throw new TypeError('Expected WebCLDevice.enableExtension(String extension_name)');
}
return this.enable_extensions[name].enabled;
var ret = this._enableExtension(param_name);
if(ret)
cl.WebCLDevice.prototype.enable_extensions[param_name].enabled = true;
return ret;
}

@@ -605,2 +625,10 @@

cl.WebCLContext.prototype.retain=function () {
return this._retain();
}
cl.WebCLContext.prototype.releaseAll=function () {
return this._releaseAll();
}
cl.WebCLContext.prototype.getInfo=function (param_name) {

@@ -614,3 +642,3 @@ if (!(arguments.length === 1 && typeof param_name === 'number')) {

cl.WebCLContext.prototype.createProgram=function (sources) {
if (!(arguments.length === 1 && typeof sources === 'string')) {
if (!(arguments.length === 1 && (sources==null || typeof sources === 'string'))) {
throw new TypeError('Expected WebCLContext.createProgram(string sources)');

@@ -630,5 +658,7 @@ }

cl.WebCLContext.prototype.createCommandQueue=function (device, properties) {
if (!(arguments.length >=1 && checkObjectType(device, 'WebCLDevice') &&
(properties==null || typeof properties === 'number' || typeof properties === 'object'))) {
throw new TypeError('Expected WebCLContext.createCommandQueue(WebCLDevice device, CLenum[] properties)');
if (!(arguments.length==0 ||
((arguments.length ==1 && (checkObjectType(device, 'WebCLDevice') || typeof device === 'number'))) ||
(typeof properties==='undefined' || typeof properties === 'number')
)) {
throw new TypeError('Expected WebCLContext.createCommandQueue(optional WebCLDevice device, optional CLenum properties = 0)');
}

@@ -639,3 +669,3 @@ return this._createCommandQueue(device, properties);

cl.WebCLContext.prototype.createBuffer=function (flags, size, host_ptr) {
if (!(arguments.length >= 2 && typeof flags === 'number' && typeof size === 'number' &&
if (!(arguments.length >= 2 && typeof flags === 'number' && typeof size === 'number' &&
(host_ptr === null || typeof host_ptr === 'undefined' || typeof host_ptr === 'object') )) {

@@ -648,6 +678,6 @@ throw new TypeError('Expected WebCLContext.createBuffer(CLenum flags, int size, optional ArrayBuffer host_ptr)');

cl.WebCLContext.prototype.createImage=function (flags, descriptor, host_ptr) {
if (!(arguments.length === 3 && typeof flags === 'number' &&
if (!(arguments.length >=2 && typeof flags === 'number' &&
typeof descriptor === 'object' &&
typeof host_ptr === 'object')) {
throw new TypeError('Expected WebCLContext.createImage3D(CLenum flags, cl.WebCLImageDescriptor descriptor, ' +
(host_ptr==null || typeof host_ptr==='undefined' || typeof host_ptr === 'object'))) {
throw new TypeError('Expected WebCLContext.createImage(CLenum flags, WebCL.WebCLImageDescriptor descriptor, ' +
'ArrayBuffer host_ptr)');

@@ -659,5 +689,5 @@ }

cl.WebCLContext.prototype.createSampler=function (normalized_coords, addressing_mode, filter_mode) {
if (!(arguments.length === 3 &&
(typeof normalized_coords === 'number' || typeof normalized_coords === 'boolean') &&
typeof addressing_mode === 'number' &&
if (!(arguments.length === 3 &&
(typeof normalized_coords === 'number' || typeof normalized_coords === 'boolean') &&
typeof addressing_mode === 'number' &&
typeof filter_mode === 'number')) {

@@ -677,3 +707,3 @@ throw new TypeError('Expected WebCLContext.createSampler(bool normalized_coords, CLenum addressing_mode, CLenum filter_mode)');

cl.WebCLContext.prototype.getSupportedImageFormats=function (flags, image_type) {
if (!(arguments.length === 2 && typeof flags === 'number' && typeof image_type === 'number')) {
if (!((arguments.length === 2 && typeof flags === 'number' && typeof image_type === 'number') || arguments.length===0 || (arguments.length==1 && typeof flags === 'number'))) {
throw new TypeError('Expected WebCLContext.getSupportedImageFormats(CLenum flags, CLenum image_type)');

@@ -686,4 +716,4 @@ }

if(!cl.WebCLDevice.prototype.enable_extensions.KHR_gl_sharing.enabled) {
throw new Error('WEBCL_EXTENSION_NOT_ENABLED');
}
throw new WebCLException('WEBCL_EXTENSION_NOT_ENABLED');
}
if (!(arguments.length === 2 && typeof flags === 'number' && typeof buffer ==='object')) {

@@ -697,4 +727,4 @@ throw new TypeError('Expected WebCLContext.createFromGLBuffer(CLenum flags, WebGLBuffer buffer)');

if(!cl.WebCLDevice.prototype.enable_extensions.KHR_gl_sharing.enabled) {
throw new Error('WEBCL_EXTENSION_NOT_ENABLED');
}
throw new WebCLException('WEBCL_EXTENSION_NOT_ENABLED');
}
if (!(arguments.length === 2 && typeof flags === 'number' && typeof buffer ==='object')) {

@@ -708,8 +738,8 @@ throw new TypeError('Expected WebCLContext.createFromGLRenderbuffer(CLenum flags, WebGLRenderbuffer buffer)');

if(!cl.WebCLDevice.prototype.enable_extensions.KHR_gl_sharing.enabled) {
throw new Error('WEBCL_EXTENSION_NOT_ENABLED');
}
if (!(arguments.length === 4 && typeof flags === 'number' &&
throw new WebCLException('WEBCL_EXTENSION_NOT_ENABLED');
}
if (!(arguments.length === 4 && typeof flags === 'number' &&
typeof texture_target ==='number' &&
typeof miplevel ==='number' &&
typeof texture ==='object'
typeof texture ==='object'
)) {

@@ -721,2 +751,16 @@ throw new TypeError('Expected WebCLContext.createFromGLTexture(CLenum flags, GLenum texture_target, GLint miplevel, WebGLTexture2D texture)');

cl.WebCLContext.prototype.getGLContextInfo=function () {
if(!cl.WebCLDevice.prototype.enable_extensions.KHR_gl_sharing.enabled) {
throw new WebCLException('WEBCL_EXTENSION_NOT_ENABLED');
}
return new WebCLRenderingContext(this._getGLContextInfo());
}
cl.WebCLContext.prototype.getGLContext=function () {
if(!cl.WebCLDevice.prototype.enable_extensions.KHR_gl_sharing.enabled) {
throw new WebCLException('WEBCL_EXTENSION_NOT_ENABLED');
}
return new WebGLRenderingContext(this._getGLContext());
}
//////////////////////////////

@@ -759,2 +803,32 @@ //WebCLEvent object

//////////////////////////////
//WebCLUserEvent object
//////////////////////////////
cl.WebCLUserEvent.prototype.release=function () {
return this._release();
}
cl.WebCLUserEvent.prototype.getInfo=function (param_name) {
return this._getInfo(param_name);
}
cl.WebCLUserEvent.prototype.getProfilingInfo=function (param_name) {
return this._getProfilingInfo(param_name);
}
cl.WebCLUserEvent.prototype.setStatus=function (execution_status) {
if (!(arguments.length === 1 && typeof execution_status === 'number')) {
throw new TypeError('Expected WebCLUserEvent.setStatus(CLenum execution_status)');
}
return this._setStatus(execution_status);
}
cl.WebCLUserEvent.prototype.setCallback=function (execution_status, fct, args) {
if (!(arguments.length >= 2 && typeof execution_status === 'number' &&
typeof fct === 'function')) {
throw new TypeError('Expected WebCLEvent.setCallback(CLenum execution_status, function callback, any args)');
}
return this._setCallback(execution_status, fct, args);
}
//////////////////////////////
//WebCLKernel object

@@ -773,4 +847,12 @@ //////////////////////////////

cl.WebCLKernel.prototype.getArgInfo=function (index) {
if (!(arguments.length === 1 && typeof index === 'number')) {
throw new TypeError('Expected WebCLKernel.getInfo(CLuint number)');
}
return this._getArgInfo(index);
}
cl.WebCLKernel.prototype.getWorkGroupInfo=function (device, param_name) {
if (!(arguments.length === 2 && checkObjectType(device, 'WebCLDevice') && typeof param_name === 'number')) {
if (!(arguments.length === 2 &&
(device==null || (checkObjectType(device, 'WebCLDevice') && typeof param_name === 'number')))) {
throw new TypeError('Expected WebCLKernel.getWorkGroupInfo(WebCLDevice device, CLenum param_name)');

@@ -781,9 +863,8 @@ }

cl.WebCLKernel.prototype.setArg=function (index, value, type) {
if (!(arguments.length >= 2 && typeof index === 'number' &&
(typeof value === 'number' || typeof value === 'object') &&
(typeof type == 'undefined' || typeof type === 'number') )) {
throw new TypeError('Expected WebCLKernel.setArg(int index, any value, optional WebCL.types type)');
cl.WebCLKernel.prototype.setArg=function (index, value) {
if (!(arguments.length == 2 && typeof index === 'number' &&
(typeof value === 'object') )) {
throw new TypeError('Expected WebCLKernel.setArg(int index, WebCLBuffer | WebCLImage | WebCLSampler | ArrayBufferView value)');
}
return this._setArg(index, value, type);
return this._setArg(index, value);
}

@@ -813,5 +894,8 @@

if(!cl.WebCLDevice.prototype.enable_extensions.KHR_gl_sharing.enabled) {
throw new Error('WEBCL_EXTENSION_NOT_ENABLED');
throw new WebCLException('WEBCL_EXTENSION_NOT_ENABLED');
}
return this._getGLObjectInfo(); // returns a WebGLObjectInfo dictionary
var info=this._getGLObjectInfo(); // returns a WebGLObjectInfo dictionary
if(info && info.glObject)
info.glObject=new WebGLBuffer(info.glObject);
return info;
}

@@ -827,9 +911,26 @@

cl.WebCLBuffer.prototype.createSubBuffer=function (flags, type, region) {
if (!(arguments.length === 3 && typeof flags === 'number' && typeof type === 'number' && typeof region === 'object')) {
throw new TypeError('Expected WebCLMemoryObject.createSubBuffer(CLenum flags, CLenum type, WebCLRegion region)');
cl.WebCLBuffer.prototype.getInfo=function (param_name) {
if (!(arguments.length === 1 && typeof param_name === 'number')) {
throw new TypeError('Expected WebCLBuffer.getInfo(CLenum param_name)');
}
return this._createSubBuffer(flags, type, region);
return this._getInfo(param_name);
}
cl.WebCLBuffer.prototype.getGLObjectInfo=function () {
if(!cl.WebCLDevice.prototype.enable_extensions.KHR_gl_sharing.enabled) {
throw new WebCLException('WEBCL_EXTENSION_NOT_ENABLED');
}
var info=this._getGLObjectInfo(); // returns a WebGLObjectInfo dictionary
if(info && info.glObject)
info.glObject=new WebGLBuffer(info.glObject);
return info;
}
cl.WebCLBuffer.prototype.createSubBuffer=function (flags, origin, sizeInBytes) {
if (!(arguments.length === 3 && typeof flags === 'number' && typeof origin === 'number' && typeof sizeInBytes === 'number')) {
throw new TypeError('Expected WebCLMemoryObject.createSubBuffer(CLenum flags, CLuint origin, CLuint sizeInBytes)');
}
return this._createSubBuffer(flags, origin, sizeInBytes);
}
//////////////////////////////

@@ -843,7 +944,14 @@ //WebCLImage object

cl.WebCLImage.prototype.getInfo=function (param_name) {
if (!(arguments.length === 1 && typeof param_name === 'number')) {
throw new TypeError('Expected WebCLImage.getInfo(CLenum param_name)');
cl.WebCLImage.prototype.getInfo=function () {
return this._getInfo();
}
cl.WebCLImage.prototype.getGLObjectInfo=function () {
if(!cl.WebCLDevice.prototype.enable_extensions.KHR_gl_sharing.enabled) {
throw new WebCLException('WEBCL_EXTENSION_NOT_ENABLED');
}
return this._getImageInfo(param_name);
var info=this._getGLObjectInfo(); // returns a WebGLObjectInfo dictionary
if(info && info.glObject)
info.glObject=new WebGLTexture(info.glObject);
return info;
}

@@ -910,12 +1018,15 @@

cl.WebCLPlatform.prototype.enableExtension=function (name) {
var lname=name.trim().toLowerCase();
if(this.enable_extensions[name]) {
this.enable_extensions[name].enabled=true;
cl.WebCLPlatform.prototype.enableExtension=function (param_name) {
if (!(arguments.length === 1 && typeof param_name === 'string')) {
throw new TypeError('Expected WebCLPlatform.enableExtension(String extension_name)');
}
return this.enable_extensions[name].enabled;
/* TODO
* enable all devices in this platform
*/
return this._enableExtension(param_name);
}
cl.WebCLPlatform.prototype.getDevices=function (device_type) {
if (!(arguments.length === 1 && typeof device_type === 'number')) {
if (!(arguments.length == 0 || (arguments.length == 1 && typeof device_type === 'number'))) {
throw new TypeError('Expected WebCLPlatform.getDevices(CLenum device_type)');

@@ -933,2 +1044,6 @@ }

cl.WebCLProgram.prototype.retain=function () {
return this._retain();
}
cl.WebCLProgram.prototype.getInfo=function (param_name) {

@@ -942,3 +1057,4 @@ if (!(arguments.length === 1 && typeof param_name === 'number')) {

cl.WebCLProgram.prototype.getBuildInfo=function (device, param_name) {
if (!(arguments.length === 2 && checkObjectType(device, 'WebCLDevice') && typeof param_name === 'number')) {
if (!(arguments.length === 2 && (typeof device === 'undefined' || checkObjectType(device, 'WebCLDevice')) &&
(typeof param_name === 'number' || param_name==null))) {
throw new TypeError('Expected WebCLProgram.getBuildInfo(WebCLDevice device, CLenum param_name)');

@@ -949,12 +1065,12 @@ }

cl.WebCLProgram.prototype.build=function (devices, options, data, callback) {
if ( !(arguments.length === 1 && typeof devices === 'object') &&
!(arguments.length >= 2 && typeof devices === 'object' &&
(options==null || typeof options==='undefined' || typeof options === 'string')) &&
!(typeof data === 'undefined' || typeof data === 'object') &&
!(typeof callback === 'undefined' || callback==null || typeof callback === 'function')
) {
throw new TypeError('Expected WebCLProgram.build(WebCLDevice[] devices, String options, any data, function callback)');
cl.WebCLProgram.prototype.build=function (devices, options, callback, user_data) {
if ( !(arguments.length==0) &&
!(arguments.length == 1 && (typeof devices === 'object' || devices==null)) &&
!(arguments.length >= 2 && (typeof devices === 'object' || devices==null) &&
(options==null || typeof options==='undefined' || typeof options === 'string') &&
(callback==null || typeof callback === 'undefined' || typeof callback === 'function')
)) {
throw new TypeError('Expected WebCLProgram.build(WebCLDevice[] devices, String build_options, optional function callback, optional user_data)');
}
return this._build(devices, options, data, callback);
return this._build(devices, options, callback, user_data);
}

@@ -961,0 +1077,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc