FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

memory management: swap+pool by junzhezhang · Pull Request #412 · apache/singa · GitHub

/ singa Public

memory management: swap+pool - #412

Open
junzhezhang wants to merge 19 commits into
apache:masterfrom
junzhezhang:vd2
Open

memory management: swap+pool#412
junzhezhang wants to merge 19 commits into
apache:masterfrom
junzhezhang:vd2

Conversation

Copy link
Copy Markdown

new class of pool: SwapPool
important APIs: PoolOpt(), Malloc(), Free()
PoolOpt() takes in M/F seq including those induced by swapping
cross-iteration variables and last iteration case solved.

delay swap_plan() by 3 more iterations

update train

correct swap_sched(), swap_select(),swap_plan()

correct load update in swap_select

vec_run changed to new 3 iterations

correct vec_run36 index issue

correct overhead issue, verify vec_run.t

vec_run duplicate to avoid sorting issue
verified itm 5 indices in Table_sched

vec_swap_select pass by reference in swap_sched()

impl swap_update_tables(), before DeploySwap(), both at Append()

for time being, remove negative r_idx itms && git push origin vd1

handle last itr by impl sizeSqn and verification to change asyncSwapFlag back to 0
correct swap_construct_tables(), included negative r_idx for swap_update_tables() and DeploySwap()

include negative r_idx for DeploySwap()

impl GetRealGpuPtr() to swapIn nullptr Block at last iteration

impl GetRealGpuPtr(), and optimize data() and mutable_data()

impl GetRealGpuPtr(), and optimize data() and mutable_data()

verify const issue

change to return tempData instead of updating data_

without remove erasing in Table_not_at_device

milestone of last itr, at 550 MB
new class of pool: SwapPool
important APIs: PoolOpt(), Malloc(), Free()
PoolOpt() takes in M/F sequences including those induced by swapping
cross-iteration variables and last iteration case solved.

record down MF after swap done, for one iteration
Comment thread CMakeLists.txt Outdated
include(ExternalProject)
ExternalProject_Add(cnmem
GIT_REPOSITORY "https://github.com/nusdbsystem/cnmem.git"
GIT_REPOSITORY "https://github.com/junzhezhang/cnmem.git"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

did you change cnmem source code?

Comment thread examples/cifar10/train.py
@@ -31,24 +31,25 @@
import os

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

pls keep the cnn.py (instead of alexnet.py)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think you don't need to change the example model code.

Comment thread include/singa/core/common.h Outdated
Block(void* ptr, size_t size, size_t offset = 0)
: data_(ptr), size_(size), offset_(offset) {
Block(void* ptr, size_t size, size_t offset = 0, Device* ptrDevice = nullptr)
: data_(ptr), size_(size), offset_(offset), ptrDevice_(ptrDevice) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

ptr_device_

Comment thread include/singa/core/device.h Outdated
///SwapGPU
struct onePieceMsg{
/*
members: [ptr, size, MallocFree, idx]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

pls make the names consistent: MallocFree -> malloc_free

Comment thread include/singa/core/device.h Outdated
int MallocFree;
int idx;
double t;
onePieceMsg(string p, size_t s, int M, int i):ptr(p),size(s),MallocFree(M),idx(i){}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

const string &p

Comment thread include/singa/core/device.h Outdated
/// Called by Tensor.
void FreeBlock(Block* block);

void AppendInfo(string blockInfo);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

any comments on the blockInfo? better give an example.

Comment thread include/singa/core/device.h Outdated

int id() const { return id_; }

virtual void* GetRealGpuPtr(const Block* block_) = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

what do you mean by real gpu ptr?

///SwapGPU
struct onePieceMsg{
/*
members: [ptr, size, operation_type, idx]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

ptr to CPU or GPU memory?

Comment thread include/singa/core/device.h Outdated
map<int,std::tuple<int,int,int,int>>Table_sched; // changed to with sync_r_idx

//vec_block
vector<string>vec_block; //iteration 0-3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

the comments cannot explain the code.

Comment thread include/singa/core/memory.h Outdated
vector<string> vec;
vector<string> vec_block_RW;
vector<string> vec_block_RWMF;
map<int,int>Table_r2d; //full duration info, cross-iteration duration.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

the names Table_r2d and Table_d2r are not descriptive..

Comment thread src/core/common/common.cc Outdated
ptr_device_->AppendInfo(temp);
}
if (data_ == nullptr) {
cout<<"before GetRealGpuPtr, block_ and data_: "<<this<<' '<<data_<<endl;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

cout??
It will dump too many prints on the screen..

Comment thread src/core/device/swap_gpu.cc Outdated
};


struct oneIterMsg{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

this kind of names is not descriptive.

Comment thread src/core/device/swap_gpu.cc Outdated
//vector of pairMsg is used in run.
//vector of iterMsg is used in test.

vector<onePieceMsg> swap_strVec_2_pieceMsgVec(vector<string> vec, int &idxRange){

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

don't mix different naming styles..

Comment thread src/core/device/swap_gpu.cc Outdated
idxRange = static_cast<int>(onePieceMsgVec_.size());

return onePieceMsgVec_;
}// end of strVec_2_pieceMsgVec function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

this comment is meaningless..
better add some comments for the functionality or the arguments.

Copy link
Copy Markdown
Author

Updated the PR as per required on 09 Nov meeting, focused on correctness and code readability.

nudles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
  1. can you separate the Pool and Swap+Pool into 2 pull requests?
  2. please replace the strings with structs.

Comment thread examples/cifar10/train.py
train((train_x, train_y, test_x, test_y), net, 250, vgg_lr, 0.0005,
use_cpu=args.use_cpu)
use_cpu=args.use_cpu,batch_size=args.batch_size)
else:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

again, it would be better to keep the original example code.

#include <memory>
#include "singa/utils/logging.h"

#include <string>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

not used?

Comment thread include/singa/core/device.h Outdated
/// Called by Tensor.
void FreeBlock(Block* block);

void AppendInfo(string block_info);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

as discussed, please use a structure or class for block_info instead of string.

float mem_limit_ratio = 0.70;
size_t smallest_block = 1<<20; //1 MB
int data_buffer = 4; // used to control readyIdx
int mutable_data_buffer = 6;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

what does 4 and 6 mean?

Comment thread src/core/common/common.cc Outdated
//Append block info: opt_type, ptr, time_stamp
if (ptr_device_!=nullptr){
//Append info.
stringstream strm2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

the code would be cleaner if the strings are replaced with struct.

Comment thread src/core/memory/memory.cc
int name;
size_t size;
int r_idx;
int d_idx;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

what are r_idx, d_idx and name?

Copy link
Copy Markdown
Author

Replaced the strings with structs in Append function as per requested, updated in branch vd2.

New PR could not be created to Apache master, so it was created to my forked repo.

For the other request, separation of Pool and Swap+Pool into 2 PR is not possible from git, as they were updated mixed and match. But they are well separated in different classes of Device and Memory

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL