Permalink
Browse files

Added CuCtxCreate().

  • Loading branch information...
1 parent 5f55e74 commit 45f901b32e5b7c2d3f6f2f9fc368290ee279ad64 @kashif committed Apr 23, 2011
Showing with 20 additions and 1 deletion.
  1. +10 −0 src/cuda_device.cpp
  2. +3 −0 src/cuda_device.hpp
  3. +7 −1 test/test.js
View
@@ -18,6 +18,7 @@ void CudaDevice::Initialize (Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(constructor_template, "GetName", CudaDevice::getName);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "TotalMem", CudaDevice::totalMem);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "ComputeCapability", CudaDevice::computeCapability);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "CtxCreate", CudaDevice::ctxCreate);
target->Set(String::NewSymbol("CudaDevice"), constructor_template->GetFunction());
}
@@ -79,4 +80,13 @@ Handle<Value> CudaDevice::totalMem(const Arguments& args) {
cuDeviceTotalMem(&totalGlobalMem, cu->m_device);
return scope.Close(Number::New(totalGlobalMem));
+}
+
+Handle<Value> CudaDevice::ctxCreate(const Arguments& args) {
+ HandleScope scope;
+
+ CudaDevice *cu = ObjectWrap::Unwrap<CudaDevice>(args.Holder());
+ CUresult error = cuCtxCreate(&(cu->m_context), 0, cu->m_device);
+
+ return scope.Close(Number::New(error));
}
View
@@ -17,16 +17,19 @@ class CudaDevice : public EventEmitter {
static Handle<Value> getName(const Arguments& args);
static Handle<Value> computeCapability(const Arguments& args);
static Handle<Value> totalMem(const Arguments& args);
+ static Handle<Value> ctxCreate(const Arguments& args);
CudaDevice() : EventEmitter () {
m_device = NULL;
+ m_context = NULL;
}
~CudaDevice(){
}
private:
CUdevice m_device;
+ CUcontext m_context;
};
#endif
View
@@ -10,9 +10,15 @@ console.log("Device count: " + count);
//cuDeviceGet
var cuDevice = new cu.CudaDevice(0);
+
//cuDeviceGetName
console.log("Device name: " + cuDevice.GetName());
console.log("Device total mem: " + cuDevice.TotalMem())
+//cuDeviceComputeCapability
var compute = cuDevice.ComputeCapability();
-console.log("Device compute capability: major=" + compute[0] + " minor=" + compute[1]);
+console.log("Device compute capability: major=" + compute[0] + " minor=" + compute[1]);
+
+//cuCtxCreate
+var error = cuDevice.CtxCreate();
+console.log("Ctx created with error code: " + error);

0 comments on commit 45f901b

Please sign in to comment.