Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

【paddle_test No.17】replace cc_test with paddle_test #62031

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion paddle/fluid/memory/allocation/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/memory/allocation/best_fit_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }

Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/memory/allocation/buffered_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace allocation {
// underlying_allocator_
class BufferedAllocator : public Allocator {
public:
explicit BufferedAllocator(std::shared_ptr<Allocator> allocator);
TEST_API explicit BufferedAllocator(std::shared_ptr<Allocator> allocator);

~BufferedAllocator();

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/memory/allocation/cpu_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/memory/allocation/naive_best_fit_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
26 changes: 15 additions & 11 deletions paddle/fluid/memory/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +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);

int64_t HostMemoryStatCurrentValue(const std::string& stat_type, int dev_id);
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 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);
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);
Expand Down
20 changes: 4 additions & 16 deletions test/cpp/fluid/memory/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
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
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 DEPS allocator)
paddle_test(buffered_allocator_test SRCS buffered_allocator_test.cc DEPS allocator)

if(WITH_GPU)
nv_test(
Expand Down