diff options
author | Boris Fomitchev <borisfom@users.noreply.github.com> | 2016-11-24 01:38:57 +0300 |
---|---|---|
committer | Soumith Chintala <soumith@gmail.com> | 2016-11-24 01:38:57 +0300 |
commit | f5932241e86087821a4c61dbde2c39a03d7c9883 (patch) | |
tree | e36533a796dc81b1c3cf75a7bc04ea41006891c0 /init.c | |
parent | 2d75d411560df62f4ac291143f6b0f2e15378031 (diff) |
Implemented cudaMemGetInfo for caching allocator (#600)
* Implemented cudaMemGetInfo for caching allocator
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -698,13 +698,14 @@ static int cutorch_getMemoryUsage(lua_State *L) { size_t totalBytes = 0; int curDevice; THCudaCheck(cudaGetDevice(&curDevice)); + THCState *state = cutorch_getstate(L); int device = luaL_optint(L, 1, -10); if (device == -10) { /* no argument passed, current device mem usage */ - THCudaCheck(cudaMemGetInfo(&freeBytes, &totalBytes)); + THCudaCheck(THCudaMemGetInfo(state, &freeBytes, &totalBytes)); } else { /* argument was given, particular device's memory usage */ THCudaCheck(cudaSetDevice(device-1)); /* zero indexed */ - THCudaCheck(cudaMemGetInfo(&freeBytes, &totalBytes)); + THCudaCheck(THCudaMemGetInfo(state, &freeBytes, &totalBytes)); THCudaCheck(cudaSetDevice(curDevice)); } lua_pushnumber(L, freeBytes); |