From b0911ecb45dae20898929cf58c279666056e528e Mon Sep 17 00:00:00 2001 From: sneaxiy <32832641+sneaxiy@users.noreply.github.com> Date: Mon, 17 Apr 2023 16:30:55 +0800 Subject: [PATCH] Add unique counter for shared memory used in DataLoader (#52976) * fix ipc counter * fix missing std::to_string --- paddle/fluid/memory/allocation/mmap_allocator.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paddle/fluid/memory/allocation/mmap_allocator.cc b/paddle/fluid/memory/allocation/mmap_allocator.cc index 1197098a4d8..2e091fa1b2f 100644 --- a/paddle/fluid/memory/allocation/mmap_allocator.cc +++ b/paddle/fluid/memory/allocation/mmap_allocator.cc @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -34,12 +35,15 @@ namespace allocation { std::string GetIPCName() { static std::random_device rd; + static std::atomic counter{0}; std::string handle = "/paddle_"; #ifdef _WIN32 handle += std::to_string(GetCurrentProcessId()); #else handle += std::to_string(getpid()); #endif + handle += "_"; + handle += std::to_string(counter.fetch_add(1)); handle += "_"; handle += std::to_string(rd()); return handle; -- GitLab