未验证 提交 9a001c09 编写于 作者: F From00 提交者: GitHub

Remove macro for GetGpuBasePtr (#39279)

上级 45f9c9eb
...@@ -244,17 +244,20 @@ class RecordedGpuMallocHelper { ...@@ -244,17 +244,20 @@ class RecordedGpuMallocHelper {
#endif #endif
} }
#ifdef PADDLE_WITH_TESTING
void *GetBasePtr(void *ptr) { void *GetBasePtr(void *ptr) {
#ifdef PADDLE_WITH_TESTING
auto it = gpu_ptrs.upper_bound(ptr); auto it = gpu_ptrs.upper_bound(ptr);
if (it == gpu_ptrs.begin()) { if (it == gpu_ptrs.begin()) {
return nullptr; return nullptr;
} }
return *(--it); return *(--it);
} #else
PADDLE_THROW(platform::errors::Unimplemented(
"The RecordedGpuMallocHelper::GetBasePtr is only implemented with "
"testing, should not use for release."));
return nullptr;
#endif #endif
}
bool GetMemInfo(size_t *avail, size_t *total, size_t *actual_avail, bool GetMemInfo(size_t *avail, size_t *total, size_t *actual_avail,
size_t *actual_total) { size_t *actual_total) {
...@@ -375,11 +378,9 @@ void EmptyCache(void) { ...@@ -375,11 +378,9 @@ void EmptyCache(void) {
} }
} }
#ifdef PADDLE_WITH_TESTING
void *GetGpuBasePtr(void *ptr, int dev_id) { void *GetGpuBasePtr(void *ptr, int dev_id) {
return RecordedGpuMallocHelper::Instance(dev_id)->GetBasePtr(ptr); return RecordedGpuMallocHelper::Instance(dev_id)->GetBasePtr(ptr);
} }
#endif
} // namespace platform } // namespace platform
} // namespace paddle } // namespace paddle
...@@ -145,10 +145,9 @@ bool IsGpuMallocRecorded(int dev_id); ...@@ -145,10 +145,9 @@ bool IsGpuMallocRecorded(int dev_id);
//! Empty idle cached memory held by the allocator. //! Empty idle cached memory held by the allocator.
void EmptyCache(void); void EmptyCache(void);
//! Get the primitive pointer return from cudaMalloc, just for testing //! Get the primitive pointer return from cudaMalloc, just implemented with
#ifdef PADDLE_WITH_TESTING //! testing, do not use for release
void *GetGpuBasePtr(void *ptr, int dev_id); void *GetGpuBasePtr(void *ptr, int dev_id);
#endif
} // namespace platform } // namespace platform
} // namespace paddle } // namespace paddle
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册