Skip to content

Commit

Permalink
Enable the CUDA caching allocators by default
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
colesbury committed Dec 21, 2016
1 parent e63d033 commit 3b42b47
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3b42b47

Please sign in to comment.