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/init.c
diff options
context:
space:
mode:
authorSam Gross <sgross@fb.com>2016-12-22 00:55:55 +0300
committerSam Gross <sgross@fb.com>2016-12-22 00:55:55 +0300
commit3b42b47a834f57a3e712ce69552e9b0bca4b476d (patch)
treeb6f4ce0f73859bb9b944dc5e8621470c86c6bade /init.c
parente63d033cddff79d9a6c1d61ffe96586a73288ef1 (diff)
Enable the CUDA caching allocators by default
A few of us have been using this extensively without problems. This avoids synchronizations due to cudaFree calls which makes it much easier to write performant CUDA code.
Diffstat (limited to 'init.c')
-rw-r--r--init.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/init.c b/init.c
index 7be0823..28ec26f 100644
--- a/init.c
+++ b/init.c
@@ -1003,8 +1003,9 @@ int luaopen_libcutorch(lua_State *L)
THCState* state = THCState_alloc();
+ /* Enable the caching allocator unless THC_CACHING_ALLOCATOR=0 */
char* thc_caching_allocator = getenv("THC_CACHING_ALLOCATOR");
- if (thc_caching_allocator && strcmp(thc_caching_allocator, "1") == 0) {
+ if (!thc_caching_allocator || strcmp(thc_caching_allocator, "0") != 0) {
THCState_setDeviceAllocator(state, THCCachingAllocator_get());
state->cudaHostAllocator = &THCCachingHostAllocator;
}