From 6fae4e664511e3d2b0e9e9062dfcc1a3eaf635ac Mon Sep 17 00:00:00 2001 From: junzhezhang Date: Sun, 20 Jan 2019 18:31:00 +0800 Subject: [PATCH] clean up old Append and rename new AppendStruct --- include/singa/core/device.h | 10 +++++----- src/core/common/common.cc | 4 ++-- src/core/device/device.cc | 2 +- src/core/device/swap_gpu.cc | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/singa/core/device.h b/include/singa/core/device.h index c0bc615780..7d9ed57757 100644 --- a/include/singa/core/device.h +++ b/include/singa/core/device.h @@ -106,7 +106,7 @@ class Device { int id() const { return id_; } virtual void* UpdateGpuPtr(const Block* block_ptr) = 0; - virtual void AppendStruct(DeviceOptInfoToAppend dev_opt_info) = 0; + virtual void Append(DeviceOptInfoToAppend dev_opt_info) = 0; private: Device() {}; @@ -153,7 +153,7 @@ class CppCPU : public Device { std::shared_ptr host() const override { return defaultDevice;} void SetRandSeed(unsigned seed) override; - void AppendStruct(DeviceOptInfoToAppend dev_opt_info) override {} + void Append(DeviceOptInfoToAppend dev_opt_info) override {} protected: void DoExec(function&& fn, int executor) override; @@ -188,7 +188,7 @@ class CudaGPU : public Device { void SetRandSeed(unsigned seed) override; size_t GetAllocatedMem() override; - void AppendStruct(DeviceOptInfoToAppend dev_opt_info) override {} + void Append(DeviceOptInfoToAppend dev_opt_info) override {} protected: @@ -286,7 +286,7 @@ class SwapGPU : public Device { void SetRandSeed(unsigned seed) override; size_t GetAllocatedMem() override; //Append at every index: free, read, mutable - void AppendStruct(DeviceOptInfoToAppend dev_opt_info) override; + void Append(DeviceOptInfoToAppend dev_opt_info) override; protected: void DoExec(function&& fn, int executor) override; @@ -408,7 +408,7 @@ class OpenclDevice : public singa::Device { virtual void CopyDataToFrom(Block* dst, Block* src, size_t nBytes, CopyDirection direction, int dst_offset = 0, int src_offset = 0) override; - void AppendStruct(DeviceOptInfoToAppend dev_opt_info) override {} + void Append(DeviceOptInfoToAppend dev_opt_info) override {} protected: /// The OpenCL device that this object represents. /// Each OpenclDevice contains exactly one cl::Device for the lifetime of the diff --git a/src/core/common/common.cc b/src/core/common/common.cc index a03ba5802e..692c1c451f 100644 --- a/src/core/common/common.cc +++ b/src/core/common/common.cc @@ -36,7 +36,7 @@ void* Block::mutable_data() { DeviceOptInfoToAppend dev_opt_info("Mutable", temp_str,size()); auto t = (std::chrono::system_clock::now()).time_since_epoch().count(); dev_opt_info.t = t; - ptr_device_->AppendStruct(dev_opt_info); + ptr_device_->Append(dev_opt_info); } //update ptr after swap in done, if variable is not swapped back yet as expected. @@ -60,7 +60,7 @@ const void* Block::data() const { DeviceOptInfoToAppend dev_opt_info("Read", temp_str,size()); auto t = (std::chrono::system_clock::now()).time_since_epoch().count(); dev_opt_info.t = t; - ptr_device_->AppendStruct(dev_opt_info); + ptr_device_->Append(dev_opt_info); } //update ptr after swap in done, if variable is not swapped back yet as expected. diff --git a/src/core/device/device.cc b/src/core/device/device.cc index 09abc26094..5a1ac270ac 100644 --- a/src/core/device/device.cc +++ b/src/core/device/device.cc @@ -61,7 +61,7 @@ void Device::FreeBlock(Block* block) { DeviceOptInfoToAppend dev_opt_info("Free", temp_str,block->size()); auto t = (std::chrono::system_clock::now()).time_since_epoch().count(); dev_opt_info.t = t; - AppendStruct(dev_opt_info); + Append(dev_opt_info); delete block; } diff --git a/src/core/device/swap_gpu.cc b/src/core/device/swap_gpu.cc index 29b6a2a62d..4228f6e16a 100644 --- a/src/core/device/swap_gpu.cc +++ b/src/core/device/swap_gpu.cc @@ -910,7 +910,7 @@ void SwapGPU::AppendAfterMalloc(Block* block_ptr,void* data_ptr,int size){ DeviceOptInfoToAppend dev_opt_info("Malloc", temp_str,size); auto t = (std::chrono::system_clock::now()).time_since_epoch().count(); dev_opt_info.t = t; - AppendStruct(dev_opt_info); + Append(dev_opt_info); } @@ -989,7 +989,7 @@ void SwapGPU::DeploySwapExec(int r_global_index){ } } -void SwapGPU::AppendStruct(DeviceOptInfoToAppend dev_opt_info){ +void SwapGPU::Append(DeviceOptInfoToAppend dev_opt_info){ //convert block_ptr from string to Block* void* temp_ptr;