summaryrefslogtreecommitdiff
path: root/src/gpgpu-sim
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpgpu-sim')
-rw-r--r--src/gpgpu-sim/gpu-sim.cc2
-rw-r--r--src/gpgpu-sim/mem_latency_stat.cc3
-rw-r--r--src/gpgpu-sim/shader.cc4
-rw-r--r--src/gpgpu-sim/stat-tool.cc33
-rw-r--r--src/gpgpu-sim/stat-tool.h12
5 files changed, 29 insertions, 25 deletions
diff --git a/src/gpgpu-sim/gpu-sim.cc b/src/gpgpu-sim/gpu-sim.cc
index bdf989a..e4ae04f 100644
--- a/src/gpgpu-sim/gpu-sim.cc
+++ b/src/gpgpu-sim/gpu-sim.cc
@@ -886,7 +886,7 @@ void gpgpu_sim::init()
m_shader_stats->new_grid();
// initialize the control-flow, memory access, memory latency logger
if (m_config.g_visualizer_enabled) {
- create_thread_CFlogger( m_config.num_shader(), m_shader_config->n_thread_per_shader, 0, m_config.gpgpu_cflog_interval );
+ create_thread_CFlogger( gpgpu_ctx, m_config.num_shader(), m_shader_config->n_thread_per_shader, 0, m_config.gpgpu_cflog_interval );
}
shader_CTA_count_create( m_config.num_shader(), m_config.gpgpu_cflog_interval);
if (m_config.gpgpu_cflog_interval != 0) {
diff --git a/src/gpgpu-sim/mem_latency_stat.cc b/src/gpgpu-sim/mem_latency_stat.cc
index 4e94991..a1b43a8 100644
--- a/src/gpgpu-sim/mem_latency_stat.cc
+++ b/src/gpgpu-sim/mem_latency_stat.cc
@@ -41,6 +41,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include "../../libcuda/gpgpu_context.h"
memory_stats_t::memory_stats_t( unsigned n_shader, const shader_core_config *shader_config, const memory_config *mem_config, const class gpgpu_sim* gpu )
{
@@ -195,7 +196,7 @@ void memory_stats_t::memlatstat_dram_access(mem_fetch *mf)
mem_access_type_stats[mf->get_access_type()][dram_id][bank]++;
}
if (mf->get_pc() != (unsigned)-1)
- ptx_file_line_stats_add_dram_traffic(mf->get_pc(), mf->get_data_size());
+ m_gpu->gpgpu_ctx->stats->ptx_file_line_stats_add_dram_traffic(mf->get_pc(), mf->get_data_size());
}
void memory_stats_t::memlatstat_icnt2mem_pop(mem_fetch *mf)
diff --git a/src/gpgpu-sim/shader.cc b/src/gpgpu-sim/shader.cc
index b7ae95d..c697450 100644
--- a/src/gpgpu-sim/shader.cc
+++ b/src/gpgpu-sim/shader.cc
@@ -744,7 +744,7 @@ void shader_core_ctx::decode()
if( m_inst_fetch_buffer.m_valid ) {
// decode 1 or 2 instructions and place them into ibuffer
address_type pc = m_inst_fetch_buffer.m_pc;
- const warp_inst_t* pI1 = ptx_fetch_inst(pc);
+ const warp_inst_t* pI1 = m_gpu->gpgpu_ctx->ptx_fetch_inst(pc);
m_warp[m_inst_fetch_buffer.m_warp_id].ibuffer_fill(0,pI1);
m_warp[m_inst_fetch_buffer.m_warp_id].inc_inst_in_pipeline();
if( pI1 ) {
@@ -754,7 +754,7 @@ void shader_core_ctx::decode()
}else if(pI1->oprnd_type==FP_OP) {
m_stats->m_num_FPdecoded_insn[m_sid]++;
}
- const warp_inst_t* pI2 = ptx_fetch_inst(pc+pI1->isize);
+ const warp_inst_t* pI2 = m_gpu->gpgpu_ctx->ptx_fetch_inst(pc+pI1->isize);
if( pI2 ) {
m_warp[m_inst_fetch_buffer.m_warp_id].ibuffer_fill(1,pI2);
m_warp[m_inst_fetch_buffer.m_warp_id].inc_inst_in_pipeline();
diff --git a/src/gpgpu-sim/stat-tool.cc b/src/gpgpu-sim/stat-tool.cc
index 6a4c75b..35a4cc3 100644
--- a/src/gpgpu-sim/stat-tool.cc
+++ b/src/gpgpu-sim/stat-tool.cc
@@ -37,6 +37,7 @@
#include <map>
#include <algorithm>
#include <string>
+#include "../../libcuda/gpgpu_context.h"
////////////////////////////////////////////////////////////////////////////////
@@ -110,12 +111,10 @@ void spill_log_to_file (FILE *fout, int final, unsigned long long current_cycle
////////////////////////////////////////////////////////////////////////////////
-unsigned translate_pc_to_ptxlineno(unsigned pc);
-
static int n_thread_CFloggers = 0;
static thread_CFlocality** thread_CFlogger = NULL;
-void create_thread_CFlogger( int n_loggers, int n_threads, address_type start_pc, unsigned long long logging_interval)
+void create_thread_CFlogger(gpgpu_context* ctx, int n_loggers, int n_threads, address_type start_pc, unsigned long long logging_interval)
{
destroy_thread_CFlogger();
@@ -126,7 +125,7 @@ void create_thread_CFlogger( int n_loggers, int n_threads, address_type start_pc
char buffer[32];
for (int i = 0; i < n_thread_CFloggers; i++) {
snprintf(buffer, 32, "%02d", i);
- thread_CFlogger[i] = new thread_CFlocality( name_tpl + buffer, logging_interval, n_threads, start_pc);
+ thread_CFlogger[i] = new thread_CFlocality( ctx, name_tpl + buffer, logging_interval, n_threads, start_pc);
if (logging_interval != 0) {
add_snap_shot_trigger(thread_CFlogger[i]);
add_spill_log(thread_CFlogger[i]);
@@ -368,10 +367,10 @@ static int s_cache_access_logger_n_types = 0;
static std::vector<linear_histogram_logger> s_cache_access_logger;
enum cache_access_logger_types {
- NORMAL, TEXTURE, CONSTANT, INSTRUCTION
+ NORMALS, TEXTURE, CONSTANT, INSTRUCTION
};
-int get_shader_normal_cache_id() { return NORMAL; }
+int get_shader_normal_cache_id() { return NORMALS; }
int get_shader_texture_cache_id() { return TEXTURE; }
int get_shader_constant_cache_id() { return CONSTANT; }
int get_shader_instruction_cache_id() { return INSTRUCTION; }
@@ -394,7 +393,7 @@ void shader_cache_access_log( int logger_id, int type, int miss)
{
if (s_cache_access_logger_n_types == 0) return;
if (logger_id < 0) return;
- assert(type == NORMAL || type == TEXTURE || type == CONSTANT || type == INSTRUCTION);
+ assert(type == NORMALS || type == TEXTURE || type == CONSTANT || type == INSTRUCTION);
assert(miss == 0 || miss == 1);
s_cache_access_logger[logger_id].log(2 * type + miss);
@@ -404,7 +403,7 @@ void shader_cache_access_unlog( int logger_id, int type, int miss)
{
if (s_cache_access_logger_n_types == 0) return;
if (logger_id < 0) return;
- assert(type == NORMAL || type == TEXTURE || type == CONSTANT || type == INSTRUCTION);
+ assert(type == NORMALS || type == TEXTURE || type == CONSTANT || type == INSTRUCTION);
assert(miss == 0 || miss == 1);
s_cache_access_logger[logger_id].unlog(2 * type + miss);
@@ -477,22 +476,24 @@ void shader_CTA_count_visualizer_gzprint( gzFile fout )
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
-thread_insn_span::thread_insn_span(unsigned long long cycle)
+thread_insn_span::thread_insn_span(unsigned long long cycle, gpgpu_context* ctx)
: m_cycle(cycle),
#if (tr1_hash_map_ismap == 1)
m_insn_span_count()
#else
m_insn_span_count(32*1024)
#endif
-{
+{
+ gpgpu_ctx = ctx;
}
thread_insn_span::~thread_insn_span() { }
-thread_insn_span::thread_insn_span(const thread_insn_span& other)
+thread_insn_span::thread_insn_span(const thread_insn_span& other, gpgpu_context* ctx)
: m_cycle(other.m_cycle),
- m_insn_span_count(other.m_insn_span_count)
+ m_insn_span_count(other.m_insn_span_count)
{
+ gpgpu_ctx = ctx;
}
thread_insn_span& thread_insn_span::operator=(const thread_insn_span& other)
@@ -551,7 +552,7 @@ void thread_insn_span::print_sparse_histo(FILE *fout) const
int n_printed_entries = 0;
span_count_map::const_iterator i_sc = m_insn_span_count.begin();
for (; i_sc != m_insn_span_count.end(); ++i_sc) {
- unsigned ptx_lineno = translate_pc_to_ptxlineno(i_sc->first);
+ unsigned ptx_lineno = gpgpu_ctx->translate_pc_to_ptxlineno(i_sc->first);
fprintf(fout, "%u %d ", ptx_lineno, i_sc->second);
n_printed_entries++;
}
@@ -566,7 +567,7 @@ void thread_insn_span::print_sparse_histo(gzFile fout) const
int n_printed_entries = 0;
span_count_map::const_iterator i_sc = m_insn_span_count.begin();
for (; i_sc != m_insn_span_count.end(); ++i_sc) {
- unsigned ptx_lineno = translate_pc_to_ptxlineno(i_sc->first);
+ unsigned ptx_lineno = gpgpu_ctx->translate_pc_to_ptxlineno(i_sc->first);
gzprintf(fout, "%u %d ", ptx_lineno, i_sc->second);
n_printed_entries++;
}
@@ -578,14 +579,14 @@ void thread_insn_span::print_sparse_histo(gzFile fout) const
////////////////////////////////////////////////////////////////////////////////
-thread_CFlocality::thread_CFlocality(std::string name,
+thread_CFlocality::thread_CFlocality( gpgpu_context* ctx, std::string name,
unsigned long long snap_shot_interval,
int nthreads,
address_type start_pc,
unsigned long long start_cycle)
: snap_shot_trigger(snap_shot_interval), m_name(name),
m_nthreads(nthreads), m_thread_pc(nthreads, start_pc), m_cycle(start_cycle),
- m_thd_span(start_cycle)
+ m_thd_span(start_cycle, ctx)
{
std::fill(m_thread_pc.begin(), m_thread_pc.end(), -1); // so that hw thread with no work assigned will not clobber results
}
diff --git a/src/gpgpu-sim/stat-tool.h b/src/gpgpu-sim/stat-tool.h
index 5646f01..67b3923 100644
--- a/src/gpgpu-sim/stat-tool.h
+++ b/src/gpgpu-sim/stat-tool.h
@@ -35,6 +35,7 @@
#include <stdio.h>
#include <zlib.h>
+class gpgpu_context;
/////////////////////////////////////////////////////////////////////////////////////
// logger snapshot trigger:
// - automate the snap_shot part of loggers to avoid modifying simulation loop everytime
@@ -80,8 +81,8 @@ public:
class thread_insn_span {
public:
- thread_insn_span(unsigned long long cycle);
- thread_insn_span(const thread_insn_span& other);
+ thread_insn_span(unsigned long long cycle, gpgpu_context* ctx);
+ thread_insn_span(const thread_insn_span& other, gpgpu_context* ctx);
~thread_insn_span();
thread_insn_span& operator=(const thread_insn_span& other);
@@ -94,7 +95,8 @@ public:
void print_sparse_histo(FILE *fout) const;
void print_sparse_histo(gzFile fout) const;
-private:
+private:
+ gpgpu_context* gpgpu_ctx;
typedef tr1_hash_map<address_type, int> span_count_map;
unsigned long long m_cycle;
span_count_map m_insn_span_count;
@@ -102,7 +104,7 @@ private:
class thread_CFlocality : public snap_shot_trigger, public spill_log_interface {
public:
- thread_CFlocality(std::string name, unsigned long long snap_shot_interval,
+ thread_CFlocality(gpgpu_context* ctx, std::string name, unsigned long long snap_shot_interval,
int nthreads, address_type start_pc, unsigned long long start_cycle = 0);
~thread_CFlocality();
@@ -270,7 +272,7 @@ void try_snap_shot (unsigned long long current_cycle);
void set_spill_interval (unsigned long long interval);
void spill_log_to_file (FILE *fout, int final, unsigned long long current_cycle);
-void create_thread_CFlogger( int n_loggers, int n_threads, address_type start_pc, unsigned long long logging_interval);
+void create_thread_CFlogger(gpgpu_context* ctx, int n_loggers, int n_threads, address_type start_pc, unsigned long long logging_interval);
void destroy_thread_CFlogger( );
void cflog_update_thread_pc( int logger_id, int thread_id, address_type pc );
void cflog_snapshot( int logger_id, unsigned long long cycle );