Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added asynchronous memcpy

  • Loading branch information...
commit 457c4b17a81376f0723fb7dc7dee5d110848e3ee 1 parent a691386
@r2jitu r2jitu authored
Showing with 17 additions and 3 deletions.
  1. +16 −2 src/mem.cpp
  2. +1 −1  test/test.js
View
18 src/mem.cpp
@@ -83,7 +83,14 @@ Handle<Value> Mem::CopyHtoD(const Arguments& args) {
char *phost = Buffer::Data(buf);
size_t bytes = Buffer::Length(buf);
- CUresult error = cuMemcpyHtoD(pmem->m_devicePtr, phost, bytes);
+ bool async = args.Length() >= 2 && args[1]->IsTrue();
+
+ CUresult error;
+ if (async) {
+ error = cuMemcpyHtoDAsync(pmem->m_devicePtr, phost, bytes, 0);
+ } else {
+ error = cuMemcpyHtoD(pmem->m_devicePtr, phost, bytes);
+ }
return scope.Close(Number::New(error));
}
@@ -96,7 +103,14 @@ Handle<Value> Mem::CopyDtoH(const Arguments& args) {
char *phost = Buffer::Data(buf);
size_t bytes = Buffer::Length(buf);
- CUresult error = cuMemcpyDtoH(phost, pmem->m_devicePtr, bytes);
+ bool async = args.Length() >= 2 && args[1]->IsTrue();
+
+ CUresult error;
+ if (async) {
+ error = cuMemcpyDtoHAsync(phost, pmem->m_devicePtr, bytes, 0);
+ } else {
+ error = cuMemcpyDtoH(phost, pmem->m_devicePtr, bytes);
+ }
return scope.Close(Number::New(error));
}
View
2  test/test.js
@@ -66,7 +66,7 @@ console.log("Launched kernel:", error);
// cuMemcpyDtoH
-var error = cuMem.copyDtoH(buf);
+var error = cuMem.copyDtoH(buf, true);
console.log("Copied buffer to host:", error);
//cuCtxSynchronize

0 comments on commit 457c4b1

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