summaryrefslogtreecommitdiff
path: root/src/gpgpu-sim
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpgpu-sim')
-rw-r--r--src/gpgpu-sim/dram.cc2
-rw-r--r--src/gpgpu-sim/dram.h5
-rw-r--r--src/gpgpu-sim/gpu-cache.cc6
-rw-r--r--src/gpgpu-sim/gpu-sim.cc17
-rw-r--r--src/gpgpu-sim/gpu-sim.h39
-rw-r--r--src/gpgpu-sim/l2cache.cc11
-rw-r--r--src/gpgpu-sim/l2cache.h12
-rw-r--r--src/gpgpu-sim/mem_fetch.cc4
-rw-r--r--src/gpgpu-sim/mem_fetch.h5
-rw-r--r--src/gpgpu-sim/mem_latency_stat.cc5
-rw-r--r--src/gpgpu-sim/mem_latency_stat.h5
-rw-r--r--src/gpgpu-sim/power_stat.cc4
-rw-r--r--src/gpgpu-sim/power_stat.h6
-rw-r--r--src/gpgpu-sim/shader.cc24
-rw-r--r--src/gpgpu-sim/shader.h20
-rw-r--r--src/gpgpu-sim/stat-tool.cc33
-rw-r--r--src/gpgpu-sim/stat-tool.h12
17 files changed, 122 insertions, 88 deletions
diff --git a/src/gpgpu-sim/dram.cc b/src/gpgpu-sim/dram.cc
index 5e36d4b..d443d79 100644
--- a/src/gpgpu-sim/dram.cc
+++ b/src/gpgpu-sim/dram.cc
@@ -41,7 +41,7 @@ int PRINT_CYCLE = 0;
template class fifo_pipeline<mem_fetch>;
template class fifo_pipeline<dram_req_t>;
-dram_t::dram_t( unsigned int partition_id, const struct memory_config *config, memory_stats_t *stats,
+dram_t::dram_t( unsigned int partition_id, const memory_config *config, memory_stats_t *stats,
memory_partition_unit *mp, gpgpu_sim* gpu )
{
id = partition_id;
diff --git a/src/gpgpu-sim/dram.h b/src/gpgpu-sim/dram.h
index 7a3a2da..0bd9725 100644
--- a/src/gpgpu-sim/dram.h
+++ b/src/gpgpu-sim/dram.h
@@ -106,11 +106,12 @@ enum bank_grp_bits_position{
};
class mem_fetch;
+class memory_config;
class dram_t
{
public:
- dram_t( unsigned int parition_id, const struct memory_config *config, class memory_stats_t *stats,
+ dram_t( unsigned int parition_id, const memory_config *config, class memory_stats_t *stats,
class memory_partition_unit *mp, class gpgpu_sim* gpu );
bool full(bool is_write) const;
@@ -145,7 +146,7 @@ public:
- const struct memory_config *m_config;
+ const memory_config *m_config;
private:
bankgrp_t **bkgrp;
diff --git a/src/gpgpu-sim/gpu-cache.cc b/src/gpgpu-sim/gpu-cache.cc
index f1f6e19..1705821 100644
--- a/src/gpgpu-sim/gpu-cache.cc
+++ b/src/gpgpu-sim/gpu-cache.cc
@@ -1251,7 +1251,8 @@ data_cache::wr_miss_wa_naive( new_addr_type addr,
false, // Now performing a read
mf->get_access_warp_mask(),
mf->get_access_byte_mask(),
- mf->get_access_sector_mask());
+ mf->get_access_sector_mask(),
+ m_gpu->gpgpu_ctx);
mem_fetch *n_mf = new mem_fetch( *ma,
NULL,
@@ -1365,7 +1366,8 @@ data_cache::wr_miss_wa_fetch_on_write( new_addr_type addr,
false, // Now performing a read
mf->get_access_warp_mask(),
mf->get_access_byte_mask(),
- mf->get_access_sector_mask());
+ mf->get_access_sector_mask(),
+ m_gpu->gpgpu_ctx);
mem_fetch *n_mf = new mem_fetch( *ma,
NULL,
diff --git a/src/gpgpu-sim/gpu-sim.cc b/src/gpgpu-sim/gpu-sim.cc
index 93f041a..e4ae04f 100644
--- a/src/gpgpu-sim/gpu-sim.cc
+++ b/src/gpgpu-sim/gpu-sim.cc
@@ -545,16 +545,14 @@ void gpgpu_sim_config::reg_options(option_parser_t opp)
option_parser_register(opp, "-trace_sampling_memory_partition", OPT_INT32,
&Trace::sampling_memory_partition, "The memory partition which is printed using MEMPART_DPRINTF. Default -1 (i.e. all)",
"-1");
- ptx_file_line_stats_options(opp);
+ gpgpu_ctx->stats->ptx_file_line_stats_options(opp);
//Jin: kernel launch latency
- extern unsigned g_kernel_launch_latency;
option_parser_register(opp, "-gpgpu_kernel_launch_latency", OPT_INT32,
- &g_kernel_launch_latency, "Kernel launch latency in cycles. Default: 0",
+ &(gpgpu_ctx->device_runtime->g_kernel_launch_latency), "Kernel launch latency in cycles. Default: 0",
"0");
- extern bool g_cdp_enabled;
option_parser_register(opp, "-gpgpu_cdp_enabled", OPT_BOOL,
- &g_cdp_enabled, "Turn on CDP",
+ &(gpgpu_ctx->device_runtime->g_cdp_enabled), "Turn on CDP",
"0");
}
@@ -888,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) {
@@ -934,7 +932,7 @@ void gpgpu_sim::update_stats() {
void gpgpu_sim::print_stats()
{
- ptx_file_line_stats_write_file();
+ gpgpu_ctx->stats->ptx_file_line_stats_write_file();
gpu_print_stat();
if (g_network_mode) {
@@ -1107,8 +1105,7 @@ void gpgpu_sim::gpu_print_stat()
printf("gpu_tot_occupancy = %.4f\% \n", (gpu_occupancy + gpu_tot_occupancy).get_occ_fraction() * 100);
- extern unsigned long long g_max_total_param_size;
- fprintf(statfout, "max_total_param_size = %llu\n", g_max_total_param_size);
+ fprintf(statfout, "max_total_param_size = %llu\n", gpgpu_ctx->device_runtime->g_max_total_param_size);
// performance counter for stalls due to congestion.
printf("gpu_stall_dramfull = %d\n", gpu_stall_dramfull);
@@ -1831,7 +1828,7 @@ const shader_core_config * gpgpu_sim::getShaderCoreConfig()
return m_shader_config;
}
-const struct memory_config * gpgpu_sim::getMemoryConfig()
+const memory_config * gpgpu_sim::getMemoryConfig()
{
return m_memory_config;
}
diff --git a/src/gpgpu-sim/gpu-sim.h b/src/gpgpu-sim/gpu-sim.h
index 119b934..19e1eb3 100644
--- a/src/gpgpu-sim/gpu-sim.h
+++ b/src/gpgpu-sim/gpu-sim.h
@@ -33,6 +33,7 @@
#include "../trace.h"
#include "addrdec.h"
#include "shader.h"
+#include "gpu-cache.h"
#include <iostream>
#include <fstream>
#include <list>
@@ -143,13 +144,14 @@ struct power_config {
};
-
-struct memory_config {
- memory_config()
+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()
{
@@ -291,13 +293,14 @@ struct memory_config {
unsigned write_high_watermark;
unsigned write_low_watermark;
bool m_perf_sim_memcpy;
+ 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) {
+ gpgpu_sim_config(gpgpu_context* ctx): m_shader_config(ctx), m_memory_config(ctx) {
m_valid = false;
gpgpu_ctx = ctx;
}
@@ -424,6 +427,26 @@ struct occupancy_stats {
};
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;
+};
class gpgpu_sim : public gpgpu_t {
public:
@@ -487,7 +510,7 @@ public:
/*!
* Returning the memory configuration of the shader core, used by the functional simulation only so far
*/
- const struct memory_config * getMemoryConfig();
+ const memory_config * getMemoryConfig();
//! Get shader core SIMT cluster
@@ -496,6 +519,8 @@ public:
*/
simt_core_cluster * getSIMTCluster();
+ void hit_watchpoint( unsigned watchpoint_num, ptx_thread_info *thd, const ptx_instruction *pI );
+
// backward pointer
class gpgpu_context* gpgpu_ctx;
@@ -545,7 +570,7 @@ private:
const struct cudaDeviceProp *m_cuda_properties;
const shader_core_config *m_shader_config;
- const struct memory_config *m_memory_config;
+ const memory_config *m_memory_config;
// stats
class shader_core_stats *m_shader_stats;
@@ -560,6 +585,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::map<unsigned,watchpoint_event> g_watchpoint_hits;
+
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
diff --git a/src/gpgpu-sim/l2cache.cc b/src/gpgpu-sim/l2cache.cc
index 62e70a7..6540b52 100644
--- a/src/gpgpu-sim/l2cache.cc
+++ b/src/gpgpu-sim/l2cache.cc
@@ -49,7 +49,7 @@
mem_fetch * partition_mf_allocator::alloc(new_addr_type addr, mem_access_type type, unsigned size, bool wr, unsigned long long cycle ) const
{
assert( wr );
- mem_access_t access( type, addr, size, wr );
+ mem_access_t access( type, addr, size, wr, m_memory_config->gpgpu_ctx );
mem_fetch *mf = new mem_fetch( access,
NULL,
WRITE_PACKET_SIZE,
@@ -62,7 +62,7 @@ mem_fetch * partition_mf_allocator::alloc(new_addr_type addr, mem_access_type ty
}
memory_partition_unit::memory_partition_unit( unsigned partition_id,
- const struct memory_config *config,
+ const memory_config *config,
class memory_stats_t *stats,
class gpgpu_sim* gpu)
: m_id(partition_id), m_config(config), m_stats(stats), m_arbitration_metadata(config), m_gpu(gpu)
@@ -95,7 +95,7 @@ memory_partition_unit::~memory_partition_unit()
delete[] m_sub_partition;
}
-memory_partition_unit::arbitration_metadata::arbitration_metadata(const struct memory_config *config)
+memory_partition_unit::arbitration_metadata::arbitration_metadata(const memory_config *config)
: m_last_borrower(config->m_n_sub_partition_per_memory_channel - 1),
m_private_credit(config->m_n_sub_partition_per_memory_channel, 0),
m_shared_credit(0)
@@ -312,7 +312,7 @@ void memory_partition_unit::print( FILE *fp ) const
}
memory_sub_partition::memory_sub_partition( unsigned sub_partition_id,
- const struct memory_config *config,
+ const memory_config *config,
class memory_stats_t *stats,
class gpgpu_sim* gpu)
{
@@ -640,7 +640,8 @@ std::vector<mem_fetch*> memory_sub_partition::breakdown_request_to_sector_reques
mf->is_write(),
mf->get_access_warp_mask(),
mf->get_access_byte_mask() & byte_sector_mask,
- std::bitset<SECTOR_CHUNCK_SIZE>().set(j));
+ std::bitset<SECTOR_CHUNCK_SIZE>().set(j),
+ m_gpu->gpgpu_ctx);
mem_fetch *n_mf = new mem_fetch( *ma,
NULL,
diff --git a/src/gpgpu-sim/l2cache.h b/src/gpgpu-sim/l2cache.h
index 8ff2666..1f74c47 100644
--- a/src/gpgpu-sim/l2cache.h
+++ b/src/gpgpu-sim/l2cache.h
@@ -58,7 +58,7 @@ private:
class memory_partition_unit
{
public:
- memory_partition_unit( unsigned partition_id, const struct memory_config *config, class memory_stats_t *stats, class gpgpu_sim* gpu );
+ memory_partition_unit( unsigned partition_id, const memory_config *config, class memory_stats_t *stats, class gpgpu_sim* gpu );
~memory_partition_unit();
bool busy() const;
@@ -98,7 +98,7 @@ public:
private:
unsigned m_id;
- const struct memory_config *m_config;
+ const memory_config *m_config;
class memory_stats_t *m_stats;
class memory_sub_partition **m_sub_partition;
class dram_t *m_dram;
@@ -106,7 +106,7 @@ private:
class arbitration_metadata
{
public:
- arbitration_metadata(const struct memory_config *config);
+ arbitration_metadata(const memory_config *config);
// check if a subpartition still has credit
bool has_credits(int inner_sub_partition_id) const;
@@ -130,7 +130,7 @@ private:
std::vector<int> m_private_credit;
int m_shared_credit;
};
- arbitration_metadata m_arbitration_metadata;
+ arbitration_metadata m_arbitration_metadata;
// determine wheither a given subpartition can issue to DRAM
bool can_issue_to_dram(int inner_sub_partition_id);
@@ -149,7 +149,7 @@ private:
class memory_sub_partition
{
public:
- memory_sub_partition( unsigned sub_partition_id, const struct memory_config *config, class memory_stats_t *stats, class gpgpu_sim* gpu );
+ memory_sub_partition( unsigned sub_partition_id, const memory_config *config, class memory_stats_t *stats, class gpgpu_sim* gpu );
~memory_sub_partition();
unsigned get_id() const { return m_id; }
@@ -197,7 +197,7 @@ public:
private:
// data
unsigned m_id; //< the global sub partition ID
- const struct memory_config *m_config;
+ const memory_config *m_config;
class l2_cache *m_L2cache;
class L2interface *m_L2interface;
class gpgpu_sim* m_gpu;
diff --git a/src/gpgpu-sim/mem_fetch.cc b/src/gpgpu-sim/mem_fetch.cc
index c9b0484..6a00889 100644
--- a/src/gpgpu-sim/mem_fetch.cc
+++ b/src/gpgpu-sim/mem_fetch.cc
@@ -39,10 +39,10 @@ mem_fetch::mem_fetch( const mem_access_t &access,
unsigned wid,
unsigned sid,
unsigned tpc,
- const struct memory_config *config,
+ const memory_config *config,
unsigned long long cycle,
mem_fetch *m_original_mf,
- mem_fetch *m_original_wr_mf)
+ mem_fetch *m_original_wr_mf):m_access(access)
{
m_request_uid = sm_next_mf_request_uid++;
diff --git a/src/gpgpu-sim/mem_fetch.h b/src/gpgpu-sim/mem_fetch.h
index 4eb3a52..1cab9f2 100644
--- a/src/gpgpu-sim/mem_fetch.h
+++ b/src/gpgpu-sim/mem_fetch.h
@@ -47,6 +47,7 @@ enum mf_type {
#undef MF_TUP
#undef MF_TUP_END
+class memory_config;
class mem_fetch {
public:
mem_fetch( const mem_access_t &access,
@@ -55,7 +56,7 @@ public:
unsigned wid,
unsigned sid,
unsigned tpc,
- const struct memory_config *config,
+ const memory_config *config,
unsigned long long cycle,
mem_fetch *original_mf = NULL,
mem_fetch *original_wr_mf = NULL);
@@ -149,7 +150,7 @@ private:
static unsigned sm_next_mf_request_uid;
- const struct memory_config *m_mem_config;
+ const memory_config *m_mem_config;
unsigned icnt_flit_size;
mem_fetch* original_mf; //this pointer is set up when a request is divided into sector requests at L2 cache (if the req size > L2 sector size), so the pointer refers to the original request
diff --git a/src/gpgpu-sim/mem_latency_stat.cc b/src/gpgpu-sim/mem_latency_stat.cc
index d08ba39..a1b43a8 100644
--- a/src/gpgpu-sim/mem_latency_stat.cc
+++ b/src/gpgpu-sim/mem_latency_stat.cc
@@ -41,8 +41,9 @@
#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 struct memory_config *mem_config, const class gpgpu_sim* gpu )
+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 )
{
assert( mem_config->m_valid );
assert( shader_config->m_valid );
@@ -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/mem_latency_stat.h b/src/gpgpu-sim/mem_latency_stat.h
index 6ce568d..0c84972 100644
--- a/src/gpgpu-sim/mem_latency_stat.h
+++ b/src/gpgpu-sim/mem_latency_stat.h
@@ -32,11 +32,12 @@
#include <zlib.h>
#include <map>
+class memory_config;
class memory_stats_t {
public:
memory_stats_t( unsigned n_shader,
const class shader_core_config *shader_config,
- const struct memory_config *mem_config,
+ const memory_config *mem_config,
const class gpgpu_sim* gpu);
unsigned memlatstat_done( class mem_fetch *mf );
@@ -54,7 +55,7 @@ public:
unsigned m_n_shader;
const shader_core_config *m_shader_config;
- const struct memory_config *m_memory_config;
+ const memory_config *m_memory_config;
const class gpgpu_sim* m_gpu;
unsigned max_mrq_latency;
diff --git a/src/gpgpu-sim/power_stat.cc b/src/gpgpu-sim/power_stat.cc
index 007b4c6..2c02082 100644
--- a/src/gpgpu-sim/power_stat.cc
+++ b/src/gpgpu-sim/power_stat.cc
@@ -42,7 +42,7 @@
-power_mem_stat_t::power_mem_stat_t(const struct memory_config *mem_config, const shader_core_config *shdr_config, memory_stats_t *mem_stats, shader_core_stats *shdr_stats){
+power_mem_stat_t::power_mem_stat_t(const memory_config *mem_config, const shader_core_config *shdr_config, memory_stats_t *mem_stats, shader_core_stats *shdr_stats){
assert( mem_config->m_valid );
m_mem_stats = mem_stats;
m_config = mem_config;
@@ -266,7 +266,7 @@ for(unsigned i=0; i<m_config->num_shader(); ++i){
}
}
-power_stat_t::power_stat_t( const shader_core_config *shader_config,float * average_pipeline_duty_cycle,float *active_sms,shader_core_stats * shader_stats, const struct memory_config *mem_config,memory_stats_t * memory_stats)
+power_stat_t::power_stat_t( const shader_core_config *shader_config,float * average_pipeline_duty_cycle,float *active_sms,shader_core_stats * shader_stats, const memory_config *mem_config,memory_stats_t * memory_stats)
{
assert( shader_config->m_valid );
assert( mem_config->m_valid );
diff --git a/src/gpgpu-sim/power_stat.h b/src/gpgpu-sim/power_stat.h
index 91fade9..24ade99 100644
--- a/src/gpgpu-sim/power_stat.h
+++ b/src/gpgpu-sim/power_stat.h
@@ -113,7 +113,7 @@ struct mem_power_stats_pod{
class power_mem_stat_t : public mem_power_stats_pod{
public:
- power_mem_stat_t(const struct memory_config *mem_config, const shader_core_config *shdr_config, memory_stats_t *mem_stats, shader_core_stats *shdr_stats);
+ power_mem_stat_t(const memory_config *mem_config, const shader_core_config *shdr_config, memory_stats_t *mem_stats, shader_core_stats *shdr_stats);
void visualizer_print( gzFile visualizer_file );
void print (FILE *fout) const;
void init();
@@ -128,7 +128,7 @@ private:
class power_stat_t {
public:
- power_stat_t( const shader_core_config *shader_config,float * average_pipeline_duty_cycle,float * active_sms,shader_core_stats * shader_stats, const struct memory_config *mem_config,memory_stats_t * memory_stats);
+ power_stat_t( const shader_core_config *shader_config,float * average_pipeline_duty_cycle,float * active_sms,shader_core_stats * shader_stats, const memory_config *mem_config,memory_stats_t * memory_stats);
void visualizer_print( gzFile visualizer_file );
void print (FILE *fout) const;
void save_stats(){
@@ -621,7 +621,7 @@ public:
float * m_average_pipeline_duty_cycle;
float * m_active_sms;
const shader_core_config *m_config;
- const struct memory_config *m_mem_config;
+ const memory_config *m_mem_config;
};
diff --git a/src/gpgpu-sim/shader.cc b/src/gpgpu-sim/shader.cc
index f380560..c697450 100644
--- a/src/gpgpu-sim/shader.cc
+++ b/src/gpgpu-sim/shader.cc
@@ -28,7 +28,6 @@
#include <float.h>
#include "shader.h"
-#include "gpu-sim.h"
#include "addrdec.h"
#include "dram.h"
#include "stat-tool.h"
@@ -53,6 +52,19 @@
#define MIN(a,b) (((a)<(b))?(a):(b))
+mem_fetch *shader_core_mem_fetch_allocator::alloc( new_addr_type addr, mem_access_type type, unsigned size, bool wr, unsigned long long cycle ) const
+{
+ mem_access_t access( type, addr, size, wr, m_memory_config->gpgpu_ctx);
+ mem_fetch *mf = new mem_fetch( access,
+ NULL,
+ wr?WRITE_PACKET_SIZE:READ_PACKET_SIZE,
+ -1,
+ m_core_id,
+ m_cluster_id,
+ m_memory_config,
+ cycle);
+ return mf;
+}
/////////////////////////////////////////////////////////////////////////////
std::list<unsigned> shader_core_ctx::get_regs_written( const inst_t &fvt ) const
@@ -71,7 +83,7 @@ shader_core_ctx::shader_core_ctx( class gpgpu_sim *gpu,
unsigned shader_id,
unsigned tpc_id,
const shader_core_config *config,
- const struct memory_config *mem_config,
+ const memory_config *mem_config,
shader_core_stats *stats )
: core_t( gpu, NULL, config->warp_size, config->n_thread_per_shader ),
m_barriers( this, config->max_warps_per_shader, config->max_cta_per_core, config->max_barriers_per_cta, config->warp_size ),
@@ -732,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 ) {
@@ -742,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();
@@ -809,7 +821,7 @@ void shader_core_ctx::fetch()
// TODO: replace with use of allocator
// mem_fetch *mf = m_mem_fetch_allocator->alloc()
- mem_access_t acc(INST_ACC_R,ppc,nbytes,false);
+ mem_access_t acc(INST_ACC_R,ppc,nbytes,false, m_gpu->gpgpu_ctx);
mem_fetch *mf = new mem_fetch(acc,
NULL/*we don't have an instruction yet*/,
READ_PACKET_SIZE,
@@ -3787,7 +3799,7 @@ void opndcoll_rfu_t::collector_unit_t::dispatch()
simt_core_cluster::simt_core_cluster( class gpgpu_sim *gpu,
unsigned cluster_id,
const shader_core_config *config,
- const struct memory_config *mem_config,
+ const memory_config *mem_config,
shader_core_stats *stats,
class memory_stats_t *mstats )
{
diff --git a/src/gpgpu-sim/shader.h b/src/gpgpu-sim/shader.h
index 2837f1b..b0d7f7f 100644
--- a/src/gpgpu-sim/shader.h
+++ b/src/gpgpu-sim/shader.h
@@ -1727,6 +1727,7 @@ private:
friend class LooseRoundRobbinScheduler;
};
+class memory_config;
class shader_core_mem_fetch_allocator : public mem_fetch_allocator {
public:
shader_core_mem_fetch_allocator( unsigned core_id, unsigned cluster_id, const memory_config *config )
@@ -1735,20 +1736,7 @@ public:
m_cluster_id = cluster_id;
m_memory_config = config;
}
- mem_fetch *alloc( new_addr_type addr, mem_access_type type, unsigned size, bool wr, unsigned long long cycle ) const
- {
- mem_access_t access( type, addr, size, wr );
- mem_fetch *mf = new mem_fetch( access,
- NULL,
- wr?WRITE_PACKET_SIZE:READ_PACKET_SIZE,
- -1,
- m_core_id,
- m_cluster_id,
- m_memory_config,
- cycle);
- return mf;
- }
-
+ mem_fetch *alloc( new_addr_type addr, mem_access_type type, unsigned size, bool wr, unsigned long long cycle ) const;
mem_fetch *alloc( const warp_inst_t &inst, const mem_access_t &access, unsigned long long cycle ) const
{
warp_inst_t inst_copy = inst;
@@ -1777,7 +1765,7 @@ public:
unsigned shader_id,
unsigned tpc_id,
const shader_core_config *config,
- const struct memory_config *mem_config,
+ const memory_config *mem_config,
shader_core_stats *stats );
// used by simt_core_cluster:
@@ -2072,7 +2060,7 @@ public:
simt_core_cluster( class gpgpu_sim *gpu,
unsigned cluster_id,
const shader_core_config *config,
- const struct memory_config *mem_config,
+ const memory_config *mem_config,
shader_core_stats *stats,
memory_stats_t *mstats );
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 );