Permalink
Browse files

whitespace fixes

  • Loading branch information...
kashif committed Jul 9, 2012
1 parent 56b3c9f commit 6728e7a6e4c56f75e4c3ac676e0599e8be722179
Showing with 148 additions and 149 deletions.
  1. +3 −3 index.js
  2. +2 −2 src/bindings.hpp
  3. +8 −8 src/ctx.cpp
  4. +29 −29 src/ctx.hpp
  5. +4 −4 src/device.cpp
  6. +17 −17 src/device.hpp
  7. +4 −4 src/function.cpp
  8. +13 −13 src/function.hpp
  9. +1 −1 src/mem.cpp
  10. +19 −19 src/mem.hpp
  11. +6 −6 src/module.cpp
  12. +19 −19 src/module.hpp
  13. +23 −24 test/test.js
View
@@ -43,12 +43,12 @@ function alignUp(offset, alignment) {
module.exports.prepareArguments = function (args) {
var paramBufferSize = 0;
-
+
for (var i in args) {
var type = args[i].type;
paramBufferSize = alignUp(paramBufferSize, typeAlignment[type]);
-
+
if (typeof(typeByteSize[type]) != "number")
throw "Invalid type given";
@@ -60,7 +60,7 @@ module.exports.prepareArguments = function (args) {
var offset = 0;
for (var i in args) {
var type = args[i].type;
-
+
offset = alignUp(offset, typeAlignment[type]);
if (type == "DevicePtr") {
View
@@ -9,8 +9,8 @@ using namespace node;
namespace NodeCuda {
-static Handle<Value> GetDriverVersion(Local<String> property, const AccessorInfo &info);
-static Handle<Value> GetDeviceCount(Local<String> property, const AccessorInfo &info);
+ static Handle<Value> GetDriverVersion(Local<String> property, const AccessorInfo &info);
+ static Handle<Value> GetDeviceCount(Local<String> property, const AccessorInfo &info);
}
View
@@ -7,7 +7,7 @@ Persistent<FunctionTemplate> Ctx::constructor_template;
void Ctx::Initialize(Handle<Object> target) {
HandleScope scope;
-
+
Local<FunctionTemplate> t = FunctionTemplate::New(Ctx::New);
constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
@@ -26,13 +26,13 @@ void Ctx::Initialize(Handle<Object> target) {
Handle<Value> Ctx::New(const Arguments& args) {
HandleScope scope;
-
+
Ctx *pctx = new Ctx();
pctx->Wrap(args.This());
-
+
unsigned int flags = args[0]->Uint32Value();
pctx->m_device = ObjectWrap::Unwrap<Device>(args[1]->ToObject())->m_device;
-
+
cuCtxCreate(&(pctx->m_context), flags, pctx->m_device);
return args.This();
@@ -121,18 +121,18 @@ void Ctx::EIO_Synchronize(eio_req *req) {
params->error = cuCtxPushCurrent(params->ctx->m_context);
if (params->error) return;
-
+
params->error = cuCtxSynchronize();
if (params->error) return;
-
+
params->error = cuCtxPopCurrent(NULL);
}
int Ctx::EIO_AfterSynchronize(eio_req *req) {
HandleScope scope;
SynchronizeParams *params = static_cast<SynchronizeParams*>(req->data);
ev_unref(EV_DEFAULT_UC);
-
+
params->ctx->Unref();
params->ctx->sync_in_progress = false;
@@ -158,6 +158,6 @@ Handle<Value> Ctx::GetApiVersion(Local<String> property, const AccessorInfo &inf
unsigned int version;
CUresult error = cuCtxGetApiVersion(pctx->m_context, &version);
-
+
return scope.Close(Number::New(version));
}
View
@@ -7,35 +7,35 @@
namespace NodeCuda {
-class Ctx : public ObjectWrap {
-public:
- static void Initialize(Handle<Object> target);
-
-protected:
- static Persistent<FunctionTemplate> constructor_template;
-
- static Handle<Value> New(const Arguments& args);
- static Handle<Value> Destroy(const Arguments& args);
- static Handle<Value> PushCurrent(const Arguments& args);
- static Handle<Value> PopCurrent(const Arguments& args);
- static Handle<Value> SetCurrent(const Arguments& args);
- static Handle<Value> GetCurrent(const Arguments& args);
- static Handle<Value> Synchronize(const Arguments& args);
- static Handle<Value> GetApiVersion(Local<String> property, const AccessorInfo &info);
-
- Ctx() : ObjectWrap(), m_context(NULL), m_device(0), sync_in_progress(false) {}
-
- ~Ctx () {}
-
-private:
- CUcontext m_context;
- CUdevice m_device;
-
- bool sync_in_progress;
-
- static void EIO_Synchronize(eio_req *req);
- static int EIO_AfterSynchronize(eio_req *req);
-};
+ class Ctx : public ObjectWrap {
+ public:
+ static void Initialize(Handle<Object> target);
+
+ protected:
+ static Persistent<FunctionTemplate> constructor_template;
+
+ static Handle<Value> New(const Arguments& args);
+ static Handle<Value> Destroy(const Arguments& args);
+ static Handle<Value> PushCurrent(const Arguments& args);
+ static Handle<Value> PopCurrent(const Arguments& args);
+ static Handle<Value> SetCurrent(const Arguments& args);
+ static Handle<Value> GetCurrent(const Arguments& args);
+ static Handle<Value> Synchronize(const Arguments& args);
+ static Handle<Value> GetApiVersion(Local<String> property, const AccessorInfo &info);
+
+ Ctx() : ObjectWrap(), m_context(NULL), m_device(0), sync_in_progress(false) {}
+
+ ~Ctx () {}
+
+ private:
+ CUcontext m_context;
+ CUdevice m_device;
+
+ bool sync_in_progress;
+
+ static void EIO_Synchronize(eio_req *req);
+ static int EIO_AfterSynchronize(eio_req *req);
+ };
}
View
@@ -22,7 +22,7 @@ void Device::Initialize(Handle<Object> target) {
static Handle<Value> GetName_(CUdevice device) {
HandleScope scope;
char deviceName[256];
-
+
cuDeviceGetName(deviceName, 256, device);
Local<String> result = String::New(deviceName);
return scope.Close(result);
@@ -36,7 +36,7 @@ Handle<Value> Device::New(const Arguments& args) {
if (!constructor_template->HasInstance(result)) {
result = constructor_template->InstanceTemplate()->NewInstance();
}
-
+
Device *pdevice = new Device();
cuDeviceGet(&(pdevice->m_device), ordinal);
@@ -50,7 +50,7 @@ Handle<Value> Device::GetComputeCapability(Local<String> property, const Accesso
Device *pdevice = ObjectWrap::Unwrap<Device>(info.Holder());
int major = 0, minor = 0;
cuDeviceComputeCapability(&major, &minor, pdevice->m_device);
-
+
Local<Object> result = Object::New();
result->Set(String::New("major"), Integer::New(major));
result->Set(String::New("minor"), Integer::New(minor));
@@ -70,6 +70,6 @@ Handle<Value> Device::GetTotalMem(Local<String> property, const AccessorInfo &in
Device *pdevice = ObjectWrap::Unwrap<Device>(info.Holder());
size_t totalGlobalMem;
cuDeviceTotalMem(&totalGlobalMem, pdevice->m_device);
-
+
return scope.Close(Number::New(totalGlobalMem));
}
View
@@ -6,30 +6,30 @@
namespace NodeCuda {
-class Device : public ObjectWrap {
-public:
- static void Initialize(Handle<Object> target);
+ class Device : public ObjectWrap {
+ public:
+ static void Initialize(Handle<Object> target);
-protected:
- static Persistent<FunctionTemplate> constructor_template;
+ protected:
+ static Persistent<FunctionTemplate> constructor_template;
- static Handle<Value> New(const Arguments& args);
- static Handle<Value> GetComputeCapability(Local<String> property, const AccessorInfo &info);
- static Handle<Value> GetName(Local<String> property, const AccessorInfo &info);
- static Handle<Value> GetTotalMem(Local<String> property, const AccessorInfo &info);
+ static Handle<Value> New(const Arguments& args);
+ static Handle<Value> GetComputeCapability(Local<String> property, const AccessorInfo &info);
+ static Handle<Value> GetName(Local<String> property, const AccessorInfo &info);
+ static Handle<Value> GetTotalMem(Local<String> property, const AccessorInfo &info);
- // TODO: cuDeviceGetAttribute
- // TODO: cuDeviceGetProperties
+ // TODO: cuDeviceGetAttribute
+ // TODO: cuDeviceGetProperties
- Device() : ObjectWrap(), m_device(NULL) {}
+ Device() : ObjectWrap(), m_device(NULL) {}
- ~Device() {}
+ ~Device() {}
-private:
- CUdevice m_device;
+ private:
+ CUdevice m_device;
- friend class Ctx;
-};
+ friend class Ctx;
+ };
}
View
@@ -15,7 +15,7 @@ void NodeCuda::Function::Initialize(Handle<Object> target) {
constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
constructor_template->SetClassName(String::NewSymbol("CudaFunction"));
-
+
NODE_SET_PROTOTYPE_METHOD(constructor_template, "launchKernel", NodeCuda::Function::LaunchKernel);
// Function objects can only be created by cuModuleGetFunction
@@ -55,9 +55,9 @@ Handle<Value> NodeCuda::Function::LaunchKernel(const Arguments& args) {
};
CUresult error = cuLaunchKernel(pfunction->m_function,
- gridDimX, gridDimY, gridDimZ,
- blockDimX, blockDimY, blockDimZ,
- 0, 0, NULL, cuExtra);
+ gridDimX, gridDimY, gridDimZ,
+ blockDimX, blockDimY, blockDimZ,
+ 0, 0, NULL, cuExtra);
return scope.Close(Number::New(error));
}
View
@@ -7,26 +7,26 @@
namespace NodeCuda {
-class Function : public ObjectWrap {
-public:
- static void Initialize(Handle<Object> target);
+ class Function : public ObjectWrap {
+ public:
+ static void Initialize(Handle<Object> target);
-protected:
- static Persistent<FunctionTemplate> constructor_template;
+ protected:
+ static Persistent<FunctionTemplate> constructor_template;
- static Handle<Value> LaunchKernel(const Arguments& args);
+ static Handle<Value> LaunchKernel(const Arguments& args);
- Function() : ObjectWrap(), m_function(0) {}
+ Function() : ObjectWrap(), m_function(0) {}
- ~Function() {}
+ ~Function() {}
-private:
- static Handle<Value> New(const Arguments& args);
+ private:
+ static Handle<Value> New(const Arguments& args);
- CUfunction m_function;
+ CUfunction m_function;
- friend Handle<Value> Module::GetFunction(const Arguments&);
-};
+ friend Handle<Value> Module::GetFunction(const Arguments&);
+ };
}
View
@@ -17,7 +17,7 @@ void Mem::Initialize(Handle<Object> target) {
// Mem objects can only be created by allocation functions
NODE_SET_METHOD(target, "memAlloc", Mem::Alloc);
NODE_SET_METHOD(target, "memAllocPitch", Mem::AllocPitch);
-
+
constructor_template->InstanceTemplate()->SetAccessor(String::New("devicePtr"), Mem::GetDevicePtr);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "free", Mem::Free);
View
@@ -7,32 +7,32 @@
namespace NodeCuda {
-class Mem : public ObjectWrap {
-public:
- static void Initialize(Handle<Object> target);
+ class Mem : public ObjectWrap {
+ public:
+ static void Initialize(Handle<Object> target);
-protected:
- static Persistent<FunctionTemplate> constructor_template;
+ protected:
+ static Persistent<FunctionTemplate> constructor_template;
- static Handle<Value> Alloc(const Arguments& args);
- static Handle<Value> AllocPitch(const Arguments& args);
- static Handle<Value> Free(const Arguments& args);
- static Handle<Value> CopyHtoD(const Arguments& args);
- static Handle<Value> CopyDtoH(const Arguments& args);
+ static Handle<Value> Alloc(const Arguments& args);
+ static Handle<Value> AllocPitch(const Arguments& args);
+ static Handle<Value> Free(const Arguments& args);
+ static Handle<Value> CopyHtoD(const Arguments& args);
+ static Handle<Value> CopyDtoH(const Arguments& args);
- static Handle<Value> GetDevicePtr(Local<String> property, const AccessorInfo &info);
-
- Mem() : ObjectWrap(), m_devicePtr(0) {}
+ static Handle<Value> GetDevicePtr(Local<String> property, const AccessorInfo &info);
- ~Mem() {}
+ Mem() : ObjectWrap(), m_devicePtr(0) {}
-private:
- static Handle<Value> New(const Arguments& args);
+ ~Mem() {}
- CUdeviceptr m_devicePtr;
+ private:
+ static Handle<Value> New(const Arguments& args);
- friend class NodeCuda::Function;
-};
+ CUdeviceptr m_devicePtr;
+
+ friend class NodeCuda::Function;
+ };
}
Oops, something went wrong.

0 comments on commit 6728e7a

Please sign in to comment.