From dda377ce2854d0e65f7f6531f6eb6b398bbbf888 Mon Sep 17 00:00:00 2001 From: Tor Aamodt Date: Sun, 3 Oct 2010 18:12:23 -0800 Subject: 1. integrating Inder's changes 2. edit to 3dfd to enable execution on Quadro 3. update script to not pass device directly to 3dfd on command line (which it does not support) [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 7810] --- configs/QuadroFX5800/gpgpusim.config | 3 +++ libcuda/cuda_runtime_api.cc | 18 +++++++----------- src/cuda-sim/ptx_ir.cc | 4 ++-- src/cuda-sim/ptx_loader.cc | 36 ++++++++++++++++++++++++++++++++++-- src/cuda-sim/ptx_loader.h | 3 +-- src/gpgpu-sim/gpu-sim.cc | 5 +++++ 6 files changed, 52 insertions(+), 17 deletions(-) diff --git a/configs/QuadroFX5800/gpgpusim.config b/configs/QuadroFX5800/gpgpusim.config index 8c14ea3..560796d 100644 --- a/configs/QuadroFX5800/gpgpusim.config +++ b/configs/QuadroFX5800/gpgpusim.config @@ -1,6 +1,7 @@ # functional simulator specification -gpgpu_ptx_instruction_classification 0 -gpgpu_ptx_sim_mode 0 +-gpgpu_ptx_force_max_capability 10 # high level architecture configuration -gpgpu_sm_uarch GT200 @@ -59,3 +60,5 @@ -gpgpu_operand_collector 1 -gpgpu_operand_collector_num_units 6 -gpgpu_operand_collector_num_units_sfu 8 + +-visualizer_enabled 0 diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index c7d19e0..d8092e8 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -1042,22 +1042,18 @@ void** CUDARTAPI __cudaRegisterFatBinary( void *fatCubin ) __cudaFatCudaBinary *info = (__cudaFatCudaBinary *)fatCubin; assert( info->version >= 3 ); unsigned num_ptx_versions=0; - unsigned max_capability=0; - unsigned selected_capability_offset=(unsigned)-1; + //unsigned max_capability=0; + //unsigned selected_capability_offset=(unsigned)-1; while( info->ptx[num_ptx_versions].gpuProfileName != NULL ) { unsigned capability=0; sscanf(info->ptx[num_ptx_versions].gpuProfileName,"compute_%u",&capability); - if( capability > max_capability ) { - max_capability = capability; - selected_capability_offset=num_ptx_versions; - } + + printf("GPGPU-Sim PTX: __cudaRegisterFatBinary found PTX versions for '%s', ", info->ident); + printf("capability = %s\n", info->ptx[num_ptx_versions].gpuProfileName ); + gpgpu_ptx_sim_add_ptxstring( fat_cubin_handle, info->ptx[num_ptx_versions].ptx, info->cubin[num_ptx_versions].cubin, info->ident, capability ); + num_ptx_versions++; } - if ( selected_capability_offset != (unsigned)-1 ) { - printf("GPGPU-Sim PTX: __cudaRegisterFatBinary found %u PTX versions for '%s', ", num_ptx_versions, info->ident); - printf("selected = %s\n", info->ptx[selected_capability_offset].gpuProfileName ); - gpgpu_ptx_sim_add_ptxstring( fat_cubin_handle, info->ptx[selected_capability_offset].ptx, info->cubin[selected_capability_offset].cubin, info->ident ); - } #endif return (void**)fat_cubin_handle; } diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc index db915fe..fd51de5 100644 --- a/src/cuda-sim/ptx_ir.cc +++ b/src/cuda-sim/ptx_ir.cc @@ -1219,8 +1219,8 @@ void gpgpu_ptx_assemble( std::string kname, void *kinfo ) { function_info *func_info = (function_info *)kinfo; if((function_info *)kinfo == NULL) { - printf("GPGPU-Sim PTX: Error - missing function definition \'%s\'\n", kname.c_str()); - abort(); + printf("GPGPU-Sim PTX: Warning - missing function definition \'%s\'\n", kname.c_str()); + return; } if( func_info->is_extern() ) { printf("GPGPU-Sim PTX: skipping assembly for extern declared function \'%s\'\n", func_info->get_name().c_str() ); diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc index cea9912..c836fac 100644 --- a/src/cuda-sim/ptx_loader.cc +++ b/src/cuda-sim/ptx_loader.cc @@ -83,6 +83,7 @@ struct ptx_info_t { char *cubin_str; char *fname; ptx_info_t *next; + unsigned capability; }; /// extern prototypes @@ -98,6 +99,7 @@ extern "C" FILE *ptxinfo_in; extern int g_ptx_convert_to_ptxplus; extern int g_ptx_save_converted_ptxplus; +extern unsigned g_ptx_force_max_capability; /// static functions @@ -209,6 +211,7 @@ static int ptx_file_filter( // global functions static ptx_info_t *g_ptx_source_array = NULL; +static unsigned g_ptx_max_capability = 0; void gpgpu_ptx_sim_load_gpu_kernels() { @@ -226,9 +229,33 @@ void gpgpu_ptx_sim_load_gpu_kernels() load_constants(symtab,STATIC_ALLOC_LIMIT); } else { if (!g_override_embedded_ptx) { - printf("GPGPU-Sim PTX: USING EMBEDDED .ptx files...\n"); + printf("GPGPU-Sim PTX: USING EMBEDDED .ptx files...\n"); + unsigned selected_capability = 0; + + if(g_ptx_force_max_capability == 0) { + // No forced max capability, selected the highest capability + //assert(g_ptx_max_capability > 0); + selected_capability = g_ptx_max_capability; + printf("GPGPU-Sim PTX: Loading PTX, selected capability: compute_%u\n", selected_capability); + } else { + // Forced max capability, select the highest capability less than or equal to forced capability + ptx_info_t *pti; + for( pti=g_ptx_source_array; pti!=NULL; pti=pti->next ){ + if(selected_capability < pti->capability && pti->capability <= g_ptx_force_max_capability) + selected_capability = pti->capability; + } + //assert(selected_capability > 0); + printf("GPGPU-Sim PTX: Loading PTX, max forced capability: compute_%u, selected capability: compute_%u\n", + g_ptx_force_max_capability, selected_capability); + } + ptx_info_t *s; for ( s=g_ptx_source_array; s!=NULL; s=s->next ) { + if(s->capability != selected_capability) + continue; + + printf("GPGPU-Sim PTX: Loading PTX for %s, capability = compute_%u\n", s->fname, s->capability); + symbol_table *symtab; source_num++; if(g_ptx_convert_to_ptxplus) { @@ -293,7 +320,7 @@ void gpgpu_ptx_sim_load_gpu_kernels() } } -void gpgpu_ptx_sim_add_ptxstring( unsigned fat_cubin_handle, const char *ptx_string, const char *cubin_string, const char *sourcefname ) +void gpgpu_ptx_sim_add_ptxstring( unsigned fat_cubin_handle, const char *ptx_string, const char *cubin_string, const char *sourcefname, unsigned capability ) { ptx_info_t *t = new ptx_info_t; t->next = NULL; @@ -311,6 +338,11 @@ void gpgpu_ptx_sim_add_ptxstring( unsigned fat_cubin_handle, const char *ptx_str t->cubin_str = NULL; } t->fname = strdup(sourcefname); + t->capability = capability; + + // Set overall max capability + if(g_ptx_max_capability < capability) + g_ptx_max_capability = capability; // put ptx source into a fifo if (g_ptx_source_array == NULL) { diff --git a/src/cuda-sim/ptx_loader.h b/src/cuda-sim/ptx_loader.h index 432ee10..6b9d2f8 100644 --- a/src/cuda-sim/ptx_loader.h +++ b/src/cuda-sim/ptx_loader.h @@ -74,8 +74,7 @@ extern memory_space *g_surf_mem; extern memory_space *g_param_mem; extern bool g_override_embedded_ptx; -void gpgpu_ptx_sim_load_gpu_kernels(); -void gpgpu_ptx_sim_add_ptxstring( unsigned cubin_handle, const char *ptx_string, const char *cubin_string, const char *sourcefname ); +void gpgpu_ptx_sim_add_ptxstring( unsigned fat_cubin_handle, const char *ptx_string, const char *cubin_string, const char *sourcefname, unsigned capability ); class symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, const char *p_for_info, unsigned source_num ); char* gpgpu_ptx_sim_convert_ptx_to_ptxplus(const char *ptx_str, const char *cubin_str, unsigned source_num); diff --git a/src/gpgpu-sim/gpu-sim.cc b/src/gpgpu-sim/gpu-sim.cc index 563dbae..bfa4fda 100644 --- a/src/gpgpu-sim/gpu-sim.cc +++ b/src/gpgpu-sim/gpu-sim.cc @@ -188,6 +188,7 @@ int g_ptx_inst_debug_thread_uid; int g_ptx_convert_to_ptxplus; int g_ptx_save_converted_ptxplus; +unsigned g_ptx_force_max_capability; void visualizer_options(option_parser_t opp); @@ -417,6 +418,10 @@ void gpgpu_sim::reg_options(option_parser_t opp) &g_ptx_save_converted_ptxplus, "Saved converted ptxplus to a file", "0"); + option_parser_register(opp, "-gpgpu_ptx_force_max_capability", OPT_UINT32, + &g_ptx_force_max_capability, + "Force maximum compute capability", + "0"); option_parser_register(opp, "-gpgpu_operand_collector", OPT_BOOL, &m_shader_config->gpgpu_operand_collector, "Enable operand collector model (default = off)", "0"); -- cgit v1.3