mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Summary: This is to fix #16141 and similar issues. The idea is to track a reference to every shared CUDA Storage and deallocate memory only after a consumer process deallocates received Storage. ezyang Done with cleanup. Same (insignificantly better) performance as in file-per-share solution, but handles millions of shared tensors easily. Note [ ] documentation in progress. Pull Request resolved: https://github.com/pytorch/pytorch/pull/16854 Differential Revision: D13994490 Pulled By: VitalyFedyunin fbshipit-source-id: 565148ec3ac4fafb32d37fde0486b325bed6fbd1
36 lines
803 B
C++
36 lines
803 B
C++
#define __STDC_FORMAT_MACROS
|
|
|
|
#include <torch/csrc/python_headers.h>
|
|
#ifdef _MSC_VER
|
|
#include <Windows.h>
|
|
#endif
|
|
#include <structmember.h>
|
|
|
|
#define THP_HOST_HALF
|
|
|
|
#include <TH/TH.h>
|
|
// See Note [TH abstraction violation]
|
|
// - Used to get at the allocator associated with a storage
|
|
#include <TH/THStorageFunctions.hpp>
|
|
#include <libshm.h>
|
|
#include <torch/csrc/THP.h>
|
|
#include <torch/csrc/copy_utils.h>
|
|
#include <torch/csrc/DynamicTypes.h>
|
|
#include <torch/csrc/CudaIPCTypes.h>
|
|
|
|
#include <torch/csrc/generic/Storage.cpp>
|
|
#include <TH/THGenerateAllTypes.h>
|
|
|
|
#include <torch/csrc/generic/Storage.cpp>
|
|
#include <TH/THGenerateHalfType.h>
|
|
|
|
#include <torch/csrc/generic/Storage.cpp>
|
|
#include <TH/THGenerateBoolType.h>
|
|
|
|
template<>
|
|
void THPPointer<THStorage>::free() {
|
|
if (ptr) {
|
|
THStorage_free(ptr);
|
|
}
|
|
}
|