Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/cutorch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/THC/THCGeneral.c')
-rw-r--r--lib/THC/THCGeneral.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/THC/THCGeneral.c b/lib/THC/THCGeneral.c
index 26ba750..e99487e 100644
--- a/lib/THC/THCGeneral.c
+++ b/lib/THC/THCGeneral.c
@@ -848,6 +848,27 @@ cudaError_t THCudaFree(THCState *state, void *ptr)
return allocator->free(allocator->state, ptr);
}
+void* THCudaHostAlloc(THCState *state, size_t size)
+{
+ THCudaCheck(cudaGetLastError());
+ THAllocator* allocator = state->cudaHostAllocator;
+ return allocator->malloc(NULL, size);
+}
+
+void THCudaHostFree(THCState *state, void *ptr)
+{
+ THAllocator* allocator = state->cudaHostAllocator;
+ return allocator->free(NULL, ptr);
+}
+
+void THCudaHostRecord(THCState *state, void *ptr)
+{
+ if (state->cudaHostAllocator == &THCCachingHostAllocator) {
+ THCStream* stream = THCState_getStream(state);
+ THCCachingHostAllocator_recordEvent(ptr, stream);
+ }
+}
+
cudaError_t THCudaMemGetInfo(THCState *state, size_t* freeBytes, size_t* totalBytes)
{
size_t cachedBytes = 0;
@@ -932,4 +953,3 @@ float THC_half2float(half h)
TH_halfbits2float(&h.x, &f);
return f;
}
-