Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added cu.launch() to make kernel launching easier

  • Loading branch information...
commit a0d0cbd4ef06d1ca9876fab471f96b4d4871ab9b 1 parent ff7137a
Jitu Das r2jitu authored

Showing 3 changed files with 13 additions and 5 deletions. Show diff stats Hide diff stats

  1. +10 0 index.js
  2. +1 1  src/function.cpp
  3. +2 4 test/test.js
10 index.js
@@ -75,3 +75,13 @@ module.exports.prepareArguments = function (args) {
75 75 return paramBuffer;
76 76 }
77 77
  78 +module.exports.launch = function () {
  79 + var func = arguments[0];
  80 + var gridDim = arguments[1];
  81 + var blockDim = arguments[2];
  82 + var args = arguments[3];
  83 +
  84 + args = module.exports.prepareArguments(args);
  85 +
  86 + return func.launchKernel(gridDim, blockDim, args);
  87 +}
2  src/function.cpp
@@ -16,7 +16,7 @@ void NodeCuda::Function::Initialize(Handle<Object> target) {
16 16 constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
17 17 constructor_template->SetClassName(String::NewSymbol("CudaFunction"));
18 18
19   - NODE_SET_PROTOTYPE_METHOD(constructor_template, "launch", NodeCuda::Function::LaunchKernel);
  19 + NODE_SET_PROTOTYPE_METHOD(constructor_template, "launchKernel", NodeCuda::Function::LaunchKernel);
20 20
21 21 // Function objects can only be created by cuModuleGetFunction
22 22 }
6 test/test.js
@@ -55,10 +55,8 @@ var cuFunction = cuModule.getFunction("helloWorld");
55 55 console.log("Got function:", cuFunction);
56 56
57 57 //cuLaunchKernel
58   -var args = cu.prepareArguments([
59   - { type: "DevicePtr", value: cuMem.devicePtr },
60   -]);
61   -var error = cuFunction.launch([3,1,1], [2,2,2], args);
  58 +var error = cu.launch(cuFunction, [3,1,1], [2,2,2],
  59 + [ { type: "DevicePtr", value: cuMem.devicePtr } ]);
62 60 console.log("Launched kernel:", error);
63 61
64 62

0 comments on commit a0d0cbd

Please sign in to comment.
Something went wrong with that request. Please try again.