diff options
| author | Mahmoud <[email protected]> | 2020-05-23 22:45:28 -0400 |
|---|---|---|
| committer | Mahmoud <[email protected]> | 2020-05-23 22:45:28 -0400 |
| commit | 47e1a8a3a45203c34a93672a1b1bd742dc193183 (patch) | |
| tree | 4db7185ba2d4af2bd03e1388cd15a33b95ea8562 /src/trace-driven/gpgpusim_trace_driven_main.cc | |
| parent | 90a36a59f5619790b7f6d80375f69d05a75c0a82 (diff) | |
code refomratting
Diffstat (limited to 'src/trace-driven/gpgpusim_trace_driven_main.cc')
| -rw-r--r-- | src/trace-driven/gpgpusim_trace_driven_main.cc | 182 |
1 files changed, 91 insertions, 91 deletions
diff --git a/src/trace-driven/gpgpusim_trace_driven_main.cc b/src/trace-driven/gpgpusim_trace_driven_main.cc index 90dc769..4a5f14a 100644 --- a/src/trace-driven/gpgpusim_trace_driven_main.cc +++ b/src/trace-driven/gpgpusim_trace_driven_main.cc @@ -1,123 +1,123 @@ -//developed by Mahmoud Khairy, Purdue Univ +// developed by Mahmoud Khairy, Purdue Univ -#include <time.h> +#include <math.h> #include <stdio.h> -#include <vector> -#include <iostream> +#include <time.h> #include <fstream> -#include <string> +#include <iostream> #include <sstream> -#include <math.h> +#include <string> +#include <vector> +#include "../../libcuda/gpgpu_context.h" #include "../abstract_hardware_model.h" -#include "../option_parser.h" #include "../cuda-sim/cuda-sim.h" #include "../gpgpu-sim/gpu-sim.h" -#include "../../libcuda/gpgpu_context.h" -#include "trace_driven.h" -#include "ISA_Def/trace_opcode.h" #include "../gpgpusim_entrypoint.h" +#include "../option_parser.h" +#include "ISA_Def/trace_opcode.h" +#include "trace_driven.h" /* TO DO: * NOTE: the current version of trace-driven is functionally working fine, * but we still need to improve traces compression and simulation speed. * This includes: - * 1- Prefetch concurrent thread that prefetches traces from disk (to not be limited by disk speed) - * 2- traces compression format - * a. cfg format and remove thread/block Id from the head - * b. using zlib library to save in binary format + * 1- Prefetch concurrent thread that prefetches traces from disk (to not be + * limited by disk speed) 2- traces compression format a. cfg format and remove + * thread/block Id from the head b. using zlib library to save in binary format * - * 3- Efficient memory improvement (save string not objects - parse only 10 in the buffer) - * 4- Seeking capability - thread scheduler (save tb index and warp index info in the traces header) - * 5- Get rid off traces intermediate files - change the tracer + * 3- Efficient memory improvement (save string not objects - parse only 10 in + * the buffer) 4- Seeking capability - thread scheduler (save tb index and warp + * index info in the traces header) 5- Get rid off traces intermediate files - + * change the tracer */ -int main ( int argc, const char **argv ) -{ - - gpgpu_context* m_gpgpu_context = new gpgpu_context(); - gpgpu_sim * m_gpgpu_sim = m_gpgpu_context->gpgpu_trace_sim_init_perf(argc,argv); - m_gpgpu_sim->init(); - - //for each kernel - //load file - //parse and create kernel info - //launch - //while loop till the end of the end kernel execution - //prints stats +int main(int argc, const char** argv) { + gpgpu_context* m_gpgpu_context = new gpgpu_context(); + gpgpu_sim* m_gpgpu_sim = + m_gpgpu_context->gpgpu_trace_sim_init_perf(argc, argv); + m_gpgpu_sim->init(); - trace_parser tracer(m_gpgpu_sim->get_config().get_traces_filename(), m_gpgpu_sim, m_gpgpu_context); - trace_config config(m_gpgpu_sim); + // for each kernel + // load file + // parse and create kernel info + // launch + // while loop till the end of the end kernel execution + // prints stats - std::vector<std::string> commandlist = tracer.parse_kernellist_file(); - bool first_kernel=true; + trace_parser tracer(m_gpgpu_sim->get_config().get_traces_filename(), + m_gpgpu_sim, m_gpgpu_context); + trace_config config(m_gpgpu_sim); - for(unsigned i=0; i<commandlist.size(); ++i) { + std::vector<std::string> commandlist = tracer.parse_kernellist_file(); + bool first_kernel = true; - trace_kernel_info_t* kernel_info = NULL; - if(commandlist[i].substr(0,6) == "Memcpy") { - - size_t addre, Bcount; - tracer.parse_memcpy_info(commandlist[i], addre, Bcount); - std::cout<<commandlist[i]<<std::endl; - m_gpgpu_sim->perf_memcpy_to_gpu(addre, Bcount); - continue; - } - else { - //skip the first unimportant initialization kernel - if(m_gpgpu_sim->get_config().is_skip_first_kernel() && first_kernel) { - first_kernel = false; - continue; - } - kernel_info = tracer.parse_kernel_info(commandlist[i], &config); - m_gpgpu_sim->launch(kernel_info); - } + for (unsigned i = 0; i < commandlist.size(); ++i) { + trace_kernel_info_t* kernel_info = NULL; + if (commandlist[i].substr(0, 6) == "Memcpy") { + size_t addre, Bcount; + tracer.parse_memcpy_info(commandlist[i], addre, Bcount); + std::cout << commandlist[i] << std::endl; + m_gpgpu_sim->perf_memcpy_to_gpu(addre, Bcount); + continue; + } else { + // skip the first unimportant initialization kernel + if (m_gpgpu_sim->get_config().is_skip_first_kernel() && first_kernel) { + first_kernel = false; + continue; + } + kernel_info = tracer.parse_kernel_info(commandlist[i], &config); + m_gpgpu_sim->launch(kernel_info); + } - bool active = false; - bool sim_cycles = false; - bool break_limit = false; + bool active = false; + bool sim_cycles = false; + bool break_limit = false; - do { - if(!m_gpgpu_sim->active()) - break; + do { + if (!m_gpgpu_sim->active()) break; - //performance simulation - if( m_gpgpu_sim->active() ) { - m_gpgpu_sim->cycle(); - sim_cycles = true; - m_gpgpu_sim->deadlock_check(); - }else { - if(m_gpgpu_sim->cycle_insn_cta_max_hit()){ - m_gpgpu_context->the_gpgpusim->g_stream_manager->stop_all_running_kernels(); - break_limit = true; - } - } + // performance simulation + if (m_gpgpu_sim->active()) { + m_gpgpu_sim->cycle(); + sim_cycles = true; + m_gpgpu_sim->deadlock_check(); + } else { + if (m_gpgpu_sim->cycle_insn_cta_max_hit()) { + m_gpgpu_context->the_gpgpusim->g_stream_manager + ->stop_all_running_kernels(); + break_limit = true; + } + } - active=m_gpgpu_sim->active() ; + active = m_gpgpu_sim->active(); - } while( active ); + } while (active); - if(kernel_info) { - tracer.kernel_finalizer(kernel_info); - m_gpgpu_sim->print_stats(); - } + if (kernel_info) { + tracer.kernel_finalizer(kernel_info); + m_gpgpu_sim->print_stats(); + } - if(sim_cycles) { - m_gpgpu_sim->update_stats(); - m_gpgpu_context->print_simulation_time(); - } + if (sim_cycles) { + m_gpgpu_sim->update_stats(); + m_gpgpu_context->print_simulation_time(); + } - if(break_limit) { - printf("GPGPU-Sim: ** break due to reaching the maximum cycles (or instructions) **\n"); - fflush(stdout); - exit(1); - } - } + if (break_limit) { + printf( + "GPGPU-Sim: ** break due to reaching the maximum cycles (or " + "instructions) **\n"); + fflush(stdout); + exit(1); + } + } - //we print this message to inform the gpgpu-simulation stats_collect script that we are done - printf("GPGPU-Sim: *** simulation thread exiting ***\n"); - printf("GPGPU-Sim: *** exit detected ***\n"); + // we print this message to inform the gpgpu-simulation stats_collect script + // that we are done + printf("GPGPU-Sim: *** simulation thread exiting ***\n"); + printf("GPGPU-Sim: *** exit detected ***\n"); - return 1; + return 1; } |
