From 8d8fa45b0fa6bc3afcb65463890c38d1c9255ec0 Mon Sep 17 00:00:00 2001 From: Wilson Fung Date: Sat, 26 Jan 2013 13:50:40 -0800 Subject: Now even the power model log will have kernel names printed out. [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 15110] --- src/gpgpu-sim/gpu-sim.cc | 43 +++++++++++++++++++++++++------------- src/gpgpu-sim/gpu-sim.h | 3 ++- src/gpuwattch/gpgpu_sim_wrapper.cc | 3 ++- src/gpuwattch/gpgpu_sim_wrapper.h | 2 +- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/gpgpu-sim/gpu-sim.cc b/src/gpgpu-sim/gpu-sim.cc index 2eab0b9..ff5427a 100644 --- a/src/gpgpu-sim/gpu-sim.cc +++ b/src/gpgpu-sim/gpu-sim.cc @@ -70,6 +70,9 @@ class gpgpu_sim_wrapper {}; #include #include +#include +#include +#include #define MAX(a,b) (((a)>(b))?(a):(b)) @@ -712,23 +715,37 @@ void gpgpu_sim::deadlock_check() } } -void gpgpu_sim::gpu_print_stat() -{ - FILE *statfout = stdout; +/// printing the names and uids of a set of executed kernels (usually there is only one) +std::string gpgpu_sim::executed_kernel_info_string() +{ + std::stringstream statout; - // printing the names and uids of a set of executed kernels (usually there is only one) - fprintf(statfout, "kernel_name = "); + statout << "kernel_name = "; for (unsigned int k = 0; k < m_executed_kernel_names.size(); k++) { - fprintf(statfout, "'%s' ", m_executed_kernel_names[k].c_str()); + statout << m_executed_kernel_names[k] << " "; } - fprintf(statfout, "\n"); - fprintf(statfout, "kernel_launch_uid = "); + statout << std::endl; + statout << "kernel_launch_uid = "; for (unsigned int k = 0; k < m_executed_kernel_uids.size(); k++) { - fprintf(statfout, "%d ", m_executed_kernel_uids[k]); + statout << m_executed_kernel_uids[k] << " "; } - fprintf(statfout, "\n"); + statout << std::endl; + + return statout.str(); +} + +void gpgpu_sim::clear_executed_kernel_info() +{ m_executed_kernel_names.clear(); m_executed_kernel_uids.clear(); +} + +void gpgpu_sim::gpu_print_stat() +{ + FILE *statfout = stdout; + + std::string kernel_info_str = executed_kernel_info_string(); + fprintf(statfout, "%s", kernel_info_str.c_str()); printf("gpu_sim_cycle = %lld\n", gpu_sim_cycle); printf("gpu_sim_insn = %lld\n", gpu_sim_insn); @@ -754,7 +771,7 @@ void gpgpu_sim::gpu_print_stat() m_shader_stats->print(stdout); #ifdef GPGPUSIM_POWER_MODEL if(m_config.g_power_simulation_enabled){ - m_gpgpusim_wrapper->print_power_kernel_stats(gpu_sim_cycle,gpu_tot_sim_cycle,gpu_tot_sim_insn + gpu_sim_insn ); + m_gpgpusim_wrapper->print_power_kernel_stats(gpu_sim_cycle, gpu_tot_sim_cycle, gpu_tot_sim_insn + gpu_sim_insn, kernel_info_str ); } #endif @@ -800,9 +817,7 @@ void gpgpu_sim::gpu_print_stat() time_vector_print(); fflush(stdout); - - - + clear_executed_kernel_info(); } diff --git a/src/gpgpu-sim/gpu-sim.h b/src/gpgpu-sim/gpu-sim.h index 93b7b0c..c04c1c1 100644 --- a/src/gpgpu-sim/gpu-sim.h +++ b/src/gpgpu-sim/gpu-sim.h @@ -459,7 +459,8 @@ private: std::vector m_executed_kernel_names; //< names of kernel for stat printout std::vector m_executed_kernel_uids; //< uids of kernel launches for stat printout - + std::string executed_kernel_info_string(); //< format the kernel information into a string for stat printout + void clear_executed_kernel_info(); //< clear the kernel information after stat printout public: unsigned long long gpu_sim_insn; diff --git a/src/gpuwattch/gpgpu_sim_wrapper.cc b/src/gpuwattch/gpgpu_sim_wrapper.cc index 22d0659..3bee7b0 100644 --- a/src/gpuwattch/gpgpu_sim_wrapper.cc +++ b/src/gpuwattch/gpgpu_sim_wrapper.cc @@ -586,10 +586,11 @@ void gpgpu_sim_wrapper::compute() { proc->compute(); } -void gpgpu_sim_wrapper::print_power_kernel_stats(double gpu_sim_cycle, double gpu_tot_sim_cycle, double init_value) +void gpgpu_sim_wrapper::print_power_kernel_stats(double gpu_sim_cycle, double gpu_tot_sim_cycle, double init_value, const std::string & kernel_info_string) { detect_print_steady_state(1,init_value); if(g_power_simulation_enabled){ + powerfile<