Skip to content

Commit c2782f8

Browse files
committed
updated sample for createContext
1 parent 68b4f9d commit c2782f8

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

examples/vector_add.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function VectorAdd() {
2525
console.info("Platform "+i+": "+cl.getPlatformInfo(platforms[i],cl.PLATFORM_NAME));
2626
var platform=platforms[0];
2727

28-
var devices=cl.getDeviceIds(platform, cl.DEVICE_TYPE_ALL);
28+
var devices=cl.getDeviceIDs(platform, cl.DEVICE_TYPE_ALL);
2929
for(var i=0;i<devices.length;i++)
3030
console.info(" Devices "+i+": "+cl.getDeviceInfo(devices[i],cl.DEVICE_NAME));
3131

@@ -34,7 +34,9 @@ function VectorAdd() {
3434
// var context = cl.createContextFromType(
3535
// [cl.CONTEXT_PLATFORM, platform],
3636
// cl.DEVICE_TYPE_GPU);
37-
var context = cl.createContext(platform, devices);
37+
var context = cl.createContext([
38+
cl.CONTEXT_PLATFORM, platform],
39+
devices);
3840

3941
console.info("created context");
4042

src/context.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace opencl {
1515
// cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
1616
NAN_METHOD(CreateContext) {
1717
Nan::EscapableHandleScope scope;
18-
REQ_ARGS(4)
18+
REQ_ARGS(2)
1919
Local<Array> properties;
2020
Local<Array> devices;
2121
Local<Function> callback;
@@ -25,7 +25,7 @@ NAN_METHOD(CreateContext) {
2525
cl_context ctx=NULL;
2626
int err=CL_SUCCESS;
2727

28-
// Arg 1 -- properties
28+
// Arg 0 -- properties
2929
if(ARG_EXISTS(0)) {
3030
REQ_ARRAY_ARG(0, properties);
3131
for (uint32_t i=0; i < properties->Length(); i++) {
@@ -39,7 +39,7 @@ NAN_METHOD(CreateContext) {
3939
cl_properties.push_back(0);
4040
}
4141

42-
// Arg 2 -- devices
42+
// Arg 1 -- devices
4343
if(ARG_EXISTS(1)) {
4444
REQ_ARRAY_ARG(1, devices);
4545
for (uint32_t i=0; i<devices->Length(); i++) {
@@ -49,12 +49,12 @@ NAN_METHOD(CreateContext) {
4949
}
5050
}
5151

52-
// Arg 3 -- Callback
52+
// Arg 2 -- Callback
5353
if(ARG_EXISTS(2)) {
5454
callback = Local<Function>::Cast(info[2]);
5555
}
5656

57-
// Arg 4 -- Error callback
57+
// Arg 3 -- Error callback
5858
if(ARG_EXISTS(3)) {
5959
err_cb = Local<Function>::Cast(info[3]);
6060
}

0 commit comments

Comments
 (0)