summaryrefslogtreecommitdiff
path: root/src/abstract_hardware_model.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/abstract_hardware_model.h')
-rw-r--r--src/abstract_hardware_model.h218
1 files changed, 177 insertions, 41 deletions
diff --git a/src/abstract_hardware_model.h b/src/abstract_hardware_model.h
index 1b764e2..27a1ba6 100644
--- a/src/abstract_hardware_model.h
+++ b/src/abstract_hardware_model.h
@@ -36,11 +36,16 @@ class kernel_info_t;
#define MAX_CTA_PER_SHADER 32
#define MAX_BARRIERS_PER_CTA 16
+//After expanding the vector input and output operands
+#define MAX_INPUT_VALUES 24
+#define MAX_OUTPUT_VALUES 8
+
enum _memory_space_t {
undefined_space=0,
reg_space,
local_space,
shared_space,
+ sstarr_space,
param_space_unclassified,
param_space_kernel, /* global to all threads in a kernel : read-only */
param_space_local, /* local to a thread : read-writable */
@@ -65,8 +70,10 @@ enum FuncCache
#include <string.h>
#include <stdio.h>
+#include <set>
typedef unsigned long long new_addr_type;
+typedef unsigned long long cudaTextureObject_t;
typedef unsigned address_type;
typedef unsigned addr_t;
@@ -76,9 +83,14 @@ enum uarch_op_t {
NO_OP=-1,
ALU_OP=1,
SFU_OP,
+ TENSOR_CORE_OP,
DP_OP,
+ SP_OP,
+ INTP_OP,
ALU_SFU_OP,
LOAD_OP,
+ TENSOR_CORE_LOAD_OP,
+ TENSOR_CORE_STORE_OP,
STORE_OP,
BRANCH_OP,
BARRIER_OP,
@@ -133,7 +145,9 @@ enum operation_pipeline_t {
UNKOWN_OP,
SP__OP,
DP__OP,
+ INTP__OP,
SFU__OP,
+ TENSOR_CORE__OP,
MEM__OP
};
typedef enum operation_pipeline_t operation_pipeline;
@@ -184,6 +198,9 @@ void increment_x_then_y_then_z( dim3 &i, const dim3 &bound);
class stream_manager;
struct CUstream_st;
extern stream_manager * g_stream_manager;
+//support for pinned memories added
+extern std::map<void *,void **> pinned_memory;
+extern std::map<void *, size_t> pinned_memory_size;
class kernel_info_t {
public:
@@ -195,7 +212,8 @@ public:
// m_num_cores_running=0;
// m_param_mem=NULL;
// }
- kernel_info_t( dim3 gridDim, dim3 blockDim, class function_info *entry );
+ kernel_info_t( dim3 gridDim, dim3 blockDim, class function_info *entry);
+ kernel_info_t( dim3 gridDim, dim3 blockDim, class function_info *entry, std::map<std::string, const struct cudaArray*> nameToCudaArray, std::map<std::string, const struct textureInfo*> nameToTextureInfo);
~kernel_info_t();
void inc_running() { m_num_cores_running++; }
@@ -233,6 +251,10 @@ public:
m_next_tid.z=0;
}
dim3 get_next_cta_id() const { return m_next_cta; }
+ unsigned get_next_cta_id_single() const
+ {
+ return m_next_cta.x + m_grid_dim.x*m_next_cta.y + m_grid_dim.x*m_grid_dim.y*m_next_cta.z;
+ }
bool no_more_ctas_to_run() const
{
return (m_next_cta.x >= m_grid_dim.x || m_next_cta.y >= m_grid_dim.y || m_next_cta.z >= m_grid_dim.z );
@@ -254,6 +276,23 @@ public:
std::list<class ptx_thread_info *> &active_threads() { return m_active_threads; }
class memory_space *get_param_memory() { return m_param_mem; }
+
+ //The following functions access texture bindings present at the kernel's launch
+
+ const struct cudaArray* get_texarray( const std::string &texname ) const
+ {
+ std::map<std::string,const struct cudaArray*>::const_iterator t=m_NameToCudaArray.find(texname);
+ assert(t != m_NameToCudaArray.end());
+ return t->second;
+ }
+
+ const struct textureInfo* get_texinfo( const std::string &texname ) const
+ {
+ std::map<std::string, const struct textureInfo*>::const_iterator t=m_NameToTextureInfo.find(texname);
+ assert(t != m_NameToTextureInfo.end());
+ return t->second;
+ }
+
private:
kernel_info_t( const kernel_info_t & ); // disable copy constructor
void operator=( const kernel_info_t & ); // disable copy operator
@@ -262,6 +301,10 @@ private:
unsigned m_uid;
static unsigned m_next_uid;
+
+ //These maps contain the snapshot of the texture mappings at kernel launch
+ std::map<std::string, const struct cudaArray*> m_NameToCudaArray;
+ std::map<std::string, const struct textureInfo*> m_NameToTextureInfo;
dim3 m_grid_dim;
dim3 m_block_dim;
@@ -301,6 +344,8 @@ public:
unsigned long long start_cycle;
unsigned long long end_cycle;
unsigned m_launch_latency;
+
+ mutable bool volta_cache_config_set;
};
struct core_config {
@@ -334,6 +379,7 @@ struct core_config {
unsigned gpgpu_shmem_sizeDefault;
unsigned gpgpu_shmem_sizePrefL1;
unsigned gpgpu_shmem_sizePrefShared;
+ unsigned mem_unit_ports;
// texture and constant cache line sizes (used to determine number of memory accesses)
unsigned gpgpu_cache_texl1_linesize;
@@ -341,6 +387,8 @@ struct core_config {
unsigned gpgpu_max_insn_issue_per_warp;
bool gmem_skip_L1D; // on = global memory access always skip the L1 cache
+
+ bool adaptive_volta_cache_config;
};
// bounded stack that implements simt reconvergence using pdom mechanism from MICRO'07 paper
@@ -361,7 +409,9 @@ public:
const simt_mask_t &get_active_mask() const;
void get_pdom_stack_top_info( unsigned *pc, unsigned *rpc ) const;
unsigned get_rp() const;
- void print(FILE*fp) const;
+ void print(FILE *fp) const;
+ void resume(char * fname) ;
+ void print_checkpoint (FILE *fout) const;
protected:
unsigned m_warp_id;
@@ -386,12 +436,13 @@ protected:
std::deque<simt_stack_entry> m_stack;
};
-#define GLOBAL_HEAP_START 0x703E20000
+#define GLOBAL_HEAP_START 0xC0000000
// start allocating from this address (lower values used for allocating globals in .ptx file)
-#define SHARED_MEM_SIZE_MAX (64*1024)
-#define LOCAL_MEM_SIZE_MAX (8*1024)
-#define MAX_STREAMING_MULTIPROCESSORS 64
+#define SHARED_MEM_SIZE_MAX (96*1024)
+#define LOCAL_MEM_SIZE_MAX (16*1024)
+#define MAX_STREAMING_MULTIPROCESSORS 80 //scale it to Volta
#define MAX_THREAD_PER_SM 2048
+#define MAX_WARP_PER_SM 64
#define TOTAL_LOCAL_MEM_PER_SM (MAX_THREAD_PER_SM*LOCAL_MEM_SIZE_MAX)
#define TOTAL_SHARED_MEM (MAX_STREAMING_MULTIPROCESSORS*SHARED_MEM_SIZE_MAX)
#define TOTAL_LOCAL_MEM (MAX_STREAMING_MULTIPROCESSORS*MAX_THREAD_PER_SM*LOCAL_MEM_SIZE_MAX)
@@ -480,14 +531,28 @@ public:
const char* get_ptx_inst_debug_file() const { return g_ptx_inst_debug_file; }
int get_ptx_inst_debug_thread_uid() const { return g_ptx_inst_debug_thread_uid; }
unsigned get_texcache_linesize() const { return m_texcache_linesize; }
-
+ int get_checkpoint_option() const {return checkpoint_option; }
+ int get_checkpoint_kernel() const {return checkpoint_kernel; }
+ int get_checkpoint_CTA() const {return checkpoint_CTA; }
+ int get_resume_option() const {return resume_option; }
+ int get_resume_kernel() const {return resume_kernel; }
+ int get_resume_CTA() const {return resume_CTA; }
+ int get_checkpoint_CTA_t() const {return checkpoint_CTA_t; }
+ int get_checkpoint_insn_Y() const {return checkpoint_insn_Y; }
private:
// PTX options
int m_ptx_convert_to_ptxplus;
int m_ptx_use_cuobjdump;
int m_experimental_lib_support;
unsigned m_ptx_force_max_capability;
-
+ int checkpoint_option;
+ int checkpoint_kernel;
+ int checkpoint_CTA;
+ int resume_option;
+ int resume_kernel;
+ int resume_CTA;
+ int checkpoint_CTA_t;
+ int checkpoint_insn_Y;
int g_ptx_inst_debug_to_file;
char* g_ptx_inst_debug_file;
int g_ptx_inst_debug_thread_uid;
@@ -499,6 +564,14 @@ private:
class gpgpu_t {
public:
gpgpu_t( const gpgpu_functional_sim_config &config );
+ int checkpoint_option;
+ int checkpoint_kernel;
+ int checkpoint_CTA;
+ int resume_option;
+ int resume_kernel;
+ int resume_CTA;
+ int checkpoint_CTA_t;
+ int checkpoint_insn_Y;
void* gpu_malloc( size_t size );
void* gpu_mallocarray( size_t count );
void gpu_memset( size_t dst_start_addr, int c, size_t count );
@@ -512,43 +585,43 @@ public:
void gpgpu_ptx_sim_bindTextureToArray(const struct textureReference* texref, const struct cudaArray* array);
void gpgpu_ptx_sim_bindNameToTexture(const char* name, const struct textureReference* texref, int dim, int readmode, int ext);
+ void gpgpu_ptx_sim_unbindTexture(const struct textureReference* texref);
const char* gpgpu_ptx_sim_findNamefromTexture(const struct textureReference* texref);
- const struct textureReference* get_texref(const std::string &texname) const
+ const struct textureReference* get_texref( const std::string &texname ) const
{
- std::map<std::string, const struct textureReference*>::const_iterator t=m_NameToTextureRef.find(texname);
- if( t == m_NameToTextureRef.end() ) {
- // search for :: prefixed names
- std::string temp("::" + texname);
- t=m_NameToTextureRef.find(temp);
- }
-
- assert(t != m_NameToTextureRef.end());
-
- return t->second;
+ std::map<std::string, std::set<const struct textureReference*> >::const_iterator t=m_NameToTextureRef.find(texname);
+ assert( t != m_NameToTextureRef.end() );
+ return *(t->second.begin());
}
- const struct cudaArray* get_texarray( const struct textureReference *texref ) const
+
+ const struct cudaArray* get_texarray( const std::string &texname ) const
{
- std::map<const struct textureReference*,const struct cudaArray*>::const_iterator t=m_TextureRefToCudaArray.find(texref);
- assert(t != m_TextureRefToCudaArray.end());
+ std::map<std::string,const struct cudaArray*>::const_iterator t=m_NameToCudaArray.find(texname);
+ assert(t != m_NameToCudaArray.end());
return t->second;
}
- const struct textureInfo* get_texinfo( const struct textureReference *texref ) const
+
+ const struct textureInfo* get_texinfo( const std::string &texname ) const
{
- std::map<const struct textureReference*, const struct textureInfo*>::const_iterator t=m_TextureRefToTexureInfo.find(texref);
- assert(t != m_TextureRefToTexureInfo.end());
+ std::map<std::string, const struct textureInfo*>::const_iterator t=m_NameToTextureInfo.find(texname);
+ assert(t != m_NameToTextureInfo.end());
return t->second;
}
- const struct textureReferenceAttr* get_texattr( const struct textureReference *texref ) const
+ const struct textureReferenceAttr* get_texattr( const std::string &texname ) const
{
- std::map<const struct textureReference*, const struct textureReferenceAttr*>::const_iterator t=m_TextureRefToAttribute.find(texref);
- assert(t != m_TextureRefToAttribute.end());
+ std::map<std::string, const struct textureReferenceAttr*>::const_iterator t=m_NameToAttribute.find(texname);
+ assert(t != m_NameToAttribute.end());
return t->second;
}
const gpgpu_functional_sim_config &get_config() const { return m_function_model_config; }
FILE* get_ptx_inst_debug_file() { return ptx_inst_debug_file; }
+
+ // These maps return the current texture mappings for the GPU at any given time.
+ std::map<std::string, const struct cudaArray*> getNameArrayMapping() {return m_NameToCudaArray;}
+ std::map<std::string, const struct textureInfo*> getNameInfoMapping() {return m_NameToTextureInfo;}
protected:
const gpgpu_functional_sim_config &m_function_model_config;
@@ -559,11 +632,12 @@ protected:
class memory_space *m_surf_mem;
unsigned long long m_dev_malloc;
-
- std::map<std::string, const struct textureReference*> m_NameToTextureRef;
- std::map<const struct textureReference*,const struct cudaArray*> m_TextureRefToCudaArray;
- std::map<const struct textureReference*, const struct textureInfo*> m_TextureRefToTexureInfo;
- std::map<const struct textureReference*, const struct textureReferenceAttr*> m_TextureRefToAttribute;
+ // These maps contain the current texture mappings for the GPU at any given time.
+ std::map<std::string, std::set<const struct textureReference*> > m_NameToTextureRef;
+ std::map<const struct textureReference*, std::string> m_TextureRefToName;
+ std::map<std::string, const struct cudaArray*> m_NameToCudaArray;
+ std::map<std::string, const struct textureInfo*> m_NameToTextureInfo;
+ std::map<std::string, const struct textureReferenceAttr*> m_NameToAttribute;
};
struct gpgpu_ptx_sim_info
@@ -613,6 +687,7 @@ public:
return false;
}
enum _memory_space_t get_type() const { return m_type; }
+ void set_type( enum _memory_space_t t ) { m_type = t; }
unsigned get_bank() const { return m_bank; }
void set_bank( unsigned b ) { m_bank = b; }
bool is_const() const { return (m_type == const_space) || (m_type == param_space_kernel); }
@@ -664,6 +739,7 @@ enum cache_operator_type {
CACHE_ALL, // .ca
CACHE_LAST_USE, // .lu
CACHE_VOLATILE, // .cv
+ CACHE_L1, // .nc
// loads and stores
CACHE_STREAMING, // .cs
@@ -765,7 +841,7 @@ public:
};
// the maximum number of destination, source, or address uarch operands in a instruction
-#define MAX_REG_OPERANDS 8
+#define MAX_REG_OPERANDS 32
struct dram_callback_t {
dram_callback_t() { function=NULL; instruction=NULL; thread=NULL; }
@@ -812,8 +888,8 @@ public:
{
fprintf(fp," [inst @ pc=0x%04x] ", pc );
}
- bool is_load() const { return (op == LOAD_OP || memory_op == memory_load); }
- bool is_store() const { return (op == STORE_OP || memory_op == memory_store); }
+ bool is_load() const { return (op == LOAD_OP ||op==TENSOR_CORE_LOAD_OP || memory_op == memory_load); }
+ bool is_store() const { return (op == STORE_OP ||op==TENSOR_CORE_STORE_OP || memory_op == memory_store); }
unsigned get_num_operands() const {return num_operands;}
unsigned get_num_regs() const {return num_regs;}
void set_num_regs(unsigned num) {num_regs=num;}
@@ -840,8 +916,10 @@ public:
address_type reconvergence_pc; // -1 => not a branch, -2 => use function return address
- unsigned out[4];
- unsigned in[4];
+ unsigned out[8];
+ unsigned outcount;
+ unsigned in[24];
+ unsigned incount;
unsigned char is_vectorin;
unsigned char is_vectorout;
int pred; // predicate register number
@@ -852,7 +930,7 @@ public:
int src[MAX_REG_OPERANDS];
} arch_reg;
//int arch_reg[MAX_REG_OPERANDS]; // register number for bank conflict evaluation
- unsigned latency; // operation latency
+ unsigned latency; // operation latency
unsigned initiation_interval;
unsigned data_size; // what is the size of the word being operated on?
@@ -904,7 +982,7 @@ public:
{
m_empty=true;
}
- void issue( const active_mask_t &mask, unsigned warp_id, unsigned long long cycle, int dynamic_warp_id )
+ void issue( const active_mask_t &mask, unsigned warp_id, unsigned long long cycle, int dynamic_warp_id, int sch_id )
{
m_warp_active_mask = mask;
m_warp_issued_mask = mask;
@@ -915,6 +993,7 @@ public:
cycles = initiation_interval;
m_cache_hit=false;
m_empty=false;
+ m_scheduler_id=sch_id;
}
const active_mask_t & get_active_mask() const
{
@@ -940,7 +1019,18 @@ public:
for(unsigned i=0; i<num_addrs; i++)
m_per_scalar_thread[n].memreqaddr[i] = addr[i];
}
-
+ void print_m_accessq(){
+
+ if(accessq_empty())
+ return;
+ else{
+ printf("Printing mem access generated\n");
+ std::list<mem_access_t>::iterator it;
+ for (it = m_accessq.begin(); it != m_accessq.end(); ++it){
+ printf("MEM_TXN_GEN:%s:%x, Size:%d \n",mem_access_type_str(it->get_type()), it->get_addr(),it->get_size());
+ }
+ }
+ }
struct transaction_info {
std::bitset<4> chunks; // bitmask: 32-byte chunks accessed
mem_access_byte_mask_t bytes;
@@ -995,6 +1085,10 @@ public:
assert( !m_empty );
return m_warp_id;
}
+ unsigned warp_id_func() const // to be used in functional simulations only
+ {
+ return m_warp_id;
+ }
unsigned dynamic_warp_id() const
{
assert( !m_empty );
@@ -1033,6 +1127,7 @@ public:
void print( FILE *fout ) const;
unsigned get_uid() const { return m_uid; }
+ unsigned get_schd_id() const { return m_scheduler_id; }
protected:
@@ -1065,6 +1160,8 @@ protected:
static unsigned sm_next_uid;
+ unsigned m_scheduler_id; //the scheduler that issues this inst
+
//Jin: cdp support
public:
int m_is_cdp;
@@ -1074,7 +1171,21 @@ public:
void move_warp( warp_inst_t *&dst, warp_inst_t *&src );
size_t get_kernel_code_size( class function_info *entry );
+class checkpoint
+{
+public:
+
+ checkpoint();
+ ~checkpoint(){
+ printf("clasfsfss destructed\n");
+ }
+
+ void load_global_mem(class memory_space *temp_mem, char * f1name);
+ void store_global_mem(class memory_space *mem, char * fname , char * format);
+ unsigned radnom;
+
+};
/*
* This abstract class used as a base for functional and performance and simulation, it has basic functional simulation
* data structures and procedures.
@@ -1157,6 +1268,14 @@ public:
}
return false;
}
+ bool has_free(bool sub_core_model, unsigned reg_id){
+ //in subcore model, each sched has a one specific reg to use (based on sched id)
+ if(!sub_core_model)
+ return has_free();
+
+ assert(reg_id < regs.size());
+ return regs[reg_id]->empty();
+ }
bool has_ready(){
for( unsigned i = 0; i < regs.size(); i++ ) {
if( not regs[i]->empty() ) {
@@ -1212,6 +1331,23 @@ public:
return NULL;
}
+ warp_inst_t ** get_free(bool sub_core_model, unsigned reg_id){
+ //in subcore model, each sched has a one specific reg to use (based on sched id)
+ if(!sub_core_model)
+ return get_free();
+
+ assert(reg_id < regs.size());
+ if( regs[reg_id]->empty() ) {
+ return &regs[reg_id];
+ }
+ assert(0 && "No free register found");
+ return NULL;
+ }
+
+ unsigned get_size(){
+ return regs.size();
+ }
+
private:
std::vector<warp_inst_t*> regs;
const char* m_name;