@@ -871,10 +871,16 @@ void THCudaHostRecord(THCState *state, void *ptr)
871871
872872cudaError_t THCudaMemGetInfo (THCState * state , size_t * freeBytes , size_t * totalBytes )
873873{
874- size_t cachedBytes = 0 ;
875874 size_t largestBlock = 0 ;
875+ return THCudaMemGetInfoCached (state , freeBytes , totalBytes , & largestBlock );
876+ }
877+
878+ cudaError_t THCudaMemGetInfoCached (THCState * state , size_t * freeBytes , size_t * totalBytes , size_t * largestBlock )
879+ {
880+ size_t cachedBytes = 0 ;
876881 THCDeviceAllocator * allocator = state -> cudaDeviceAllocator ;
877882
883+ * largestBlock = 0 ;
878884 /* get info from CUDA first */
879885 cudaError_t ret = cudaMemGetInfo (freeBytes , totalBytes );
880886 if (ret != cudaSuccess )
@@ -886,11 +892,11 @@ cudaError_t THCudaMemGetInfo(THCState *state, size_t* freeBytes, size_t* totalB
886892 return ret ;
887893
888894 /* not always true - our optimistic guess here */
889- largestBlock = * freeBytes ;
895+ * largestBlock = * freeBytes ;
890896
891897 if (allocator -> cacheInfo != NULL )
892- allocator -> cacheInfo (allocator -> state , device , & cachedBytes , & largestBlock );
893-
898+ allocator -> cacheInfo (allocator -> state , device , & cachedBytes , largestBlock );
899+
894900 /* Adjust resulting free bytes number. largesBlock unused for now */
895901 * freeBytes += cachedBytes ;
896902 return cudaSuccess ;
0 commit comments