diff options
| author | andrewboktor <[email protected]> | 2015-03-05 13:18:54 -0800 |
|---|---|---|
| committer | andrewboktor <[email protected]> | 2015-03-05 13:18:54 -0800 |
| commit | 4dc9d53085b568aea0cefe75d599f87bb5e0841f (patch) | |
| tree | b9eb3212e2b7730771103d86336a72b2963a5796 /src | |
| parent | d46bf67b50b265dd3afae7c9a6a13c4cbdd6176f (diff) | |
| parent | 66d5ba0e9143b1bd6b839643bbffff6fb7db4aa6 (diff) | |
Merge pull request #9 from ElTantawy/master
initial support for CUDA 5.0, 5.5, 6.0 to get template from SDK running
Diffstat (limited to 'src')
| -rw-r--r-- | src/abstract_hardware_model.h | 7 | ||||
| -rw-r--r-- | src/cuda-sim/cuda-sim.cc | 72 | ||||
| -rw-r--r-- | src/cuda-sim/cuda-sim.h | 4 | ||||
| -rw-r--r-- | src/cuda-sim/ptx.y | 2 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_ir.cc | 4 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_ir.h | 6 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_loader.cc | 14 | ||||
| -rw-r--r-- | src/cuda-sim/ptxinfo.l | 1 | ||||
| -rw-r--r-- | src/cuda-sim/ptxinfo.y | 10 | ||||
| -rw-r--r-- | src/gpgpu-sim/shader.cc | 4 |
10 files changed, 79 insertions, 45 deletions
diff --git a/src/abstract_hardware_model.h b/src/abstract_hardware_model.h index 936d208..ba4ea29 100644 --- a/src/abstract_hardware_model.h +++ b/src/abstract_hardware_model.h @@ -443,6 +443,7 @@ private: unsigned m_texcache_linesize; }; + class gpgpu_t { public: gpgpu_t( const gpgpu_functional_sim_config &config ); @@ -497,7 +498,7 @@ protected: class memory_space *m_global_mem; class memory_space *m_tex_mem; class memory_space *m_surf_mem; - + unsigned long long m_dev_malloc; std::map<std::string, const struct textureReference*> m_NameToTextureRef; @@ -506,18 +507,20 @@ protected: std::map<const struct textureReference*, const struct textureReferenceAttr*> m_TextureRefToAttribute; }; -struct gpgpu_ptx_sim_kernel_info +struct gpgpu_ptx_sim_info { // Holds properties of the kernel (Kernel's resource use). // These will be set to zero if a ptxinfo file is not present. int lmem; int smem; int cmem; + int gmem; int regs; unsigned ptx_version; unsigned sm_target; }; + struct gpgpu_ptx_sim_arg { gpgpu_ptx_sim_arg() { m_start=NULL; } gpgpu_ptx_sim_arg(const void *arg, size_t size, size_t offset) diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc index ab54121..715be98 100644 --- a/src/cuda-sim/cuda-sim.cc +++ b/src/cuda-sim/cuda-sim.cc @@ -1382,7 +1382,7 @@ void set_param_gpgpu_num_shaders(int num_shaders) gpgpu_param_num_shaders = num_shaders; } -const struct gpgpu_ptx_sim_kernel_info* ptx_sim_kernel_info(const function_info *kernel) +const struct gpgpu_ptx_sim_info* ptx_sim_kernel_info(const function_info *kernel) { return kernel->get_kernel_info(); } @@ -1867,7 +1867,7 @@ unsigned translate_pc_to_ptxlineno(unsigned pc) int g_ptxinfo_error_detected; static char *g_ptxinfo_kname = NULL; -static struct gpgpu_ptx_sim_kernel_info g_ptxinfo_kinfo; +static struct gpgpu_ptx_sim_info g_ptxinfo; const char *get_ptxinfo_kname() { @@ -1876,18 +1876,25 @@ const char *get_ptxinfo_kname() void print_ptxinfo() { - printf ("GPGPU-Sim PTX: Kernel \'%s\' : regs=%u, lmem=%u, smem=%u, cmem=%u\n", - get_ptxinfo_kname(), - g_ptxinfo_kinfo.regs, - g_ptxinfo_kinfo.lmem, - g_ptxinfo_kinfo.smem, - g_ptxinfo_kinfo.cmem ); + if(! get_ptxinfo_kname()){ + printf ("GPGPU-Sim PTX: Binary info : gmem=%u, cmem=%u\n", + g_ptxinfo.gmem, + g_ptxinfo.cmem); + } + if(get_ptxinfo_kname()){ + printf ("GPGPU-Sim PTX: Kernel \'%s\' : regs=%u, lmem=%u, smem=%u, cmem=%u\n", + get_ptxinfo_kname(), + g_ptxinfo.regs, + g_ptxinfo.lmem, + g_ptxinfo.smem, + g_ptxinfo.cmem ); + } } -struct gpgpu_ptx_sim_kernel_info get_ptxinfo_kinfo() +struct gpgpu_ptx_sim_info get_ptxinfo() { - return g_ptxinfo_kinfo; + return g_ptxinfo; } void ptxinfo_function(const char *fname ) @@ -1898,39 +1905,54 @@ void ptxinfo_function(const char *fname ) void ptxinfo_regs( unsigned nregs ) { - g_ptxinfo_kinfo.regs=nregs; + g_ptxinfo.regs=nregs; } void ptxinfo_lmem( unsigned declared, unsigned system ) { - g_ptxinfo_kinfo.lmem=declared+system; + g_ptxinfo.lmem=declared+system; +} + +void ptxinfo_gmem( unsigned declared, unsigned system ) +{ + g_ptxinfo.gmem=declared+system; } void ptxinfo_smem( unsigned declared, unsigned system ) { - g_ptxinfo_kinfo.smem=declared+system; + g_ptxinfo.smem=declared+system; } void ptxinfo_cmem( unsigned nbytes, unsigned bank ) { - g_ptxinfo_kinfo.cmem+=nbytes; + g_ptxinfo.cmem+=nbytes; } void clear_ptxinfo() { free(g_ptxinfo_kname); g_ptxinfo_kname=NULL; - g_ptxinfo_kinfo.regs=0; - g_ptxinfo_kinfo.lmem=0; - g_ptxinfo_kinfo.smem=0; - g_ptxinfo_kinfo.cmem=0; - g_ptxinfo_kinfo.ptx_version=0; - g_ptxinfo_kinfo.sm_target=0; + g_ptxinfo.regs=0; + g_ptxinfo.lmem=0; + g_ptxinfo.smem=0; + g_ptxinfo.cmem=0; + g_ptxinfo.gmem=0; + g_ptxinfo.ptx_version=0; + g_ptxinfo.sm_target=0; } void ptxinfo_opencl_addinfo( std::map<std::string,function_info*> &kernels ) { + + if(! g_ptxinfo_kname) { + printf ("GPGPU-Sim PTX: Binary info : gmem=%u, cmem=%u\n", + g_ptxinfo.gmem, + g_ptxinfo.cmem); + clear_ptxinfo(); + return; + } + if( !strcmp("__cuda_dummy_entry__",g_ptxinfo_kname) ) { // this string produced by ptxas for empty ptx files (e.g., bandwidth test) clear_ptxinfo(); @@ -1943,13 +1965,13 @@ void ptxinfo_opencl_addinfo( std::map<std::string,function_info*> &kernels ) } else { printf ("GPGPU-Sim PTX: Kernel \'%s\' : regs=%u, lmem=%u, smem=%u, cmem=%u\n", g_ptxinfo_kname, - g_ptxinfo_kinfo.regs, - g_ptxinfo_kinfo.lmem, - g_ptxinfo_kinfo.smem, - g_ptxinfo_kinfo.cmem ); + g_ptxinfo.regs, + g_ptxinfo.lmem, + g_ptxinfo.smem, + g_ptxinfo.cmem ); function_info *finfo = k->second; assert(finfo!=NULL); - finfo->set_kernel_info( g_ptxinfo_kinfo ); + finfo->set_kernel_info( g_ptxinfo ); } clear_ptxinfo(); } diff --git a/src/cuda-sim/cuda-sim.h b/src/cuda-sim/cuda-sim.h index 4c26350..958daba 100644 --- a/src/cuda-sim/cuda-sim.h +++ b/src/cuda-sim/cuda-sim.h @@ -73,7 +73,7 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel, gpgpu_t *gpu, bool functionalSimulationMode = false); const warp_inst_t *ptx_fetch_inst( address_type pc ); -const struct gpgpu_ptx_sim_kernel_info* ptx_sim_kernel_info(const class function_info *kernel); +const struct gpgpu_ptx_sim_info* ptx_sim_kernel_info(const class function_info *kernel); void ptx_print_insn( address_type pc, FILE *fp ); std::string ptx_get_insn_str( address_type pc ); void set_param_gpgpu_num_shaders(int num_shaders); @@ -129,6 +129,6 @@ address_type get_return_pc( void *thd ); const char *get_ptxinfo_kname(); void print_ptxinfo(); void clear_ptxinfo(); -struct gpgpu_ptx_sim_kernel_info get_ptxinfo_kinfo(); +struct gpgpu_ptx_sim_info get_ptxinfo(); #endif diff --git a/src/cuda-sim/ptx.y b/src/cuda-sim/ptx.y index 770ee1d..79faddf 100644 --- a/src/cuda-sim/ptx.y +++ b/src/cuda-sim/ptx.y @@ -239,6 +239,7 @@ function_ident_param: IDENTIFIER { add_function_name($1); } LEFT_PAREN {func_hea ; function_decl_header: ENTRY_DIRECTIVE { $$ = 1; g_func_decl=1; func_header(".entry"); } + | VISIBLE_DIRECTIVE ENTRY_DIRECTIVE { $$ = 1; g_func_decl=1; func_header(".entry"); } | FUNC_DIRECTIVE { $$ = 0; g_func_decl=1; func_header(".func"); } | VISIBLE_DIRECTIVE FUNC_DIRECTIVE { $$ = 0; g_func_decl=1; func_header(".func"); } | EXTERN_DIRECTIVE FUNC_DIRECTIVE { $$ = 2; g_func_decl=1; func_header(".func"); } @@ -279,6 +280,7 @@ directive_statement: variable_declaration SEMI_COLON | TARGET_DIRECTIVE IDENTIFIER COMMA IDENTIFIER COMMA IDENTIFIER { target_header3($2,$4,$6); } | TARGET_DIRECTIVE IDENTIFIER { target_header($2); } | FILE_DIRECTIVE INT_OPERAND STRING { add_file($2,$3); } + | FILE_DIRECTIVE INT_OPERAND STRING COMMA INT_OPERAND COMMA INT_OPERAND { add_file($2,$3); } | LOC_DIRECTIVE INT_OPERAND INT_OPERAND INT_OPERAND | PRAGMA_DIRECTIVE STRING SEMI_COLON { add_pragma($2); } | function_decl SEMI_COLON {/*Do nothing*/} diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc index 490cb10..6943b48 100644 --- a/src/cuda-sim/ptx_ir.cc +++ b/src/cuda-sim/ptx_ir.cc @@ -843,14 +843,14 @@ void function_info::print_basic_block_dot() unsigned ptx_kernel_shmem_size( void *kernel_impl ) { function_info *f = (function_info*)kernel_impl; - const struct gpgpu_ptx_sim_kernel_info *kernel_info = f->get_kernel_info(); + const struct gpgpu_ptx_sim_info *kernel_info = f->get_kernel_info(); return kernel_info->smem; } unsigned ptx_kernel_nregs( void *kernel_impl ) { function_info *f = (function_info*)kernel_impl; - const struct gpgpu_ptx_sim_kernel_info *kernel_info = f->get_kernel_info(); + const struct gpgpu_ptx_sim_info *kernel_info = f->get_kernel_info(); return kernel_info->regs; } diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h index b51406e..601a13d 100644 --- a/src/cuda-sim/ptx_ir.h +++ b/src/cuda-sim/ptx_ir.h @@ -1229,12 +1229,12 @@ public: void param_to_shared( memory_space *shared_mem, symbol_table *symtab ); void list_param( FILE *fout ) const; - const struct gpgpu_ptx_sim_kernel_info* get_kernel_info () const + const struct gpgpu_ptx_sim_info* get_kernel_info () const { return &m_kernel_info; } - const void set_kernel_info (const struct gpgpu_ptx_sim_kernel_info &info) { + const void set_kernel_info (const struct gpgpu_ptx_sim_info &info) { m_kernel_info = info; m_kernel_info.ptx_version = 10*get_ptx_version().ver(); m_kernel_info.sm_target = get_ptx_version().target(); @@ -1282,7 +1282,7 @@ private: unsigned num_reconvergence_pairs; //Registers/shmem/etc. used (from ptxas -v), loaded from ___.ptxinfo along with ___.ptx - struct gpgpu_ptx_sim_kernel_info m_kernel_info; + struct gpgpu_ptx_sim_info m_kernel_info; symbol_table *m_symtab; diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc index 4ed57da..e293065 100644 --- a/src/cuda-sim/ptx_loader.cc +++ b/src/cuda-sim/ptx_loader.cc @@ -232,12 +232,14 @@ void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num ptxinfo_in = fopen(tempfile_ptxinfo,"r"); g_ptxinfo_filename = tempfile_ptxinfo; ptxinfo_parse(); - snprintf(commandline,1024,"rm -f %s %s %s", fname, fname2, tempfile_ptxinfo); - printf("GPGPU-Sim PTX: removing ptxinfo using \"%s\"\n", commandline); - result = system(commandline); - if( result != 0 ) { - printf("GPGPU-Sim PTX: ERROR ** while loading PTX (c) %d\n", result); - exit(1); + if( ! g_save_embedded_ptx ) { + snprintf(commandline,1024,"rm -f %s %s %s", fname, fname2, tempfile_ptxinfo); + printf("GPGPU-Sim PTX: removing ptxinfo using \"%s\"\n", commandline); + result = system(commandline); + if( result != 0 ) { + printf("GPGPU-Sim PTX: ERROR ** while loading PTX (c) %d\n", result); + exit(1); + } } } diff --git a/src/cuda-sim/ptxinfo.l b/src/cuda-sim/ptxinfo.l index 18bf77d..99ee1fc 100644 --- a/src/cuda-sim/ptxinfo.l +++ b/src/cuda-sim/ptxinfo.l @@ -56,6 +56,7 @@ unsigned ptxinfo_col = 0; "lmem" TC; return LMEM; "smem" TC; return SMEM; "cmem" TC; return CMEM; +"gmem" TC; return GMEM; "line" TC; return LINE; "for" TC; return FOR; diff --git a/src/cuda-sim/ptxinfo.y b/src/cuda-sim/ptxinfo.y index e4ba6b2..294412d 100644 --- a/src/cuda-sim/ptxinfo.y +++ b/src/cuda-sim/ptxinfo.y @@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %token LMEM %token SMEM %token CMEM +%token GMEM %token <string_value> IDENTIFIER %token PLUS %token COMMA @@ -65,6 +66,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. void ptxinfo_function(const char *fname ); void ptxinfo_regs( unsigned nregs ); void ptxinfo_lmem( unsigned declared, unsigned system ); + void ptxinfo_gmem( unsigned declared, unsigned system ); void ptxinfo_smem( unsigned declared, unsigned system ); void ptxinfo_cmem( unsigned nbytes, unsigned bank ); int ptxinfo_error(const char*); @@ -85,9 +87,10 @@ line_info: function_name | function_info { ptxinfo_addinfo(); } ; -function_name: FUNC QUOTE IDENTIFIER QUOTE { ptxinfo_function($3); } - | FUNC QUOTE IDENTIFIER QUOTE FOR QUOTE IDENTIFIER QUOTE { ptxinfo_function($3); } - +function_name: FUNC QUOTE IDENTIFIER QUOTE { ptxinfo_function($3); } + | FUNC QUOTE IDENTIFIER QUOTE FOR QUOTE IDENTIFIER QUOTE {ptxinfo_function($3); } + ; + function_info: info | function_info COMMA info ; @@ -96,6 +99,7 @@ info: USED INT_OPERAND REGS { ptxinfo_regs($2); } | tuple LMEM { ptxinfo_lmem(g_declared,g_system); } | tuple SMEM { ptxinfo_smem(g_declared,g_system); } | INT_OPERAND BYTES CMEM LEFT_SQUARE_BRACKET INT_OPERAND RIGHT_SQUARE_BRACKET { ptxinfo_cmem($1,$5); } + | INT_OPERAND BYTES GMEM { ptxinfo_gmem($1,0); } | INT_OPERAND BYTES LMEM { ptxinfo_lmem($1,0); } | INT_OPERAND BYTES SMEM { ptxinfo_smem($1,0); } | INT_OPERAND BYTES CMEM { ptxinfo_cmem($1,0); } diff --git a/src/gpgpu-sim/shader.cc b/src/gpgpu-sim/shader.cc index 3c105ab..f3ad1b0 100644 --- a/src/gpgpu-sim/shader.cc +++ b/src/gpgpu-sim/shader.cc @@ -2398,7 +2398,7 @@ unsigned int shader_core_config::max_cta( const kernel_info_t &k ) const //Limit by n_threads/shader unsigned int result_thread = n_thread_per_shader / padded_cta_size; - const struct gpgpu_ptx_sim_kernel_info *kernel_info = ptx_sim_kernel_info(kernel); + const struct gpgpu_ptx_sim_info *kernel_info = ptx_sim_kernel_info(kernel); //Limit by shmem/shader unsigned int result_shmem = (unsigned)-1; @@ -2418,7 +2418,7 @@ unsigned int shader_core_config::max_cta( const kernel_info_t &k ) const result = gs_min2(result, result_regs); result = gs_min2(result, result_cta); - static const struct gpgpu_ptx_sim_kernel_info* last_kinfo = NULL; + static const struct gpgpu_ptx_sim_info* last_kinfo = NULL; if (last_kinfo != kernel_info) { //Only print out stats if kernel_info struct changes last_kinfo = kernel_info; printf ("GPGPU-Sim uArch: CTA/core = %u, limited by:", result); |
