File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ int Memory::short_memory = sizeof(short); // 2.0 Byte
2323
2424int Memory::n_memory = 1000 ;
2525int Memory::n_now = 0 ;
26- bool Memory::init_flag = false ;
26+ bool Memory::init_flag = false ;
2727
2828#if defined(__CUDA) || defined(__ROCM)
2929
@@ -234,10 +234,10 @@ double Memory::record_gpu
234234{
235235 if (!Memory::init_flag_gpu)
236236 {
237- name_gpu = new std::string[n_memory];
238- class_name_gpu = new std::string[n_memory];
239- consume_gpu = new double [n_memory];
240- for (int i=0 ;i<n_memory;i++)
237+ name_gpu = new std::string[n_memory + 2 ];
238+ class_name_gpu = new std::string[n_memory + 2 ];
239+ consume_gpu = new double [n_memory + 2 ];
240+ for (int i=0 ;i<n_memory + 2 ;i++)
241241 {
242242 consume_gpu[i] = 0.0 ;
243243 }
@@ -365,18 +365,15 @@ void Memory::finish(std::ofstream &ofs)
365365 delete[] name_gpu;
366366 delete[] class_name_gpu;
367367 delete[] consume_gpu;
368+ init_flag_gpu = false ;
368369 }
369370#endif
370371 return ;
371372}
372373
373374void Memory::print_all (std::ofstream &ofs)
374375{
375- if (!init_flag
376- #if defined(__CUDA) || defined(__ROCM)
377- && !init_flag_gpu
378- #endif
379- )
376+ if (!init_flag)
380377 {
381378 return ;
382379 }
@@ -437,6 +434,11 @@ void Memory::print_all(std::ofstream &ofs)
437434 }
438435
439436#if defined(__CUDA) || defined(__ROCM)
437+ if (!init_flag_gpu)
438+ {
439+ return ;
440+ }
441+
440442 ofs <<" \n NAME-------------------------|GPU MEMORY(MB)----" << std::endl;
441443 ofs <<std::setw (30 )<< " total" << std::setw (15 ) <<std::setprecision (4 )<< Memory::total_gpu << std::endl;
442444
You can’t perform that action at this time.
0 commit comments