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
path: root/lib/THC
diff options
context:
space:
mode:
authorsoumith <soumith@fb.com>2016-10-25 03:16:17 +0300
committersoumith <soumith@fb.com>2016-10-25 03:16:17 +0300
commitdce6cd89aa78d308dd4360484ac21da3fc80c9d0 (patch)
tree3c4a77f866cb30cf512d9480b148b1e96f0a72af /lib/THC
parent21ad069fd0174acbcf956c82895dc8c4f1fa39ce (diff)
some bugfixes for THC
Diffstat (limited to 'lib/THC')
-rw-r--r--lib/THC/THCAllocator.c14
-rw-r--r--lib/THC/THCGeneral.c14
2 files changed, 10 insertions, 18 deletions
diff --git a/lib/THC/THCAllocator.c b/lib/THC/THCAllocator.c
index 1bed0fb..fa55c40 100644
--- a/lib/THC/THCAllocator.c
+++ b/lib/THC/THCAllocator.c
@@ -18,20 +18,8 @@ static void THCudaHostAllocator_free(void* ctx, void* ptr) {
THCudaCheck(cudaFreeHost(ptr));
}
-static void *THCudaHostAllocator_realloc(void* ctx, void* ptr, ptrdiff_t size) {
- if (size < 0) THError("Invalid memory size: %ld", size);
-
- THCudaHostAllocator_free(ctx, ptr);
-
- if (size == 0) return NULL;
-
- THCudaCheck(cudaMallocHost(&ptr, size));
-
- return ptr;
-}
-
void THCAllocator_init(THAllocator *cudaHostAllocator) {
cudaHostAllocator->malloc = &THCudaHostAllocator_alloc;
- cudaHostAllocator->realloc = &THCudaHostAllocator_realloc;
+ cudaHostAllocator->realloc = NULL;
cudaHostAllocator->free = &THCudaHostAllocator_free;
}
diff --git a/lib/THC/THCGeneral.c b/lib/THC/THCGeneral.c
index 2d478de..9b4764d 100644
--- a/lib/THC/THCGeneral.c
+++ b/lib/THC/THCGeneral.c
@@ -261,17 +261,21 @@ void THCudaEnablePeerToPeerAccess(THCState* state)
if (access) {
cudaError_t err = cudaDeviceEnablePeerAccess(j, 0);
if (err == cudaErrorPeerAccessAlreadyEnabled) {
+ /* It is possible that another thread has already enabled access. */
/* Any future call to cudaGetLastError will now return an error, */
/* even though we've already dealt with this specific error here. */
/* Call cudaGetLastError once to reset the last error state. */
cudaGetLastError();
- continue;
- }
- /* In case there are unknown errors returned from the above */
- THCudaCheck(err);
+ /* The above should have cleared status */
+ THCudaCheck(cudaGetLastError());
+ } else {
+ /* In case there are other unhandled errors returned from the */
+ /* above */
+ THCudaCheck(err);
+ }
- /* Access could be enabled */
+ /* Access could be enabled, or was already enabled */
state->p2pAccessEnabled[i][j] = 1;
}
}