Permalink
Browse files

Initial start on cuDeviceGet().

Getting error:
Symbol not found: __ZTV10CudaDevice
Expected in: flat namespace
  • Loading branch information...
1 parent 0c623a7 commit 58c0de77aa2b169af237b91e8e25adf4f3f6035c @kashif kashif committed Mar 5, 2011
Showing with 40 additions and 14 deletions.
  1. +25 −0 src/cuda_device.cpp
  2. +8 −11 src/cuda_device.hpp
  3. +7 −3 test/test.js
View
@@ -1,5 +1,23 @@
#include "cuda_device.hpp"
+Persistent<FunctionTemplate> CudaDevice::constructor_template;
+
+void CudaDevice::Initialize (Handle<Object> target) {
+ HandleScope scope;
+
+ Local<FunctionTemplate> t = FunctionTemplate::New(CudaDevice::New);
+ constructor_template = Persistent<FunctionTemplate>::New(t);
+ constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
+ constructor_template->SetClassName(String::NewSymbol("CudaDevice"));
+
+ cuInit(0);
+
+ NODE_SET_METHOD(target, "DriverGetVersion", driverGetVersion);
+ NODE_SET_METHOD(target, "DeviceGetCount", deviceGetCount);
+
+ target->Set(String::NewSymbol("CudaDevice"), constructor_template->GetFunction());
+}
+
Handle<Value> CudaDevice::driverGetVersion(const Arguments& args) {
HandleScope scope;
int driverVersion = 0;
@@ -12,4 +30,11 @@ Handle<Value> CudaDevice::deviceGetCount(const Arguments& args) {
int count = 0;
cuDeviceGetCount(&count);
return scope.Close(Integer::New(count));
+}
+
+Handle<Value> CudaDevice::New(const Arguments& args) {
+ HandleScope scope;
+ CudaDevice *cu = new CudaDevice();
+ cu->Wrap(args.This());
+ return args.This();
}
View
@@ -6,25 +6,22 @@
class CudaDevice : public EventEmitter {
public:
- static void Initialize (Handle<Object> target) {
- HandleScope scope;
-
- cuInit(0);
-
- NODE_SET_METHOD(target, "DriverGetVersion", driverGetVersion);
- NODE_SET_METHOD(target, "DeviceGetCount", deviceGetCount);
- }
+ static void Initialize (Handle<Object> target);
protected:
- CUdevice m_device;
+ static Persistent<FunctionTemplate> constructor_template;
- static v8::Handle<v8::Value> driverGetVersion(const v8::Arguments& args);
- static v8::Handle<v8::Value> deviceGetCount(const v8::Arguments& args);
+ static Handle<Value> New(const Arguments& args);
+ static Handle<Value> driverGetVersion(const Arguments& args);
+ static Handle<Value> deviceGetCount(const Arguments& args);
CudaDevice() : EventEmitter () {
m_device = NULL;
}
~CudaDevice();
+
+private:
+ CUdevice m_device;
};
#endif
View
@@ -1,7 +1,11 @@
var cu = require(__dirname + '/../build/default/binding');
-var driverVersion = cu.DriverGetVersion();
+var driverVersion = cu.DriverGetVersion(); //cuDriverGetVersion()
console.log("Driver version: " + driverVersion);
-var count = cu.DeviceGetCount();
-console.log("Device count: " + count);
+var count = cu.DeviceGetCount(); //cuDeviceGetCount
+console.log("Device count: " + count);
+
+
+var device = new cu.CudaDevice();
+//var device = new cu.DeviceGet(0); //cuDeviceGet(0)

0 comments on commit 58c0de7

Please sign in to comment.