Skip to content

Commit 7263bb7

Browse files
committed
WIP
1 parent 2b9b18d commit 7263bb7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/registered_memory.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,15 @@ RegisteredMemory::Impl::Impl(const std::vector<char>& serialization) {
277277

278278
RegisteredMemory::Impl::~Impl() {
279279
// Close the CUDA IPC handle if it was opened during deserialization
280-
if (data && transports.has(Transport::CudaIpc) && getHostHash() == this->hostHash && getPidHash() != this->pidHash) {
280+
if (data && transports.has(Transport::CudaIpc) && getHostHash() == this->hostHash) {
281+
if (getPidHash() == this->pidHash) {
282+
// For local registered memory
283+
if (fileDesc >= 0) {
284+
close(fileDesc);
285+
fileDesc = -1;
286+
}
287+
return;
288+
}
281289
void* base = static_cast<char*>(data) - getTransportInfo(Transport::CudaIpc).cudaIpcOffsetFromBase;
282290
if (this->isCuMemMapAlloc) {
283291
CUmemGenericAllocationHandle handle;
@@ -288,9 +296,6 @@ RegisteredMemory::Impl::~Impl() {
288296
MSCCLPP_CULOG_WARN(cuMemUnmap((CUdeviceptr)base, size));
289297
MSCCLPP_CULOG_WARN(cuMemRelease(handle));
290298
MSCCLPP_CULOG_WARN(cuMemAddressFree((CUdeviceptr)base, size));
291-
if (getNvlsMemHandleType() == CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR && fileDesc >= 0) {
292-
close(fileDesc);
293-
}
294299
} else {
295300
cudaError_t err = cudaIpcCloseMemHandle(base);
296301
if (err != cudaSuccess) {

0 commit comments

Comments
 (0)