From 8a286140b3909b96088a90f3ea04294a33cbc085 Mon Sep 17 00:00:00 2001 From: Liyulingyue <852433440@qq.com> Date: Sat, 24 Feb 2024 13:09:37 +0800 Subject: [PATCH 01/16] MV CC INTO PADDLE --- paddle/fluid/memory/stats.h | 6 ++++-- test/cpp/fluid/memory/CMakeLists.txt | 10 ++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/paddle/fluid/memory/stats.h b/paddle/fluid/memory/stats.h index b6d722b62a4b0..b7eb4b0be2baa 100644 --- a/paddle/fluid/memory/stats.h +++ b/paddle/fluid/memory/stats.h @@ -127,8 +127,10 @@ void DeviceMemoryStatUpdate(const std::string& stat_type, int dev_id, int64_t increment); -int64_t HostMemoryStatCurrentValue(const std::string& stat_type, int dev_id); -int64_t HostMemoryStatPeakValue(const std::string& stat_type, int dev_id); +TEST_API int64_t HostMemoryStatCurrentValue(const std::string& stat_type, + int dev_id); +TEST_API int64_t HostMemoryStatPeakValue(const std::string& stat_type, + int dev_id); void HostMemoryStatUpdate(const std::string& stat_type, int dev_id, int64_t increment); diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index 5bb36f7398228..bf312bc85b71b 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -1,11 +1,5 @@ -cc_test( - memory_stats_test - SRCS memory_stats_test.cc - DEPS) -cc_test( - stats_test - SRCS stats_test.cc - DEPS) +paddle_test(memory_stats_test SRCS memory_stats_test.cc) +paddle_test(stats_test SRCS stats_test.cc) cc_test( naive_best_fit_allocator_test From 83b3fa4a8e07398c7b44b8188c5a2fed9d43b5f8 Mon Sep 17 00:00:00 2001 From: Liyulingyue <852433440@qq.com> Date: Sat, 24 Feb 2024 15:57:21 +0800 Subject: [PATCH 02/16] cc to paddle --- paddle/fluid/memory/stats.h | 18 ++++++++++-------- test/cpp/fluid/memory/CMakeLists.txt | 10 ++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/paddle/fluid/memory/stats.h b/paddle/fluid/memory/stats.h index b7eb4b0be2baa..1416ec1e03472 100644 --- a/paddle/fluid/memory/stats.h +++ b/paddle/fluid/memory/stats.h @@ -121,19 +121,21 @@ class Stat : public StatBase { // performance than the macro function xxx_MEMORY_STAT_CURRENT_VALUE, // xxx_MEMORY_STAT_PEAK_VALUE, and xxx_MEMORY_STAT_UPDATE. Try to use the macro // functions where ultra-low performance overhead is required. -int64_t DeviceMemoryStatCurrentValue(const std::string& stat_type, int dev_id); -int64_t DeviceMemoryStatPeakValue(const std::string& stat_type, int dev_id); -void DeviceMemoryStatUpdate(const std::string& stat_type, - int dev_id, - int64_t increment); +TEST_API int64_t DeviceMemoryStatCurrentValue(const std::string& stat_type, + int dev_id); +TEST_API int64_t DeviceMemoryStatPeakValue(const std::string& stat_type, + int dev_id); +TEST_API void DeviceMemoryStatUpdate(const std::string& stat_type, + int dev_id, + int64_t increment); TEST_API int64_t HostMemoryStatCurrentValue(const std::string& stat_type, int dev_id); TEST_API int64_t HostMemoryStatPeakValue(const std::string& stat_type, int dev_id); -void HostMemoryStatUpdate(const std::string& stat_type, - int dev_id, - int64_t increment); +TEST_API void HostMemoryStatUpdate(const std::string& stat_type, + int dev_id, + int64_t increment); void LogDeviceMemoryStats(const platform::Place& place, const std::string& op_name); diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index bf312bc85b71b..adcb6f960db4a 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -1,14 +1,8 @@ paddle_test(memory_stats_test SRCS memory_stats_test.cc) paddle_test(stats_test SRCS stats_test.cc) -cc_test( - naive_best_fit_allocator_test - SRCS naive_best_fit_allocator_test.cc - DEPS allocator) -cc_test( - buffered_allocator_test - SRCS buffered_allocator_test.cc - DEPS allocator) +paddle_test(naive_best_fit_allocator_test SRCS naive_best_fit_allocator_test.cc) +paddle_test(buffered_allocator_test SRCS buffered_allocator_test.cc) if(WITH_GPU) nv_test( From ed1f3a99ef3d96817d7fce3d04505537a4cbcf56 Mon Sep 17 00:00:00 2001 From: Liyulingyue <852433440@qq.com> Date: Sat, 24 Feb 2024 18:50:45 +0800 Subject: [PATCH 03/16] add test_API --- paddle/fluid/memory/allocation/allocator.h | 2 +- paddle/fluid/memory/allocation/best_fit_allocator.h | 2 +- paddle/fluid/memory/allocation/buffered_allocator.h | 4 ++-- paddle/fluid/memory/allocation/cpu_allocator.h | 4 ++-- paddle/fluid/memory/allocation/naive_best_fit_allocator.h | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/paddle/fluid/memory/allocation/allocator.h b/paddle/fluid/memory/allocation/allocator.h index 693c1cd47b0de..d61380608c01b 100644 --- a/paddle/fluid/memory/allocation/allocator.h +++ b/paddle/fluid/memory/allocation/allocator.h @@ -195,7 +195,7 @@ class Allocator : public phi::Allocator { protected: virtual phi::Allocation* AllocateImpl(size_t size) = 0; - virtual void FreeImpl(phi::Allocation* allocation); + TEST_API virtual void FreeImpl(phi::Allocation* allocation); virtual uint64_t ReleaseImpl(const platform::Place& place UNUSED) { return 0; } diff --git a/paddle/fluid/memory/allocation/best_fit_allocator.h b/paddle/fluid/memory/allocation/best_fit_allocator.h index 7e3a18955ac67..97545f55a45f8 100644 --- a/paddle/fluid/memory/allocation/best_fit_allocator.h +++ b/paddle/fluid/memory/allocation/best_fit_allocator.h @@ -105,7 +105,7 @@ class BestFitAllocation : public Allocation { // the prev-chunk and the next-chunk when possible. class BestFitAllocator : public Allocator { public: - explicit BestFitAllocator(phi::Allocation* allocation); + TEST_API explicit BestFitAllocator(phi::Allocation* allocation); void* BasePtr() const { return allocation_->ptr(); } diff --git a/paddle/fluid/memory/allocation/buffered_allocator.h b/paddle/fluid/memory/allocation/buffered_allocator.h index 08a005dc79359..f15f3e1006848 100644 --- a/paddle/fluid/memory/allocation/buffered_allocator.h +++ b/paddle/fluid/memory/allocation/buffered_allocator.h @@ -32,7 +32,7 @@ namespace allocation { // underlying_allocator_ class BufferedAllocator : public Allocator { public: - explicit BufferedAllocator(std::shared_ptr allocator); + TEST_API explicit BufferedAllocator(std::shared_ptr allocator); ~BufferedAllocator(); @@ -42,7 +42,7 @@ class BufferedAllocator : public Allocator { inline void ClearCache() { FreeCache(-1UL); } private: - void FreeCache(size_t size); + TEST_API void FreeCache(size_t size); protected: void FreeImpl(phi::Allocation *allocation) override; diff --git a/paddle/fluid/memory/allocation/cpu_allocator.h b/paddle/fluid/memory/allocation/cpu_allocator.h index 30e367f6e7f7c..24678ba3433c0 100644 --- a/paddle/fluid/memory/allocation/cpu_allocator.h +++ b/paddle/fluid/memory/allocation/cpu_allocator.h @@ -34,11 +34,11 @@ namespace allocation { class CPUAllocator : public Allocator { public: constexpr static size_t kAlignment = 4096UL; - bool IsAllocThreadSafe() const override; + TEST_API bool IsAllocThreadSafe() const override; protected: void FreeImpl(phi::Allocation* allocation) override; - phi::Allocation* AllocateImpl(size_t size) override; + TEST_API phi::Allocation* AllocateImpl(size_t size) override; }; } // namespace allocation } // namespace memory diff --git a/paddle/fluid/memory/allocation/naive_best_fit_allocator.h b/paddle/fluid/memory/allocation/naive_best_fit_allocator.h index 3d6500d0f5642..7a16287c75cb3 100644 --- a/paddle/fluid/memory/allocation/naive_best_fit_allocator.h +++ b/paddle/fluid/memory/allocation/naive_best_fit_allocator.h @@ -35,9 +35,9 @@ class NaiveBestFitAllocator : public Allocator { bool IsAllocThreadSafe() const override { return true; } protected: - phi::Allocation *AllocateImpl(size_t size) override; - void FreeImpl(phi::Allocation *allocation) override; - uint64_t ReleaseImpl(const platform::Place &place) override; + TEST_API phi::Allocation *AllocateImpl(size_t size) override; + TEST_API void FreeImpl(phi::Allocation *allocation) override; + TEST_API uint64_t ReleaseImpl(const platform::Place &place) override; private: platform::Place place_; From 45f5669dcced6005e06ee6c59769effbbf170377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Sun, 25 Feb 2024 00:10:09 +0800 Subject: [PATCH 04/16] Apply suggestions from code review --- test/cpp/fluid/memory/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index adcb6f960db4a..0c23c91054c25 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -2,7 +2,10 @@ paddle_test(memory_stats_test SRCS memory_stats_test.cc) paddle_test(stats_test SRCS stats_test.cc) paddle_test(naive_best_fit_allocator_test SRCS naive_best_fit_allocator_test.cc) -paddle_test(buffered_allocator_test SRCS buffered_allocator_test.cc) +cc_test( + buffered_allocator_test + SRCS buffered_allocator_test.cc + DEPS allocator) if(WITH_GPU) nv_test( From 7ed08c5f59483c0fc8c00c3e46832a1a110f3989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Sun, 25 Feb 2024 07:07:57 +0800 Subject: [PATCH 05/16] Update CMakeLists.txt --- test/cpp/fluid/memory/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index 0c23c91054c25..02b5402205e68 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -1,7 +1,7 @@ paddle_test(memory_stats_test SRCS memory_stats_test.cc) paddle_test(stats_test SRCS stats_test.cc) -paddle_test(naive_best_fit_allocator_test SRCS naive_best_fit_allocator_test.cc) +paddle_test(naive_best_fit_allocator_test SRCS naive_best_fit_allocator_test.cc DEPS allocator) cc_test( buffered_allocator_test SRCS buffered_allocator_test.cc From a08e45629ed84aea56c556dfa56bad25e9a35250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Tue, 27 Feb 2024 01:46:55 +0800 Subject: [PATCH 06/16] Update CMakeLists.txt --- test/cpp/fluid/memory/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index 02b5402205e68..2e1e368738d11 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -2,10 +2,7 @@ paddle_test(memory_stats_test SRCS memory_stats_test.cc) paddle_test(stats_test SRCS stats_test.cc) paddle_test(naive_best_fit_allocator_test SRCS naive_best_fit_allocator_test.cc DEPS allocator) -cc_test( - buffered_allocator_test - SRCS buffered_allocator_test.cc - DEPS allocator) +paddle_test(buffered_allocator_test SRCS buffered_allocator_test.cc DEPS allocator) if(WITH_GPU) nv_test( From 1c37e0a9fa077e3870070893a9a51f4dedef162b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Fri, 1 Mar 2024 18:49:45 +0800 Subject: [PATCH 07/16] Apply suggestions from code review --- test/cpp/fluid/memory/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index 2e1e368738d11..b6a2cb15f7fa9 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -2,7 +2,10 @@ paddle_test(memory_stats_test SRCS memory_stats_test.cc) paddle_test(stats_test SRCS stats_test.cc) paddle_test(naive_best_fit_allocator_test SRCS naive_best_fit_allocator_test.cc DEPS allocator) -paddle_test(buffered_allocator_test SRCS buffered_allocator_test.cc DEPS allocator) +nv_test( + buffered_allocator_test + SRCS buffered_allocator_test.cc + DEPS allocator) if(WITH_GPU) nv_test( From 93217df96719b06327a1b89d11807a88e23ac2cd Mon Sep 17 00:00:00 2001 From: Liyulingyue <852433440@qq.com> Date: Sat, 2 Mar 2024 03:11:20 +0800 Subject: [PATCH 08/16] modify CMakeLists.txt --- test/cpp/fluid/memory/CMakeLists.txt | 40 +++++++++++++--------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index b6a2cb15f7fa9..19c6b9f024410 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -1,7 +1,8 @@ paddle_test(memory_stats_test SRCS memory_stats_test.cc) paddle_test(stats_test SRCS stats_test.cc) -paddle_test(naive_best_fit_allocator_test SRCS naive_best_fit_allocator_test.cc DEPS allocator) +paddle_test(naive_best_fit_allocator_test SRCS naive_best_fit_allocator_test.cc + DEPS allocator) nv_test( buffered_allocator_test SRCS buffered_allocator_test.cc @@ -31,35 +32,24 @@ elseif(WITH_ROCM) SRCS best_fit_allocator_test.cc best_fit_allocator_test.cu DEPS allocator) else() - cc_test( - best_fit_allocator_test - SRCS best_fit_allocator_test.cc - DEPS allocator) + paddle_test(best_fit_allocator_test SRCS best_fit_allocator_test.cc DEPS + allocator) endif() -cc_test( - test_aligned_allocator - SRCS test_aligned_allocator.cc - DEPS allocator) +paddle_test(test_aligned_allocator SRCS test_aligned_allocator.cc DEPS + allocator) -cc_test( - retry_allocator_test - SRCS retry_allocator_test.cc - DEPS allocator) +paddle_test(retry_allocator_test SRCS retry_allocator_test.cc DEPS allocator) if(TEST retry_allocator_test) set_tests_properties(retry_allocator_test PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") endif() -cc_test( - allocator_facade_abs_flags_test - SRCS allocator_facade_abs_flags_test.cc - DEPS allocator) +paddle_test(allocator_facade_abs_flags_test SRCS + allocator_facade_abs_flags_test.cc DEPS allocator) -cc_test( - allocator_facade_frac_flags_test - SRCS allocator_facade_frac_flags_test.cc - DEPS allocator) +paddle_test(allocator_facade_frac_flags_test SRCS + allocator_facade_frac_flags_test.cc DEPS allocator) if(WITH_GPU) nv_test( @@ -147,3 +137,11 @@ cc_test( buddy_allocator_test SRCS buddy_allocator_test.cc DEPS allocator) + +if(WITH_ONNXRUNTIME AND WIN32) + # Copy onnxruntime for some c++ test in Windows, since the test will + # be build only in CI, so suppose the generator in Windows is Ninja. + copy_onnx(memory_stats_test) + copy_onnx(stats_test) + copy_onnx(naive_best_fit_allocator_test) +endif() From 789e4166e3630bb6395a2da39821241f22f3cd02 Mon Sep 17 00:00:00 2001 From: Liyulingyue <852433440@qq.com> Date: Sat, 2 Mar 2024 09:12:40 +0800 Subject: [PATCH 09/16] modify CMakeLists.txt --- test/cpp/fluid/memory/CMakeLists.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index 19c6b9f024410..4f8a3e0b04f8b 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -32,24 +32,22 @@ elseif(WITH_ROCM) SRCS best_fit_allocator_test.cc best_fit_allocator_test.cu DEPS allocator) else() - paddle_test(best_fit_allocator_test SRCS best_fit_allocator_test.cc DEPS - allocator) + paddle_test(best_fit_allocator_test SRCS best_fit_allocator_test.cc) endif() -paddle_test(test_aligned_allocator SRCS test_aligned_allocator.cc DEPS - allocator) +paddle_test(test_aligned_allocator SRCS test_aligned_allocator.cc) -paddle_test(retry_allocator_test SRCS retry_allocator_test.cc DEPS allocator) +paddle_test(retry_allocator_test SRCS retry_allocator_test.cc) if(TEST retry_allocator_test) set_tests_properties(retry_allocator_test PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") endif() paddle_test(allocator_facade_abs_flags_test SRCS - allocator_facade_abs_flags_test.cc DEPS allocator) + allocator_facade_abs_flags_test.cc) paddle_test(allocator_facade_frac_flags_test SRCS - allocator_facade_frac_flags_test.cc DEPS allocator) + allocator_facade_frac_flags_test.cc) if(WITH_GPU) nv_test( From 57ac593b8aef8d201733c565b0bd9a624d22ed5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Sat, 2 Mar 2024 17:10:13 +0800 Subject: [PATCH 10/16] Apply suggestions from code review --- test/cpp/fluid/memory/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index 4f8a3e0b04f8b..29ffd5a5b03dc 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -35,7 +35,10 @@ else() paddle_test(best_fit_allocator_test SRCS best_fit_allocator_test.cc) endif() -paddle_test(test_aligned_allocator SRCS test_aligned_allocator.cc) +nv_test( + test_aligned_allocator + SRCS test_aligned_allocator.cc + DEPS allocator) paddle_test(retry_allocator_test SRCS retry_allocator_test.cc) if(TEST retry_allocator_test) From 00a921cb3b7e7bf950085d4bcfc0adbae235c1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Sat, 2 Mar 2024 17:10:43 +0800 Subject: [PATCH 11/16] Apply suggestions from code review --- test/cpp/fluid/memory/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index 29ffd5a5b03dc..38e6e5afab279 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -40,7 +40,10 @@ nv_test( SRCS test_aligned_allocator.cc DEPS allocator) -paddle_test(retry_allocator_test SRCS retry_allocator_test.cc) +nv_test( + retry_allocator_test + SRCS retry_allocator_test.cc + DEPS allocator) if(TEST retry_allocator_test) set_tests_properties(retry_allocator_test PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") From 5e0aad21858494587361052d27a59f3e5c73e442 Mon Sep 17 00:00:00 2001 From: Liyulingyue <852433440@qq.com> Date: Sat, 2 Mar 2024 20:11:38 +0800 Subject: [PATCH 12/16] add test_API --- paddle/fluid/memory/allocation/allocator_facade.h | 2 +- paddle/fluid/memory/allocation/best_fit_allocator.h | 2 +- paddle/fluid/memory/allocation/cpu_allocator.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/memory/allocation/allocator_facade.h b/paddle/fluid/memory/allocation/allocator_facade.h index f80fcac1b2a38..984b7197c5199 100644 --- a/paddle/fluid/memory/allocation/allocator_facade.h +++ b/paddle/fluid/memory/allocation/allocator_facade.h @@ -64,7 +64,7 @@ class AllocatorFacade { std::shared_ptr AllocShared(const platform::Place& place, size_t size); // Allocate a unique allocation. - AllocationPtr Alloc(const platform::Place& place, size_t size); + TEST_API AllocationPtr Alloc(const platform::Place& place, size_t size); // Release unused memory pool. uint64_t Release(const platform::Place& place); diff --git a/paddle/fluid/memory/allocation/best_fit_allocator.h b/paddle/fluid/memory/allocation/best_fit_allocator.h index 97545f55a45f8..47f8ed80bb2e5 100644 --- a/paddle/fluid/memory/allocation/best_fit_allocator.h +++ b/paddle/fluid/memory/allocation/best_fit_allocator.h @@ -111,7 +111,7 @@ class BestFitAllocator : public Allocator { const platform::Place& Place() const { return allocation_->place(); } - size_t NumFreeChunks() const; + TEST_API size_t NumFreeChunks() const; bool IsAllocThreadSafe() const override { return true; } diff --git a/paddle/fluid/memory/allocation/cpu_allocator.h b/paddle/fluid/memory/allocation/cpu_allocator.h index 24678ba3433c0..5f5420281f0ee 100644 --- a/paddle/fluid/memory/allocation/cpu_allocator.h +++ b/paddle/fluid/memory/allocation/cpu_allocator.h @@ -37,7 +37,7 @@ class CPUAllocator : public Allocator { TEST_API bool IsAllocThreadSafe() const override; protected: - void FreeImpl(phi::Allocation* allocation) override; + TEST_API void FreeImpl(phi::Allocation* allocation) override; TEST_API phi::Allocation* AllocateImpl(size_t size) override; }; } // namespace allocation From 01284e5a7d9dbe9513abd638159c35c13dece77d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Sun, 3 Mar 2024 05:37:41 +0800 Subject: [PATCH 13/16] Apply suggestions from code review --- test/cpp/fluid/memory/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index 38e6e5afab279..f46ec23e01354 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -52,8 +52,10 @@ endif() paddle_test(allocator_facade_abs_flags_test SRCS allocator_facade_abs_flags_test.cc) -paddle_test(allocator_facade_frac_flags_test SRCS - allocator_facade_frac_flags_test.cc) +nv_test( + allocator_facade_frac_flags_test + SRCS allocator_facade_frac_flags_test.cc + DEPS allocator) if(WITH_GPU) nv_test( From af41330f56abac9090db5f91834cb171bbd72c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Sun, 3 Mar 2024 05:39:39 +0800 Subject: [PATCH 14/16] Update CMakeLists.txt --- test/cpp/fluid/memory/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index f46ec23e01354..4d9a84e688b8f 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -118,11 +118,11 @@ if(WITH_GPU AND WITH_TESTING) FLAGS_use_stream_safe_cuda_allocator=true;") endif() -cc_test( +paddle_test( auto_growth_best_fit_allocator_facade_test SRCS auto_growth_best_fit_allocator_facade_test.cc DEPS allocator) -cc_test( +paddle_test( auto_growth_best_fit_allocator_test SRCS auto_growth_best_fit_allocator_test.cc DEPS allocator) From a77985a3824f9c8beceeb99d5b6a8876d6b8e063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Sun, 3 Mar 2024 19:21:11 +0800 Subject: [PATCH 15/16] Apply suggestions from code review --- test/cpp/fluid/memory/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index 4d9a84e688b8f..be2bb1e9d4cd7 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -124,8 +124,7 @@ paddle_test( DEPS allocator) paddle_test( auto_growth_best_fit_allocator_test - SRCS auto_growth_best_fit_allocator_test.cc - DEPS allocator) + SRCS auto_growth_best_fit_allocator_test.cc) if(NOT WIN32) cc_test( From ae3e4632c0b4dce9dd420a2d23e2e93b60c8c800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Mon, 4 Mar 2024 06:43:15 +0800 Subject: [PATCH 16/16] Update CMakeLists.txt --- test/cpp/fluid/memory/CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/cpp/fluid/memory/CMakeLists.txt b/test/cpp/fluid/memory/CMakeLists.txt index be2bb1e9d4cd7..c4bf57aa7bae7 100644 --- a/test/cpp/fluid/memory/CMakeLists.txt +++ b/test/cpp/fluid/memory/CMakeLists.txt @@ -122,23 +122,24 @@ paddle_test( auto_growth_best_fit_allocator_facade_test SRCS auto_growth_best_fit_allocator_facade_test.cc DEPS allocator) -paddle_test( +nv_test( auto_growth_best_fit_allocator_test - SRCS auto_growth_best_fit_allocator_test.cc) + SRCS auto_growth_best_fit_allocator_test.cc + DEPS allocator) if(NOT WIN32) - cc_test( + paddle_test( mmap_allocator_test SRCS mmap_allocator_test.cc DEPS allocator) endif() -cc_test( +paddle_test( system_allocator_test SRCS system_allocator_test.cc DEPS allocator) -cc_test( +paddle_test( buddy_allocator_test SRCS buddy_allocator_test.cc DEPS allocator)