From e83f1eeb3329a29d29bca22fe2b919c71e3a611a Mon Sep 17 00:00:00 2001 From: "Andrew M. B. Boktor" Date: Thu, 3 May 2012 09:57:30 -0800 Subject: 1. Fixing ptx with sm_20 2. Fixing the choice of files (since new we can choose) 3. Not allowing sm_20 with PTXPlus, forcing max capability it to 19 and printing a warning [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 12279] --- libcuda/cuda_runtime_api.cc | 28 ++++++++++++++-------------- src/cuda-sim/ptx.l | 1 + src/cuda-sim/ptx.y | 2 ++ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index aca7167..0e52c89 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -1185,6 +1185,12 @@ void extract_ptx(){ unsigned get_best_version(std::list sectionlist, CUctx_st *context){ unsigned forced_max_capability = context->get_device()->get_gpgpu()->get_config().get_forced_max_capability(); + if (forced_max_capability >=20 && + context->get_device()->get_gpgpu()->get_config().convert_to_ptxplus()) { + printf("GPGPU-Sim: WARNING: Capability >= 20 are not supported in PTXPlus\n" + "\tSetting forced_max_capability to 19\n"); + forced_max_capability = 19; + } unsigned max_capability=0; std::list::iterator iter; @@ -1216,7 +1222,7 @@ unsigned get_number_of_ptx(std::list sectionlist, unsigned sel ){ unsigned capability = 0; sscanf(iter->arch, "sm_%u", &capability); - if(capability <= selected_capability && + if(capability == selected_capability && iter->type == PTXSECTION){ printf("Found compatible PTX section with capability %s\n", iter->arch); result++; @@ -1279,34 +1285,28 @@ void useCuobjdump() { ){ unsigned capability = 0; sscanf(iter->arch,"sm_%u", &capability); - if((capability <= selected_capability) && (iter->type == PTXSECTION)){ + if((capability == selected_capability) && (iter->type == PTXSECTION)){ symbol_table *symtab; char *ptxcode = readfile(iter->ptxfilename); if(context->get_device()->get_gpgpu()->get_config().convert_to_ptxplus() ) { cuobjdumpSection* elfsection = findelfsection(cuobjdump, selected_capability, iter->identifier); assert (elfsection!= NULL); - //char *elfcode = readfile(elfsection->elffilename); - //char *sasscode = readfile(elfsection->sassfilename); char *ptxplus_str = gpgpu_ptx_sim_convert_ptx_and_sass_to_ptxplus( iter->ptxfilename, elfsection->elffilename, elfsection->sassfilename); symtab=gpgpu_ptx_sim_load_ptx_from_string(ptxplus_str,source_num); printf("Adding %s with cubin handle %u\n", iter->ptxfilename, source_num); - //context->add_binary(symtab,total_ptx_files/*fat_cubin_handle*/); - //gpgpu_ptxinfo_load_from_string(ptxcode,total_ptx_files/*source_num*/); - context->add_binary(symtab, source_num/*fat_cubin_handle*/); - gpgpu_ptxinfo_load_from_string( ptxcode,total_ptx_files-source_num/*source_num*/); + context->add_binary(symtab, source_num); + gpgpu_ptxinfo_load_from_string( ptxcode,total_ptx_files-source_num); delete[] ptxplus_str; } else { - symtab=gpgpu_ptx_sim_load_ptx_from_string(ptxcode, source_num/*total_ptx_files*//*source_num*/); - context->add_binary(symtab,source_num/*fat_cubin_handle*/); - gpgpu_ptxinfo_load_from_string( ptxcode, total_ptx_files-source_num/*source_num */); + symtab=gpgpu_ptx_sim_load_ptx_from_string(ptxcode, source_num); + context->add_binary(symtab,source_num); + gpgpu_ptxinfo_load_from_string( ptxcode, total_ptx_files-source_num); } source_num++; - /*! - * The order of files in output of cuobjdump is reverse - */ + load_static_globals(symtab,STATIC_ALLOC_LIMIT,0xFFFFFFFF,context->get_device()->get_gpgpu()); load_constants(symtab,STATIC_ALLOC_LIMIT,context->get_device()->get_gpgpu()); } diff --git a/src/cuda-sim/ptx.l b/src/cuda-sim/ptx.l index 1d50a8d..01b479f 100644 --- a/src/cuda-sim/ptx.l +++ b/src/cuda-sim/ptx.l @@ -175,6 +175,7 @@ breakaddr TC; ptx_lval.int_value = BREAKADDR_OP; return OPCODE; \.union TC; return UNION_DIRECTIVE; /* not in PTX 2.1 */ \.version TC; return VERSION_DIRECTIVE; \.visible TC; return VISIBLE_DIRECTIVE; +\.address_size TC; return ADDRESS_SIZE_DIRECTIVE; \.constptr TC; return CONSTPTR_DIRECTIVE; /* Ptx plus directive for pointer to constant memory */ diff --git a/src/cuda-sim/ptx.y b/src/cuda-sim/ptx.y index 430fc00..8b65796 100644 --- a/src/cuda-sim/ptx.y +++ b/src/cuda-sim/ptx.y @@ -68,6 +68,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %token TEX_DIRECTIVE %token UNION_DIRECTIVE %token VERSION_DIRECTIVE +%token ADDRESS_SIZE_DIRECTIVE %token VISIBLE_DIRECTIVE %token IDENTIFIER %token INT_OPERAND @@ -251,6 +252,7 @@ statement_list: directive_statement { add_directive(); } directive_statement: variable_declaration SEMI_COLON | VERSION_DIRECTIVE DOUBLE_OPERAND { add_version_info($2, 0); } | VERSION_DIRECTIVE DOUBLE_OPERAND PLUS { add_version_info($2,1); } + | ADDRESS_SIZE_DIRECTIVE INT_OPERAND {/*Do nothing*/} | TARGET_DIRECTIVE IDENTIFIER COMMA IDENTIFIER { target_header2($2,$4); } | TARGET_DIRECTIVE IDENTIFIER COMMA IDENTIFIER COMMA IDENTIFIER { target_header3($2,$4,$6); } | TARGET_DIRECTIVE IDENTIFIER { target_header($2); } -- cgit v1.3