pytorch/c10
Michael Carilli cedfa4ccd8 Make DeviceCachingAllocator's error handling more defensive and a bit easier to read (#51158)
Summary:
^
Currently, `alloc_block`'s error handling has a couple (imo) minor flaws.  It might clear the error state even if the error had nothing to do with memory allocation. It might also clear the error state even if it didn't attempt a cudaMalloc, meaning it might clear an error state that came from some completely unrelated earlier cuda call.

The diffs and comments are the best explanation of my preferred (new) error-checking policy.

The diffs add very little work to the common (successful, allocation satisfied by existing block) hot path.  Most of the additional logic occurs in `alloc_block`, which is a slow path anyway (it tries cudaMalloc).

Pull Request resolved: https://github.com/pytorch/pytorch/pull/51158

Reviewed By: malfet, heitorschueroff

Differential Revision: D26101515

Pulled By: ezyang

fbshipit-source-id: 6b447f1770974a04450376afd9726be87af83c48
2021-01-28 10:54:20 -08:00
..
benchmark Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521) 2020-03-27 14:25:17 -07:00
core [pytorch] change codegen dispatch key from string to enum (#51115) 2021-01-27 22:28:52 -08:00
cuda Make DeviceCachingAllocator's error handling more defensive and a bit easier to read (#51158) 2021-01-28 10:54:20 -08:00
hip Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521) 2020-03-27 14:25:17 -07:00
macros Introducing TORCH_CUDA_CPP_API and TORCH_CUDA_CU_API to the code (#50627) 2021-01-21 19:09:11 -08:00
mobile [c10/**] Fix typos (#49815) 2021-01-01 02:11:56 -08:00
test Generalize sum_intlist and prod_intlist, clean up dimensionality functions (#50495) 2021-01-19 22:35:55 -08:00
util Create a DDPLoggingData and expose it to python interface (#50622) 2021-01-25 15:23:07 -08:00
CMakeLists.txt [c10/**] Fix typos (#49815) 2021-01-01 02:11:56 -08:00