Implemented cudaMemGetInfo for caching allocator#600
Conversation
|
@soumith, @szagoruyko : this fix is ready to go in. |
| THCudaCheck(cudaMemGetInfo(&freeBytes, &totalBytes)); | ||
| } else { /* argument was given, particular device's memory usage */ | ||
| THCudaCheck(cudaSetDevice(device-1)); /* zero indexed */ | ||
| THCudaCheck(cudaMemGetInfo(&freeBytes, &totalBytes)); |
There was a problem hiding this comment.
in this whole file,
all you have to do is change this one line from cudaMemGetInfo to THCudaMemGetInfo along with a line above to get THCState. I dont see why all the other changes here are relevant or necessary, please revert those.
There was a problem hiding this comment.
Right, me trying to avoid code duplication here led to code bloat instead :). Cleaned up.
| @@ -158,12 +158,12 @@ struct THCCachingAllocator | |||
| allocated_blocks.erase(it); | |||
|
|
|||
There was a problem hiding this comment.
i think @colesbury had some reservations about this as well. this can be greatly simplified. i'll let him comment on monday.
There was a problem hiding this comment.
The only way to simplify it would be to introduce counter of free memory and update it on each allocation/deallocation.
That would be a sensible approach as well. I was shooting for a least intrusive method that does not add any complexity (and locks) to the main functionality.
There was a problem hiding this comment.
And , yes, the largest block size parameter is now unused.
@soumith , @colesbury: we can either purge it or hook it up for the user to actually get this info, let me know which way you prefer.
|
Thanks! |
I tested it with test_shutdown.lua