diff options
| author | Nick <[email protected]> | 2019-09-13 07:48:08 -0400 |
|---|---|---|
| committer | Nick <[email protected]> | 2019-09-13 07:48:08 -0400 |
| commit | 9b1e6dba9f721c772e801abc4851a88aa61929da (patch) | |
| tree | ed12425be898e85e01e7a3997a9b8d5efba6ef50 /src/gpgpu-sim/gpu-sim.h | |
| parent | 5c99f0fa58caf45f4d457894413aa11c03afdb7d (diff) | |
Revert "Add src/gpgpu-sim formatting"
This reverts commit 9c9b1341613e767f306b2b73b5b8a5317b6ee563.
Diffstat (limited to 'src/gpgpu-sim/gpu-sim.h')
| -rw-r--r-- | src/gpgpu-sim/gpu-sim.h | 1012 |
1 files changed, 489 insertions, 523 deletions
diff --git a/src/gpgpu-sim/gpu-sim.h b/src/gpgpu-sim/gpu-sim.h index 40c4482..fba770d 100644 --- a/src/gpgpu-sim/gpu-sim.h +++ b/src/gpgpu-sim/gpu-sim.h @@ -7,16 +7,14 @@ // // Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. -// Redistributions in binary form must reproduce the above copyright notice, -// this +// Redistributions in binary form must reproduce the above copyright notice, this // list of conditions and the following disclaimer in the documentation and/or // other materials provided with the distribution. // Neither the name of The University of British Columbia nor the names of its // contributors may be used to endorse or promote products derived from this // software without specific prior written permission. // -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE @@ -30,22 +28,24 @@ #ifndef GPU_SIM_H #define GPU_SIM_H -#include <stdio.h> -#include <fstream> -#include <iostream> -#include <list> -#include "../abstract_hardware_model.h" #include "../option_parser.h" +#include "../abstract_hardware_model.h" #include "../trace.h" #include "addrdec.h" -#include "gpu-cache.h" #include "shader.h" +#include "gpu-cache.h" +#include <iostream> +#include <fstream> +#include <list> +#include <stdio.h> + + // constants for statistics printouts #define GPU_RSTAT_SHD_INFO 0x1 -#define GPU_RSTAT_BW_STAT 0x2 +#define GPU_RSTAT_BW_STAT 0x2 #define GPU_RSTAT_WARP_DIS 0x4 -#define GPU_RSTAT_DWF_MAP 0x8 +#define GPU_RSTAT_DWF_MAP 0x8 #define GPU_RSTAT_L1MISS 0x10 #define GPU_RSTAT_PDOM 0x20 #define GPU_RSTAT_SCHED 0x40 @@ -65,618 +65,584 @@ class gpgpu_context; -extern tr1_hash_map<new_addr_type, unsigned> address_random_interleaving; +extern tr1_hash_map<new_addr_type,unsigned> address_random_interleaving; + +enum dram_ctrl_t { + DRAM_FIFO=0, + DRAM_FRFCFS=1 +}; + -enum dram_ctrl_t { DRAM_FIFO = 0, DRAM_FRFCFS = 1 }; struct power_config { - power_config() { m_valid = true; } - void init() { - // initialize file name if it is not set - time_t curr_time; - time(&curr_time); - char *date = ctime(&curr_time); - char *s = date; - while (*s) { - if (*s == ' ' || *s == '\t' || *s == ':') *s = '-'; - if (*s == '\n' || *s == '\r') *s = 0; - s++; - } - char buf1[1024]; - snprintf(buf1, 1024, "gpgpusim_power_report__%s.log", date); - g_power_filename = strdup(buf1); - char buf2[1024]; - snprintf(buf2, 1024, "gpgpusim_power_trace_report__%s.log.gz", date); - g_power_trace_filename = strdup(buf2); - char buf3[1024]; - snprintf(buf3, 1024, "gpgpusim_metric_trace_report__%s.log.gz", date); - g_metric_trace_filename = strdup(buf3); - char buf4[1024]; - snprintf(buf4, 1024, "gpgpusim_steady_state_tracking_report__%s.log.gz", - date); - g_steady_state_tracking_filename = strdup(buf4); + power_config() + { + m_valid = true; + } + void init() + { - if (g_steady_power_levels_enabled) { - sscanf(gpu_steady_state_definition, "%lf:%lf", - &gpu_steady_power_deviation, &gpu_steady_min_period); - } + // initialize file name if it is not set + time_t curr_time; + time(&curr_time); + char *date = ctime(&curr_time); + char *s = date; + while (*s) { + if (*s == ' ' || *s == '\t' || *s == ':') *s = '-'; + if (*s == '\n' || *s == '\r' ) *s = 0; + s++; + } + char buf1[1024]; + snprintf(buf1,1024,"gpgpusim_power_report__%s.log",date); + g_power_filename = strdup(buf1); + char buf2[1024]; + snprintf(buf2,1024,"gpgpusim_power_trace_report__%s.log.gz",date); + g_power_trace_filename = strdup(buf2); + char buf3[1024]; + snprintf(buf3,1024,"gpgpusim_metric_trace_report__%s.log.gz",date); + g_metric_trace_filename = strdup(buf3); + char buf4[1024]; + snprintf(buf4,1024,"gpgpusim_steady_state_tracking_report__%s.log.gz",date); + g_steady_state_tracking_filename = strdup(buf4); + + if(g_steady_power_levels_enabled){ + sscanf(gpu_steady_state_definition,"%lf:%lf", &gpu_steady_power_deviation,&gpu_steady_min_period); + } - // NOTE: After changing the nonlinear model to only scaling idle core, - // NOTE: The min_inc_per_active_sm is not used any more - if (g_use_nonlinear_model) - sscanf(gpu_nonlinear_model_config, "%lf:%lf", &gpu_idle_core_power, - &gpu_min_inc_per_active_sm); - } - void reg_options(class OptionParser *opp); + //NOTE: After changing the nonlinear model to only scaling idle core, + //NOTE: The min_inc_per_active_sm is not used any more + if (g_use_nonlinear_model) + sscanf(gpu_nonlinear_model_config,"%lf:%lf", &gpu_idle_core_power,&gpu_min_inc_per_active_sm); - char *g_power_config_name; + } + void reg_options(class OptionParser * opp); + + char *g_power_config_name; + + bool m_valid; + bool g_power_simulation_enabled; + bool g_power_trace_enabled; + bool g_steady_power_levels_enabled; + bool g_power_per_cycle_dump; + bool g_power_simulator_debug; + char *g_power_filename; + char *g_power_trace_filename; + char *g_metric_trace_filename; + char * g_steady_state_tracking_filename; + int g_power_trace_zlevel; + char * gpu_steady_state_definition; + double gpu_steady_power_deviation; + double gpu_steady_min_period; + + //Nonlinear power model + bool g_use_nonlinear_model; + char * gpu_nonlinear_model_config; + double gpu_idle_core_power; + double gpu_min_inc_per_active_sm; - bool m_valid; - bool g_power_simulation_enabled; - bool g_power_trace_enabled; - bool g_steady_power_levels_enabled; - bool g_power_per_cycle_dump; - bool g_power_simulator_debug; - char *g_power_filename; - char *g_power_trace_filename; - char *g_metric_trace_filename; - char *g_steady_state_tracking_filename; - int g_power_trace_zlevel; - char *gpu_steady_state_definition; - double gpu_steady_power_deviation; - double gpu_steady_min_period; - // Nonlinear power model - bool g_use_nonlinear_model; - char *gpu_nonlinear_model_config; - double gpu_idle_core_power; - double gpu_min_inc_per_active_sm; }; + class memory_config { - public: - memory_config(gpgpu_context *ctx) { - m_valid = false; - gpgpu_dram_timing_opt = NULL; - gpgpu_L2_queue_config = NULL; - gpgpu_ctx = ctx; - } - void init() { - assert(gpgpu_dram_timing_opt); - if (strchr(gpgpu_dram_timing_opt, '=') == NULL) { - // dram timing option in ordered variables (legacy) - // Disabling bank groups if their values are not specified - nbkgrp = 1; - tCCDL = 0; - tRTPL = 0; - sscanf(gpgpu_dram_timing_opt, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", - &nbk, &tCCD, &tRRD, &tRCD, &tRAS, &tRP, &tRC, &CL, &WL, &tCDLR, - &tWR, &nbkgrp, &tCCDL, &tRTPL); - } else { - // named dram timing options (unordered) - option_parser_t dram_opp = option_parser_create(); + public: + memory_config(gpgpu_context* ctx) + { + m_valid = false; + gpgpu_dram_timing_opt=NULL; + gpgpu_L2_queue_config=NULL; + gpgpu_ctx = ctx; + } + void init() + { + assert(gpgpu_dram_timing_opt); + if (strchr(gpgpu_dram_timing_opt, '=') == NULL) { + // dram timing option in ordered variables (legacy) + // Disabling bank groups if their values are not specified + nbkgrp = 1; + tCCDL = 0; + tRTPL = 0; + sscanf(gpgpu_dram_timing_opt,"%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d", + &nbk,&tCCD,&tRRD,&tRCD,&tRAS,&tRP,&tRC,&CL,&WL,&tCDLR,&tWR,&nbkgrp,&tCCDL,&tRTPL); + } else { + // named dram timing options (unordered) + option_parser_t dram_opp = option_parser_create(); - option_parser_register(dram_opp, "nbk", OPT_UINT32, &nbk, - "number of banks", ""); - option_parser_register(dram_opp, "CCD", OPT_UINT32, &tCCD, - "column to column delay", ""); - option_parser_register( - dram_opp, "RRD", OPT_UINT32, &tRRD, - "minimal delay between activation of rows in different banks", ""); - option_parser_register(dram_opp, "RCD", OPT_UINT32, &tRCD, - "row to column delay", ""); - option_parser_register(dram_opp, "RAS", OPT_UINT32, &tRAS, - "time needed to activate row", ""); - option_parser_register(dram_opp, "RP", OPT_UINT32, &tRP, - "time needed to precharge (deactivate) row", ""); - option_parser_register(dram_opp, "RC", OPT_UINT32, &tRC, "row cycle time", - ""); - option_parser_register(dram_opp, "CDLR", OPT_UINT32, &tCDLR, - "switching from write to read (changes tWTR)", ""); - option_parser_register(dram_opp, "WR", OPT_UINT32, &tWR, - "last data-in to row precharge", ""); + option_parser_register(dram_opp, "nbk", OPT_UINT32, &nbk, "number of banks", ""); + option_parser_register(dram_opp, "CCD", OPT_UINT32, &tCCD, "column to column delay", ""); + option_parser_register(dram_opp, "RRD", OPT_UINT32, &tRRD, "minimal delay between activation of rows in different banks", ""); + option_parser_register(dram_opp, "RCD", OPT_UINT32, &tRCD, "row to column delay", ""); + option_parser_register(dram_opp, "RAS", OPT_UINT32, &tRAS, "time needed to activate row", ""); + option_parser_register(dram_opp, "RP", OPT_UINT32, &tRP, "time needed to precharge (deactivate) row", ""); + option_parser_register(dram_opp, "RC", OPT_UINT32, &tRC, "row cycle time", ""); + option_parser_register(dram_opp, "CDLR", OPT_UINT32, &tCDLR, "switching from write to read (changes tWTR)", ""); + option_parser_register(dram_opp, "WR", OPT_UINT32, &tWR, "last data-in to row precharge", ""); - option_parser_register(dram_opp, "CL", OPT_UINT32, &CL, "CAS latency", - ""); - option_parser_register(dram_opp, "WL", OPT_UINT32, &WL, "Write latency", - ""); + option_parser_register(dram_opp, "CL", OPT_UINT32, &CL, "CAS latency", ""); + option_parser_register(dram_opp, "WL", OPT_UINT32, &WL, "Write latency", ""); - // Disabling bank groups if their values are not specified - option_parser_register(dram_opp, "nbkgrp", OPT_UINT32, &nbkgrp, - "number of bank groups", "1"); - option_parser_register( - dram_opp, "CCDL", OPT_UINT32, &tCCDL, - "column to column delay between accesses to different bank groups", - "0"); - option_parser_register( - dram_opp, "RTPL", OPT_UINT32, &tRTPL, - "read to precharge delay between accesses to different bank groups", - "0"); + //Disabling bank groups if their values are not specified + option_parser_register(dram_opp, "nbkgrp", OPT_UINT32, &nbkgrp, "number of bank groups", "1"); + option_parser_register(dram_opp, "CCDL", OPT_UINT32, &tCCDL, "column to column delay between accesses to different bank groups", "0"); + option_parser_register(dram_opp, "RTPL", OPT_UINT32, &tRTPL, "read to precharge delay between accesses to different bank groups", "0"); - option_parser_delimited_string(dram_opp, gpgpu_dram_timing_opt, "=:;"); - fprintf(stdout, "DRAM Timing Options:\n"); - option_parser_print(dram_opp, stdout); - option_parser_destroy(dram_opp); - } + option_parser_delimited_string(dram_opp, gpgpu_dram_timing_opt, "=:;"); + fprintf(stdout, "DRAM Timing Options:\n"); + option_parser_print(dram_opp, stdout); + option_parser_destroy(dram_opp); + } - int nbkt = nbk / nbkgrp; - unsigned i; - for (i = 0; nbkt > 0; i++) { - nbkt = nbkt >> 1; - } - bk_tag_length = i - 1; - assert(nbkgrp > 0 && "Number of bank groups cannot be zero"); - tRCDWR = tRCD - (WL + 1); - if (elimnate_rw_turnaround) { - tRTW = 0; - tWTR = 0; - } else { - tRTW = (CL + (BL / data_command_freq_ratio) + 2 - WL); - tWTR = (WL + (BL / data_command_freq_ratio) + tCDLR); - } - tWTP = (WL + (BL / data_command_freq_ratio) + tWR); - dram_atom_size = BL * busW * gpu_n_mem_per_ctrlr; // burst length x bus - // width x # chips per - // partition + int nbkt = nbk/nbkgrp; + unsigned i; + for (i=0; nbkt>0; i++) { + nbkt = nbkt>>1; + } + bk_tag_length = i-1; + assert(nbkgrp>0 && "Number of bank groups cannot be zero"); + tRCDWR = tRCD-(WL+1); + if(elimnate_rw_turnaround) + { + tRTW = 0; + tWTR = 0; + } else { + tRTW = (CL+(BL/data_command_freq_ratio)+2-WL); + tWTR = (WL+(BL/data_command_freq_ratio)+tCDLR); + } + tWTP = (WL+(BL/data_command_freq_ratio)+tWR); + dram_atom_size = BL * busW * gpu_n_mem_per_ctrlr; // burst length x bus width x # chips per partition - assert(m_n_sub_partition_per_memory_channel > 0); - assert((nbk % m_n_sub_partition_per_memory_channel == 0) && - "Number of DRAM banks must be a perfect multiple of memory sub " - "partition"); - m_n_mem_sub_partition = m_n_mem * m_n_sub_partition_per_memory_channel; - fprintf(stdout, "Total number of memory sub partition = %u\n", - m_n_mem_sub_partition); + assert( m_n_sub_partition_per_memory_channel > 0 ); + assert( (nbk % m_n_sub_partition_per_memory_channel == 0) + && "Number of DRAM banks must be a perfect multiple of memory sub partition"); + m_n_mem_sub_partition = m_n_mem * m_n_sub_partition_per_memory_channel; + fprintf(stdout, "Total number of memory sub partition = %u\n", m_n_mem_sub_partition); - m_address_mapping.init(m_n_mem, m_n_sub_partition_per_memory_channel); - m_L2_config.init(&m_address_mapping); + m_address_mapping.init(m_n_mem, m_n_sub_partition_per_memory_channel); + m_L2_config.init(&m_address_mapping); - m_valid = true; + m_valid = true; - sscanf(write_queue_size_opt, "%d:%d:%d", - &gpgpu_frfcfs_dram_write_queue_size, &write_high_watermark, - &write_low_watermark); - } - void reg_options(class OptionParser *opp); + sscanf(write_queue_size_opt,"%d:%d:%d", + &gpgpu_frfcfs_dram_write_queue_size,&write_high_watermark,&write_low_watermark); + } + void reg_options(class OptionParser * opp); - bool m_valid; - mutable l2_cache_config m_L2_config; - bool m_L2_texure_only; + bool m_valid; + mutable l2_cache_config m_L2_config; + bool m_L2_texure_only; - char *gpgpu_dram_timing_opt; - char *gpgpu_L2_queue_config; - bool l2_ideal; - unsigned gpgpu_frfcfs_dram_sched_queue_size; - unsigned gpgpu_dram_return_queue_size; - enum dram_ctrl_t scheduler_type; - bool gpgpu_memlatency_stat; - unsigned m_n_mem; - unsigned m_n_sub_partition_per_memory_channel; - unsigned m_n_mem_sub_partition; - unsigned gpu_n_mem_per_ctrlr; + char *gpgpu_dram_timing_opt; + char *gpgpu_L2_queue_config; + bool l2_ideal; + unsigned gpgpu_frfcfs_dram_sched_queue_size; + unsigned gpgpu_dram_return_queue_size; + enum dram_ctrl_t scheduler_type; + bool gpgpu_memlatency_stat; + unsigned m_n_mem; + unsigned m_n_sub_partition_per_memory_channel; + unsigned m_n_mem_sub_partition; + unsigned gpu_n_mem_per_ctrlr; - unsigned rop_latency; - unsigned dram_latency; + unsigned rop_latency; + unsigned dram_latency; - // DRAM parameters + // DRAM parameters - unsigned tCCDL; // column to column delay when bank groups are enabled - unsigned tRTPL; // read to precharge delay when bank groups are enabled for - // GDDR5 this is identical to RTPS, if for other DRAM this is - // different, you will need to split them in two + unsigned tCCDL; //column to column delay when bank groups are enabled + unsigned tRTPL; //read to precharge delay when bank groups are enabled for GDDR5 this is identical to RTPS, if for other DRAM this is different, you will need to split them in two - unsigned tCCD; // column to column delay - unsigned tRRD; // minimal time required between activation of rows in - // different banks - unsigned tRCD; // row to column delay - time required to activate a row - // before a read - unsigned tRCDWR; // row to column delay for a write command - unsigned tRAS; // time needed to activate row - unsigned tRP; // row precharge ie. deactivate row - unsigned - tRC; // row cycle time ie. precharge current, then activate different row - unsigned tCDLR; // Last data-in to Read command (switching from write to - // read) - unsigned tWR; // Last data-in to Row precharge + unsigned tCCD; //column to column delay + unsigned tRRD; //minimal time required between activation of rows in different banks + unsigned tRCD; //row to column delay - time required to activate a row before a read + unsigned tRCDWR; //row to column delay for a write command + unsigned tRAS; //time needed to activate row + unsigned tRP; //row precharge ie. deactivate row + unsigned tRC; //row cycle time ie. precharge current, then activate different row + unsigned tCDLR; //Last data-in to Read command (switching from write to read) + unsigned tWR; //Last data-in to Row precharge - unsigned CL; // CAS latency - unsigned WL; // WRITE latency - unsigned BL; // Burst Length in bytes (4 in GDDR3, 8 in GDDR5) - unsigned tRTW; // time to switch from read to write - unsigned tWTR; // time to switch from write to read - unsigned tWTP; // time to switch from write to precharge in the same bank - unsigned busW; + unsigned CL; //CAS latency + unsigned WL; //WRITE latency + unsigned BL; //Burst Length in bytes (4 in GDDR3, 8 in GDDR5) + unsigned tRTW; //time to switch from read to write + unsigned tWTR; //time to switch from write to read + unsigned tWTP; //time to switch from write to precharge in the same bank + unsigned busW; - unsigned nbkgrp; // number of bank groups (has to be power of 2) - unsigned - bk_tag_length; // number of bits that define a bank inside a bank group + unsigned nbkgrp; // number of bank groups (has to be power of 2) + unsigned bk_tag_length; //number of bits that define a bank inside a bank group - unsigned nbk; + unsigned nbk; - bool elimnate_rw_turnaround; + bool elimnate_rw_turnaround; - unsigned data_command_freq_ratio; // frequency ratio between DRAM data bus - // and command bus (2 for GDDR3, 4 for - // GDDR5) - unsigned - dram_atom_size; // number of bytes transferred per read or write command + unsigned data_command_freq_ratio; // frequency ratio between DRAM data bus and command bus (2 for GDDR3, 4 for GDDR5) + unsigned dram_atom_size; // number of bytes transferred per read or write command - linear_to_raw_address_translation m_address_mapping; + linear_to_raw_address_translation m_address_mapping; - unsigned icnt_flit_size; + unsigned icnt_flit_size; - unsigned dram_bnk_indexing_policy; - unsigned dram_bnkgrp_indexing_policy; - bool dual_bus_interface; + unsigned dram_bnk_indexing_policy; + unsigned dram_bnkgrp_indexing_policy; + bool dual_bus_interface; - bool seperate_write_queue_enabled; - char *write_queue_size_opt; - unsigned gpgpu_frfcfs_dram_write_queue_size; - unsigned write_high_watermark; - unsigned write_low_watermark; - bool m_perf_sim_memcpy; - bool simple_dram_model; + bool seperate_write_queue_enabled; + char *write_queue_size_opt; + unsigned gpgpu_frfcfs_dram_write_queue_size; + unsigned write_high_watermark; + unsigned write_low_watermark; + bool m_perf_sim_memcpy; + bool simple_dram_model; - gpgpu_context *gpgpu_ctx; + gpgpu_context* gpgpu_ctx; }; + extern bool g_interactive_debugger_enabled; -class gpgpu_sim_config : public power_config, - public gpgpu_functional_sim_config { - public: - gpgpu_sim_config(gpgpu_context *ctx) - : m_shader_config(ctx), m_memory_config(ctx) { - m_valid = false; - gpgpu_ctx = ctx; - } - void reg_options(class OptionParser *opp); - void init() { - gpu_stat_sample_freq = 10000; - gpu_runtime_stat_flag = 0; - sscanf(gpgpu_runtime_stat, "%d:%x", &gpu_stat_sample_freq, - &gpu_runtime_stat_flag); - m_shader_config.init(); - ptx_set_tex_cache_linesize(m_shader_config.m_L1T_config.get_line_sz()); - m_memory_config.init(); - init_clock_domains(); - power_config::init(); - Trace::init(); +class gpgpu_sim_config : public power_config, public gpgpu_functional_sim_config { +public: + gpgpu_sim_config(gpgpu_context* ctx): m_shader_config(ctx), m_memory_config(ctx) { + m_valid = false; + gpgpu_ctx = ctx; + } + void reg_options(class OptionParser * opp); + void init() + { + gpu_stat_sample_freq = 10000; + gpu_runtime_stat_flag = 0; + sscanf(gpgpu_runtime_stat, "%d:%x", &gpu_stat_sample_freq, &gpu_runtime_stat_flag); + m_shader_config.init(); + ptx_set_tex_cache_linesize(m_shader_config.m_L1T_config.get_line_sz()); + m_memory_config.init(); + init_clock_domains(); + power_config::init(); + Trace::init(); + - // initialize file name if it is not set - time_t curr_time; - time(&curr_time); - char *date = ctime(&curr_time); - char *s = date; - while (*s) { - if (*s == ' ' || *s == '\t' || *s == ':') *s = '-'; - if (*s == '\n' || *s == '\r') *s = 0; - s++; + // initialize file name if it is not set + time_t curr_time; + time(&curr_time); + char *date = ctime(&curr_time); + char *s = date; + while (*s) { + if (*s == ' ' || *s == '\t' || *s == ':') *s = '-'; + if (*s == '\n' || *s == '\r' ) *s = 0; + s++; + } + char buf[1024]; + snprintf(buf,1024,"gpgpusim_visualizer__%s.log.gz",date); + g_visualizer_filename = strdup(buf); + + m_valid=true; } - char buf[1024]; - snprintf(buf, 1024, "gpgpusim_visualizer__%s.log.gz", date); - g_visualizer_filename = strdup(buf); - m_valid = true; - } + unsigned num_shader() const { return m_shader_config.num_shader(); } + unsigned num_cluster() const { return m_shader_config.n_simt_clusters; } + unsigned get_max_concurrent_kernel() const { return max_concurrent_kernel; } + unsigned checkpoint_option; + + size_t stack_limit() const {return stack_size_limit; } + size_t heap_limit() const {return heap_size_limit; } + size_t sync_depth_limit() const {return runtime_sync_depth_limit; } + size_t pending_launch_count_limit() const {return runtime_pending_launch_count_limit;} - unsigned num_shader() const { return m_shader_config.num_shader(); } - unsigned num_cluster() const { return m_shader_config.n_simt_clusters; } - unsigned get_max_concurrent_kernel() const { return max_concurrent_kernel; } - unsigned checkpoint_option; +private: + void init_clock_domains(void ); - size_t stack_limit() const { return stack_size_limit; } - size_t heap_limit() const { return heap_size_limit; } - size_t sync_depth_limit() const { return runtime_sync_depth_limit; } - size_t pending_launch_count_limit() const { - return runtime_pending_launch_count_limit; - } - private: - void init_clock_domains(void); + // backward pointer + class gpgpu_context* gpgpu_ctx; + bool m_valid; + shader_core_config m_shader_config; + memory_config m_memory_config; + // clock domains - frequency + double core_freq; + double icnt_freq; + double dram_freq; + double l2_freq; + double core_period; + double icnt_period; + double dram_period; + double l2_period; - // backward pointer - class gpgpu_context *gpgpu_ctx; - bool m_valid; - shader_core_config m_shader_config; - memory_config m_memory_config; - // clock domains - frequency - double core_freq; - double icnt_freq; - double dram_freq; - double l2_freq; - double core_period; - double icnt_period; - double dram_period; - double l2_period; + // GPGPU-Sim timing model options + unsigned long long gpu_max_cycle_opt; + unsigned long long gpu_max_insn_opt; + unsigned gpu_max_cta_opt; + char *gpgpu_runtime_stat; + bool gpgpu_flush_l1_cache; + bool gpgpu_flush_l2_cache; + bool gpu_deadlock_detect; + int gpgpu_frfcfs_dram_sched_queue_size; + int gpgpu_cflog_interval; + char * gpgpu_clock_domains; + unsigned max_concurrent_kernel; - // GPGPU-Sim timing model options - unsigned long long gpu_max_cycle_opt; - unsigned long long gpu_max_insn_opt; - unsigned gpu_max_cta_opt; - char *gpgpu_runtime_stat; - bool gpgpu_flush_l1_cache; - bool gpgpu_flush_l2_cache; - bool gpu_deadlock_detect; - int gpgpu_frfcfs_dram_sched_queue_size; - int gpgpu_cflog_interval; - char *gpgpu_clock_domains; - unsigned max_concurrent_kernel; + // visualizer + bool g_visualizer_enabled; + char *g_visualizer_filename; + int g_visualizer_zlevel; - // visualizer - bool g_visualizer_enabled; - char *g_visualizer_filename; - int g_visualizer_zlevel; - // statistics collection - int gpu_stat_sample_freq; - int gpu_runtime_stat_flag; + // statistics collection + int gpu_stat_sample_freq; + int gpu_runtime_stat_flag; - // Device Limits - size_t stack_size_limit; - size_t heap_size_limit; - size_t runtime_sync_depth_limit; - size_t runtime_pending_launch_count_limit; + // Device Limits + size_t stack_size_limit; + size_t heap_size_limit; + size_t runtime_sync_depth_limit; + size_t runtime_pending_launch_count_limit; - // gpu compute capability options - unsigned int gpgpu_compute_capability_major; - unsigned int gpgpu_compute_capability_minor; - unsigned long long liveness_message_freq; + //gpu compute capability options + unsigned int gpgpu_compute_capability_major; + unsigned int gpgpu_compute_capability_minor; + unsigned long long liveness_message_freq; - friend class gpgpu_sim; + friend class gpgpu_sim; }; struct occupancy_stats { - occupancy_stats() - : aggregate_warp_slot_filled(0), aggregate_theoretical_warp_slots(0) {} - occupancy_stats(unsigned long long wsf, unsigned long long tws) - : aggregate_warp_slot_filled(wsf), - aggregate_theoretical_warp_slots(tws) {} + occupancy_stats() : aggregate_warp_slot_filled(0), aggregate_theoretical_warp_slots(0){} + occupancy_stats( unsigned long long wsf, unsigned long long tws ) + : aggregate_warp_slot_filled(wsf), aggregate_theoretical_warp_slots(tws){} - unsigned long long aggregate_warp_slot_filled; - unsigned long long aggregate_theoretical_warp_slots; + unsigned long long aggregate_warp_slot_filled; + unsigned long long aggregate_theoretical_warp_slots; - float get_occ_fraction() const { - return float(aggregate_warp_slot_filled) / - float(aggregate_theoretical_warp_slots); - } + float get_occ_fraction() const { + return float(aggregate_warp_slot_filled) / float(aggregate_theoretical_warp_slots); + } - occupancy_stats &operator+=(const occupancy_stats &rhs) { - aggregate_warp_slot_filled += rhs.aggregate_warp_slot_filled; - aggregate_theoretical_warp_slots += rhs.aggregate_theoretical_warp_slots; - return *this; - } + occupancy_stats& operator+=(const occupancy_stats& rhs) { + aggregate_warp_slot_filled += rhs.aggregate_warp_slot_filled; + aggregate_theoretical_warp_slots += rhs.aggregate_theoretical_warp_slots; + return *this; + } - occupancy_stats operator+(const occupancy_stats &rhs) const { - return occupancy_stats( - aggregate_warp_slot_filled + rhs.aggregate_warp_slot_filled, - aggregate_theoretical_warp_slots + - rhs.aggregate_theoretical_warp_slots); - } + occupancy_stats operator+(const occupancy_stats& rhs) const{ + return occupancy_stats( aggregate_warp_slot_filled + rhs.aggregate_warp_slot_filled, + aggregate_theoretical_warp_slots + rhs.aggregate_theoretical_warp_slots + ); + } }; class gpgpu_context; class ptx_instruction; class watchpoint_event { - public: - watchpoint_event() { - m_thread = NULL; - m_inst = NULL; - } - watchpoint_event(const ptx_thread_info *thd, const ptx_instruction *pI) { - m_thread = thd; - m_inst = pI; - } - const ptx_thread_info *thread() const { return m_thread; } - const ptx_instruction *inst() const { return m_inst; } - - private: - const ptx_thread_info *m_thread; - const ptx_instruction *m_inst; +public: + watchpoint_event() + { + m_thread=NULL; + m_inst=NULL; + } + watchpoint_event(const ptx_thread_info *thd, const ptx_instruction *pI) + { + m_thread=thd; + m_inst = pI; + } + const ptx_thread_info *thread() const { return m_thread; } + const ptx_instruction *inst() const { return m_inst; } +private: + const ptx_thread_info *m_thread; + const ptx_instruction *m_inst; }; class gpgpu_sim : public gpgpu_t { - public: - gpgpu_sim(const gpgpu_sim_config &config, gpgpu_context *ctx); - - void set_prop(struct cudaDeviceProp *prop); +public: + gpgpu_sim( const gpgpu_sim_config &config, gpgpu_context* ctx ); - void launch(kernel_info_t *kinfo); - bool can_start_kernel(); - unsigned finished_kernel(); - void set_kernel_done(kernel_info_t *kernel); - void stop_all_running_kernels(); + void set_prop( struct cudaDeviceProp *prop ); - void init(); - void cycle(); - bool active(); - bool cycle_insn_cta_max_hit() { - return (m_config.gpu_max_cycle_opt && - (gpu_tot_sim_cycle + gpu_sim_cycle) >= - m_config.gpu_max_cycle_opt) || - (m_config.gpu_max_insn_opt && - (gpu_tot_sim_insn + gpu_sim_insn) >= m_config.gpu_max_insn_opt) || - (m_config.gpu_max_cta_opt && - (gpu_tot_issued_cta >= m_config.gpu_max_cta_opt)); - } - void print_stats(); - void update_stats(); - void deadlock_check(); + void launch( kernel_info_t *kinfo ); + bool can_start_kernel(); + unsigned finished_kernel(); + void set_kernel_done( kernel_info_t *kernel ); + void stop_all_running_kernels(); - void get_pdom_stack_top_info(unsigned sid, unsigned tid, unsigned *pc, - unsigned *rpc); + void init(); + void cycle(); + bool active(); + bool cycle_insn_cta_max_hit() { + return (m_config.gpu_max_cycle_opt && (gpu_tot_sim_cycle + gpu_sim_cycle) >= m_config.gpu_max_cycle_opt) || + (m_config.gpu_max_insn_opt && (gpu_tot_sim_insn + gpu_sim_insn) >= m_config.gpu_max_insn_opt) || + (m_config.gpu_max_cta_opt && (gpu_tot_issued_cta >= m_config.gpu_max_cta_opt) ); + } + void print_stats(); + void update_stats(); + void deadlock_check(); - int shared_mem_size() const; - int shared_mem_per_block() const; - int compute_capability_major() const; - int compute_capability_minor() const; - int num_registers_per_core() const; - int num_registers_per_block() const; - int wrp_size() const; - int shader_clock() const; - int max_cta_per_core() const; - int get_max_cta(const kernel_info_t &k) const; - const struct cudaDeviceProp *get_prop() const; - enum divergence_support_t simd_model() const; + void get_pdom_stack_top_info( unsigned sid, unsigned tid, unsigned *pc, unsigned *rpc ); - unsigned threads_per_core() const; - bool get_more_cta_left() const; - bool kernel_more_cta_left(kernel_info_t *kernel) const; - bool hit_max_cta_count() const; - kernel_info_t *select_kernel(); + int shared_mem_size() const; + int shared_mem_per_block() const; + int compute_capability_major() const; + int compute_capability_minor() const; + int num_registers_per_core() const; + int num_registers_per_block() const; + int wrp_size() const; + int shader_clock() const; + int max_cta_per_core() const; + int get_max_cta( const kernel_info_t &k ) const; + const struct cudaDeviceProp *get_prop() const; + enum divergence_support_t simd_model() const; - const gpgpu_sim_config &get_config() const { return m_config; } - void gpu_print_stat(); - void dump_pipeline(int mask, int s, int m) const; + unsigned threads_per_core() const; + bool get_more_cta_left() const; + bool kernel_more_cta_left(kernel_info_t *kernel) const; + bool hit_max_cta_count() const; + kernel_info_t *select_kernel(); - void perf_memcpy_to_gpu(size_t dst_start_addr, size_t count); + const gpgpu_sim_config &get_config() const { return m_config; } + void gpu_print_stat(); + void dump_pipeline( int mask, int s, int m ) const; - // The next three functions added to be used by the functional simulation - // function + void perf_memcpy_to_gpu( size_t dst_start_addr, size_t count ); - //! Get shader core configuration - /*! - * Returning the configuration of the shader core, used by the functional - * simulation only so far - */ - const shader_core_config *getShaderCoreConfig(); + //The next three functions added to be used by the functional simulation function + + //! Get shader core configuration + /*! + * Returning the configuration of the shader core, used by the functional simulation only so far + */ + const shader_core_config * getShaderCoreConfig(); + + + //! Get shader core Memory Configuration + /*! + * Returning the memory configuration of the shader core, used by the functional simulation only so far + */ + const memory_config * getMemoryConfig(); + + + //! Get shader core SIMT cluster + /*! + * Returning the cluster of of the shader core, used by the functional simulation so far + */ + simt_core_cluster * getSIMTCluster(); - //! Get shader core Memory Configuration - /*! - * Returning the memory configuration of the shader core, used by the - * functional simulation only so far - */ - const memory_config *getMemoryConfig(); + void hit_watchpoint( unsigned watchpoint_num, ptx_thread_info *thd, const ptx_instruction *pI ); - //! Get shader core SIMT cluster - /*! - * Returning the cluster of of the shader core, used by the functional - * simulation so far - */ - simt_core_cluster *getSIMTCluster(); + // backward pointer + class gpgpu_context* gpgpu_ctx; - void hit_watchpoint(unsigned watchpoint_num, ptx_thread_info *thd, - const ptx_instruction *pI); +private: + // clocks + void reinit_clock_domains(void); + int next_clock_domain(void); + void issue_block2core(); + void print_dram_stats(FILE *fout) const; + void shader_print_runtime_stat( FILE *fout ); + void shader_print_l1_miss_stat( FILE *fout ) const; + void shader_print_cache_stats( FILE *fout ) const; + void shader_print_scheduler_stat( FILE* fout, bool print_dynamic_info ) const; + void visualizer_printstat(); + void print_shader_cycle_distro( FILE *fout ) const; - // backward pointer - class gpgpu_context *gpgpu_ctx; + void gpgpu_debug(); - private: - // clocks - void reinit_clock_domains(void); - int next_clock_domain(void); - void issue_block2core(); - void print_dram_stats(FILE *fout) const; - void shader_print_runtime_stat(FILE *fout); - void shader_print_l1_miss_stat(FILE *fout) const; - void shader_print_cache_stats(FILE *fout) const; - void shader_print_scheduler_stat(FILE *fout, bool print_dynamic_info) const; - void visualizer_printstat(); - void print_shader_cycle_distro(FILE *fout) const; +///// data ///// - void gpgpu_debug(); + class simt_core_cluster **m_cluster; + class memory_partition_unit **m_memory_partition_unit; + class memory_sub_partition **m_memory_sub_partition; - ///// data ///// + std::vector<kernel_info_t*> m_running_kernels; + unsigned m_last_issued_kernel; - class simt_core_cluster **m_cluster; - class memory_partition_unit **m_memory_partition_unit; - class memory_sub_partition **m_memory_sub_partition; + std::list<unsigned> m_finished_kernel; + // m_total_cta_launched == per-kernel count. gpu_tot_issued_cta == global count. + unsigned long long m_total_cta_launched; + unsigned long long gpu_tot_issued_cta; - std::vector<kernel_info_t *> m_running_kernels; - unsigned m_last_issued_kernel; + unsigned m_last_cluster_issue; + float * average_pipeline_duty_cycle; + float * active_sms; + // time of next rising edge + double core_time; + double icnt_time; + double dram_time; + double l2_time; - std::list<unsigned> m_finished_kernel; - // m_total_cta_launched == per-kernel count. gpu_tot_issued_cta == global - // count. - unsigned long long m_total_cta_launched; - unsigned long long gpu_tot_issued_cta; + // debug + bool gpu_deadlock; - unsigned m_last_cluster_issue; - float *average_pipeline_duty_cycle; - float *active_sms; - // time of next rising edge - double core_time; - double icnt_time; - double dram_time; - double l2_time; + //// configuration parameters //// + const gpgpu_sim_config &m_config; + + const struct cudaDeviceProp *m_cuda_properties; + const shader_core_config *m_shader_config; + const memory_config *m_memory_config; - // debug - bool gpu_deadlock; + // stats + class shader_core_stats *m_shader_stats; + class memory_stats_t *m_memory_stats; + class power_stat_t *m_power_stats; + class gpgpu_sim_wrapper *m_gpgpusim_wrapper; + unsigned long long last_gpu_sim_insn; - //// configuration parameters //// - const gpgpu_sim_config &m_config; + unsigned long long last_liveness_message_time; - const struct cudaDeviceProp *m_cuda_properties; - const shader_core_config *m_shader_config; - const memory_config *m_memory_config; + std::map<std::string, FuncCache> m_special_cache_config; - // stats - class shader_core_stats *m_shader_stats; - class memory_stats_t *m_memory_stats; - class power_stat_t *m_power_stats; - class gpgpu_sim_wrapper *m_gpgpusim_wrapper; - unsigned long long last_gpu_sim_insn; + 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::map<unsigned,watchpoint_event> g_watchpoint_hits; - unsigned long long last_liveness_message_time; + 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 - std::map<std::string, FuncCache> m_special_cache_config; - 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::map<unsigned, watchpoint_event> g_watchpoint_hits; +public: + unsigned long long gpu_sim_insn; + unsigned long long gpu_tot_sim_insn; + unsigned long long gpu_sim_insn_last_update; + unsigned gpu_sim_insn_last_update_sid; + occupancy_stats gpu_occupancy; + occupancy_stats gpu_tot_occupancy; - 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 + // performance counter for stalls due to congestion. + unsigned int gpu_stall_dramfull; + unsigned int gpu_stall_icnt2sh; + unsigned long long partiton_reqs_in_parallel; + unsigned long long partiton_reqs_in_parallel_total; + unsigned long long partiton_reqs_in_parallel_util; + unsigned long long partiton_reqs_in_parallel_util_total; + unsigned long long gpu_sim_cycle_parition_util; + unsigned long long gpu_tot_sim_cycle_parition_util; + unsigned long long partiton_replys_in_parallel; + unsigned long long partiton_replys_in_parallel_total; - public: - unsigned long long gpu_sim_insn; - unsigned long long gpu_tot_sim_insn; - unsigned long long gpu_sim_insn_last_update; - unsigned gpu_sim_insn_last_update_sid; - occupancy_stats gpu_occupancy; - occupancy_stats gpu_tot_occupancy; - // performance counter for stalls due to congestion. - unsigned int gpu_stall_dramfull; - unsigned int gpu_stall_icnt2sh; - unsigned long long partiton_reqs_in_parallel; - unsigned long long partiton_reqs_in_parallel_total; - unsigned long long partiton_reqs_in_parallel_util; - unsigned long long partiton_reqs_in_parallel_util_total; - unsigned long long gpu_sim_cycle_parition_util; - unsigned long long gpu_tot_sim_cycle_parition_util; - unsigned long long partiton_replys_in_parallel; - unsigned long long partiton_replys_in_parallel_total; + FuncCache get_cache_config(std::string kernel_name); + void set_cache_config(std::string kernel_name, FuncCache cacheConfig ); + bool has_special_cache_config(std::string kernel_name); + void change_cache_config(FuncCache cache_config); + void set_cache_config(std::string kernel_name); - FuncCache get_cache_config(std::string kernel_name); - void set_cache_config(std::string kernel_name, FuncCache cacheConfig); - bool has_special_cache_config(std::string kernel_name); - void change_cache_config(FuncCache cache_config); - void set_cache_config(std::string kernel_name); + //Jin: functional simulation for CDP +private: + //set by stream operation every time a functoinal simulation is done + bool m_functional_sim; + kernel_info_t * m_functional_sim_kernel; - // Jin: functional simulation for CDP - private: - // set by stream operation every time a functoinal simulation is done - bool m_functional_sim; - kernel_info_t *m_functional_sim_kernel; - - public: - bool is_functional_sim() { return m_functional_sim; } - kernel_info_t *get_functional_kernel() { return m_functional_sim_kernel; } - void functional_launch(kernel_info_t *k) { - m_functional_sim = true; - m_functional_sim_kernel = k; - } - void finish_functional_sim(kernel_info_t *k) { - assert(m_functional_sim); - assert(m_functional_sim_kernel == k); - m_functional_sim = false; - m_functional_sim_kernel = NULL; - } +public: + bool is_functional_sim() { return m_functional_sim; } + kernel_info_t * get_functional_kernel() { return m_functional_sim_kernel; } + void functional_launch(kernel_info_t * k) { + m_functional_sim = true; + m_functional_sim_kernel = k; + } + void finish_functional_sim(kernel_info_t * k) { + assert(m_functional_sim); + assert(m_functional_sim_kernel == k); + m_functional_sim = false; + m_functional_sim_kernel = NULL; + } }; + #endif |
