@@ -42,7 +42,6 @@ const cudaMemcpyKind copyKind[] = {cudaMemcpyHostToHost, cudaMemcpyHostToDevice,
4242
4343// /functions to be used
4444// /Section for structs and respective sorting function:
45- // onePieceMsg, onePairMsg, oneIterMsg, version 11/30 3pm
4645
4746
4847
@@ -924,7 +923,8 @@ SwapGPU::SwapGPU(int id) : Device(id, kNumCudaStream) {
924923
925924 MemPoolConf conf;
926925 conf.add_device (id);
927- pool_ = std::make_shared<Swap>(conf);
926+ // TODO(junzhe) note that it has been <Swap> for building SwapGPU, which doesnt matter.
927+ pool_ = std::make_shared<SwapPool>(conf);
928928 Setup ();
929929
930930}
@@ -987,6 +987,26 @@ void* SwapGPU::Malloc(int size) {
987987 if (size > 0 ) {
988988 CUDA_CHECK (cudaSetDevice (id_));
989989 pool_->Malloc ((void **)&ptr, size);
990+
991+ // /append vec_block_mf
992+ if ((asyncSwapFlag == 1 ) && ((gc - 4 *maxLen) < three_more_globeCounter)
993+ && ((gc - maxLen) >= three_more_globeCounter)){
994+ string tempStr1 =" Malloc " ;
995+ stringstream strm2;
996+ strm2<<ptr;
997+ string tempStr2 = strm2.str ();
998+ stringstream strm3;
999+ strm3<<size;
1000+ string tempStr3 = strm3.str ();
1001+ string temp = tempStr1+tempStr2+" " +tempStr3;
1002+ vec_block_mf.push_back (temp);
1003+ }
1004+ // record mf semantics after swap plan done
1005+ if ((asyncSwapFlag == 1 ) && ((gc - 4 *maxLen) < three_more_globeCounter)){
1006+ fstream file_mf_one_itr (" mf_one_itr.csv" , ios::in|ios::out|ios::app);
1007+ file_mf_one_itr<<" Malloc " <<ptr<<" " <<size;
1008+ file_mf_one_itr<<endl;
1009+ }
9901010 // TODO(wangwei) remove the memset.
9911011 CUDA_CHECK (cudaMemset (ptr, 0 , size));
9921012 }
@@ -1000,6 +1020,21 @@ void SwapGPU::Free(void* ptr) {
10001020 if (ptr != nullptr ) {
10011021 CUDA_CHECK (cudaSetDevice (id_));
10021022 pool_->Free (ptr);
1023+ // /append vec_block_mf
1024+ if ((asyncSwapFlag == 1 ) && ((gc - 4 *maxLen) < three_more_globeCounter)
1025+ && ((gc - maxLen) >= three_more_globeCounter)){
1026+ string tempStr1 =" Free " ;
1027+ stringstream strm2;
1028+ strm2<<ptr;
1029+ string tempStr2 = strm2.str ();
1030+ string temp = tempStr1+tempStr2;
1031+ vec_block_mf.push_back (temp);
1032+ }
1033+
1034+ if ((asyncSwapFlag == 1 ) && ((gc - 4 *maxLen) < three_more_globeCounter)){
1035+ fstream file_mf_one_itr (" mf_one_itr.csv" , ios::in|ios::out|ios::app);
1036+ file_mf_one_itr<<" Free " <<ptr<<endl;
1037+ }
10031038 }
10041039
10051040 // cout<<"free done"<<endl;
@@ -1115,6 +1150,21 @@ void SwapGPU::DeploySwap_exec(int r_gc){
11151150 last_meta.block_ ->update_data (nullptr );
11161151 // cout<<"to free data_"<<last_meta.data_<<endl;
11171152 pool_->Free (last_meta.data_ );
1153+ // /append vec_block_mf
1154+ if ((asyncSwapFlag == 1 ) && ((gc - 4 *maxLen) < three_more_globeCounter)
1155+ && ((gc - maxLen) >= three_more_globeCounter)){
1156+ string tempStr1 =" Free " ;
1157+ stringstream strm2;
1158+ strm2<<last_meta.data_ ;
1159+ string tempStr2 = strm2.str ();
1160+ string temp = tempStr1+tempStr2;
1161+ vec_block_mf.push_back (temp);
1162+ }
1163+
1164+ if ((asyncSwapFlag == 1 ) && ((gc - 4 *maxLen) < three_more_globeCounter)){
1165+ fstream file_mf_one_itr (" mf_one_itr.csv" , ios::in|ios::out|ios::app);
1166+ file_mf_one_itr<<" Free " <<last_meta.data_ <<" SwapOut(Sync)" <<endl;
1167+ }
11181168 last_meta.data_ = nullptr ; // not really needed TODO(junzhe)
11191169 cout<<" ----sync out " <<sync_idx<<endl;
11201170 Table_meta.find (sync_idx)->second = last_meta;
@@ -1213,8 +1263,24 @@ void SwapGPU::Append(string blockInfo){
12131263
12141264 // test moved from start of malloc/free to end of append, only gc+1 changed
12151265 Test_sched_switch_swap ();
1216- // NOTE: this gc++ includes read/write and AppendLayer as well, in addition to malloc/free.
1266+ // NOTE: this gc includes read/write and AppendLayer as well, in addition to malloc/free.
12171267 gc++;
1268+ if ((asyncSwapFlag == 1 ) && ((gc - 4 *maxLen) == three_more_globeCounter)){
1269+ cout<<" ==================to call PoolOpt" <<endl;
1270+ fstream file_mf_8910 (" mf_8910.csv" , ios::in|ios::out|ios::app);
1271+ for (int i = 0 ; i< vec_block_mf.size ();i++){
1272+ file_mf_8910<<vec_block_mf[i]<<endl;
1273+ }
1274+ cout<<" len of vec_block_mf: " <<vec_block_mf.size ()<<endl;
1275+ pool_->PoolOpt (vec_block_mf);
1276+ cout<<" ==================to call PoolOpt done" <<endl;
1277+ }
1278+
1279+ if ((asyncSwapFlag == 1 ) && ((gc - 4 *maxLen) < three_more_globeCounter)
1280+ && ((gc - three_more_globeCounter)%maxLen == 0 )){
1281+ fstream file_mf_one_itr (" mf_one_itr.csv" , ios::in|ios::out|ios::app);
1282+ file_mf_one_itr<<" -----new itr------" <<endl;
1283+ }
12181284
12191285}
12201286
@@ -1297,6 +1363,23 @@ void SwapGPU::SwapIn_idx(const int r_idx){
12971363 // cout<<"update block and data of r_idx: "<<r_idx<<' '<<meta.block_<<' '<<meta.data_<<endl;
12981364 void * ptr = nullptr ;
12991365 pool_->Malloc ((void **)&ptr, meta.size );
1366+ // /append vec_block_mf
1367+ if ((asyncSwapFlag == 1 ) && ((gc - 4 *maxLen) < three_more_globeCounter)
1368+ && ((gc - maxLen) >= three_more_globeCounter)){
1369+ string tempStr1 =" Malloc " ;
1370+ stringstream strm2;
1371+ strm2<<ptr;
1372+ string tempStr2 = strm2.str ();
1373+ stringstream strm3;
1374+ strm3<<meta.size ;
1375+ string tempStr3 = strm3.str ();
1376+ string temp = tempStr1+tempStr2+" " +tempStr3;
1377+ vec_block_mf.push_back (temp);
1378+ }
1379+ if ((asyncSwapFlag == 1 ) && ((gc - 4 *maxLen) < three_more_globeCounter)){
1380+ fstream file_mf_one_itr (" mf_one_itr.csv" , ios::in|ios::out|ios::app);
1381+ file_mf_one_itr<<" Malloc " <<ptr<<" " <<meta.size <<" swapIn" <<endl;
1382+ }
13001383 // cout<<"expected results update_data:: "<<meta.block_<<" "<<ptr<<endl;
13011384 // cout<<"malloc due to swapIn ("<<r_idx<<") "<<ptr<<endl;
13021385 // void* to_rm_ptr = meta.data_;
0 commit comments