diff options
Diffstat (limited to 'src/gpgpu-sim')
| -rw-r--r-- | src/gpgpu-sim/gpu-sim.cc | 43 | ||||
| -rw-r--r-- | src/gpgpu-sim/gpu-sim.h | 3 |
2 files changed, 31 insertions, 15 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 <stdio.h> #include <string.h> +#include <iostream> +#include <sstream> +#include <string> #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<std::string> m_executed_kernel_names; //< names of kernel for stat printout std::vector<unsigned> 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; |
