Browse files

Added ComputeCapability().

  • Loading branch information...
1 parent 4e737ee commit 5f55e743f6c74e22848d4d6d897d450c0151b931 @kashif committed Mar 20, 2011
Showing with 18 additions and 0 deletions.
  1. +14 −0 src/cuda_device.cpp
  2. +1 −0 src/cuda_device.hpp
  3. +3 −0 test/test.js
View
14 src/cuda_device.cpp
@@ -17,6 +17,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);
target->Set(String::NewSymbol("CudaDevice"), constructor_template->GetFunction());
}
@@ -57,6 +58,19 @@ Handle<Value> CudaDevice::getName(const Arguments& args) {
return scope.Close(result);
}
+Handle<Value> CudaDevice::computeCapability(const Arguments& args) {
+ HandleScope scope;
+
+ CudaDevice *cu = ObjectWrap::Unwrap<CudaDevice>(args.Holder());
+ int major = 0, minor = 0;
+ cuDeviceComputeCapability(&major, &minor, cu->m_device);
+
+ Local<Array> result = Array::New(2);
+ result->Set(Integer::New(0), Integer::New(major));
+ result->Set(Integer::New(1), Integer::New(minor));
+ return scope.Close(result);
+}
+
Handle<Value> CudaDevice::totalMem(const Arguments& args) {
HandleScope scope;
View
1 src/cuda_device.hpp
@@ -15,6 +15,7 @@ class CudaDevice : public EventEmitter {
static Handle<Value> driverGetVersion(const Arguments& args);
static Handle<Value> deviceGetCount(const Arguments& args);
static Handle<Value> getName(const Arguments& args);
+ static Handle<Value> computeCapability(const Arguments& args);
static Handle<Value> totalMem(const Arguments& args);
CudaDevice() : EventEmitter () {
View
3 test/test.js
@@ -13,3 +13,6 @@ var cuDevice = new cu.CudaDevice(0);
//cuDeviceGetName
console.log("Device name: " + cuDevice.GetName());
console.log("Device total mem: " + cuDevice.TotalMem())
+
+var compute = cuDevice.ComputeCapability();
+console.log("Device compute capability: major=" + compute[0] + " minor=" + compute[1]);

0 comments on commit 5f55e74

Please sign in to comment.