From 9a001c09349f23b16a1fe89427e29a3e0b562650 Mon Sep 17 00:00:00 2001 From: From00 Date: Fri, 28 Jan 2022 16:47:02 +0800 Subject: [PATCH] Remove macro for GetGpuBasePtr (#39279) --- paddle/fluid/platform/device/gpu/gpu_info.cc | 13 +++++++------ paddle/fluid/platform/device/gpu/gpu_info.h | 5 ++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/paddle/fluid/platform/device/gpu/gpu_info.cc b/paddle/fluid/platform/device/gpu/gpu_info.cc index e09d07a6e39..6e6824ed789 100644 --- a/paddle/fluid/platform/device/gpu/gpu_info.cc +++ b/paddle/fluid/platform/device/gpu/gpu_info.cc @@ -244,17 +244,20 @@ class RecordedGpuMallocHelper { #endif } -#ifdef PADDLE_WITH_TESTING void *GetBasePtr(void *ptr) { +#ifdef PADDLE_WITH_TESTING auto it = gpu_ptrs.upper_bound(ptr); - if (it == gpu_ptrs.begin()) { return nullptr; } - return *(--it); - } +#else + PADDLE_THROW(platform::errors::Unimplemented( + "The RecordedGpuMallocHelper::GetBasePtr is only implemented with " + "testing, should not use for release.")); + return nullptr; #endif + } bool GetMemInfo(size_t *avail, size_t *total, size_t *actual_avail, size_t *actual_total) { @@ -375,11 +378,9 @@ void EmptyCache(void) { } } -#ifdef PADDLE_WITH_TESTING void *GetGpuBasePtr(void *ptr, int dev_id) { return RecordedGpuMallocHelper::Instance(dev_id)->GetBasePtr(ptr); } -#endif } // namespace platform } // namespace paddle diff --git a/paddle/fluid/platform/device/gpu/gpu_info.h b/paddle/fluid/platform/device/gpu/gpu_info.h index 9bc4d70bc45..1e072625ada 100644 --- a/paddle/fluid/platform/device/gpu/gpu_info.h +++ b/paddle/fluid/platform/device/gpu/gpu_info.h @@ -145,10 +145,9 @@ bool IsGpuMallocRecorded(int dev_id); //! Empty idle cached memory held by the allocator. void EmptyCache(void); -//! Get the primitive pointer return from cudaMalloc, just for testing -#ifdef PADDLE_WITH_TESTING +//! Get the primitive pointer return from cudaMalloc, just implemented with +//! testing, do not use for release void *GetGpuBasePtr(void *ptr, int dev_id); -#endif } // namespace platform } // namespace paddle -- GitLab