From b27f110d3ca92f7af869b298105ae014581367e9 Mon Sep 17 00:00:00 2001 From: speverel Date: Thu, 12 May 2016 14:45:11 -0700 Subject: Commented out line that checks for identifier in PTX file so that sim runs in 7.5 --- libcuda/cuda_runtime_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libcuda/cuda_runtime_api.cc') diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index eed4017..496d83c 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -1525,7 +1525,7 @@ cuobjdumpPTXSection* findPTXSectionInList(std::list sectionli ){ cuobjdumpPTXSection* ptxsection; if((ptxsection=dynamic_cast(*iter)) != NULL){ - if(ptxsection->getIdentifier() == identifier) + //if(ptxsection->getIdentifier() == identifier) return ptxsection; } } -- cgit v1.3 From 4bdf48ed2098e036da1503405c30b71f39be0e94 Mon Sep 17 00:00:00 2001 From: sspenst Date: Thu, 12 May 2016 16:54:39 -0700 Subject: added an assertion to pruneSectionList --- libcuda/cuda_runtime_api.cc | 2 ++ libcuda/cuobjdump.y | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'libcuda/cuda_runtime_api.cc') diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index 496d83c..7495767 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -1484,6 +1484,8 @@ std::list pruneSectionList(std::list cuobj delete *iter; } } + + assert(!prunedList.empty() && "WARNING: Change -gpgpu_ptx_force_max_capability in gpgpusim.config to match the largest Gencode argument in the Makefile"); return prunedList; } diff --git a/libcuda/cuobjdump.y b/libcuda/cuobjdump.y index f86d445..5fc0c8f 100644 --- a/libcuda/cuobjdump.y +++ b/libcuda/cuobjdump.y @@ -39,7 +39,7 @@ void setCuobjdumpelffilename(const char* filename); void setCuobjdumpsassfilename(const char* filename); int elfserial = 1; int ptxserial = 1; -int yydebug=1; + FILE *ptxfile; FILE *elffile; FILE *sassfile; -- cgit v1.3 From 7ac360c0a2defc5612fec6a106c703145e642aaa Mon Sep 17 00:00:00 2001 From: Ahmed ElTantawy Date: Fri, 13 May 2016 09:38:58 -0700 Subject: detailed error message when minimum found ptx capability is still larger than the maximum forced capability --- libcuda/cuda_runtime_api.cc | 22 ++++++++++++++-------- libcuda/cuobjdump.y | 6 ++---- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'libcuda/cuda_runtime_api.cc') diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index 7495767..f2e3359 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -1457,18 +1457,22 @@ std::list pruneSectionList(std::list cuobj std::list prunedList; - //Find the highest capability (that is lower than the forces maximum) for each cubin file + //Find the highest capability (that is lower than the forced maximum) for each cubin file //and set it in cuobjdumpSectionMap. Do this only for ptx sections std::map cuobjdumpSectionMap; + int min_ptx_capability_found=0; for ( std::list::iterator iter = cuobjdumpSectionList.begin(); iter != cuobjdumpSectionList.end(); iter++){ unsigned capability = (*iter)->getArch(); - if(dynamic_cast(*iter) != NULL && - (capability <= forced_max_capability || - forced_max_capability==0)) { - if(cuobjdumpSectionMap[(*iter)->getIdentifier()] < capability) - cuobjdumpSectionMap[(*iter)->getIdentifier()] = capability; + if(dynamic_cast(*iter) != NULL){ + if(capabilitygetIdentifier()] < capability) || + (cuobjdumpSectionMap.find((*iter)->getIdentifier())==cuobjdumpSectionMap.end())) + cuobjdumpSectionMap[(*iter)->getIdentifier()] = capability; + } } } @@ -1484,8 +1488,10 @@ std::list pruneSectionList(std::list cuobj delete *iter; } } - - assert(!prunedList.empty() && "WARNING: Change -gpgpu_ptx_force_max_capability in gpgpusim.config to match the largest Gencode argument in the Makefile"); + if(prunedList.empty()){ + printf("Error: No PTX sections found with sm capability that is lower than current forced maximum capability \n minimum ptx capability found = %u, maximum forced ptx capability = %u \n User might want to change either the forced maximum capability from gpgpusim configuration or update the compilation to generate the required PTX version",min_ptx_capability_found,forced_max_capability); + abort(); + } return prunedList; } diff --git a/libcuda/cuobjdump.y b/libcuda/cuobjdump.y index 29509e8..dce7e3d 100644 --- a/libcuda/cuobjdump.y +++ b/libcuda/cuobjdump.y @@ -39,7 +39,6 @@ void setCuobjdumpelffilename(const char* filename); void setCuobjdumpsassfilename(const char* filename); int elfserial = 1; int ptxserial = 1; -int yydebug = 1; FILE *ptxfile; FILE *elffile; FILE *sassfile; @@ -84,7 +83,6 @@ section : PTXHEADER { elffile = fopen(filename, "w"); setCuobjdumpelffilename(filename); } headerinfo identifier{ - printf("\nHeader Info and Identifier Parsed\n"); } elfcode { fclose(elffile); snprintf(filename, 1024, "_cuobjdump_%d.sass", elfserial++); @@ -107,8 +105,8 @@ headerinfo : H_SEPARATOR NEWLINE H_HOST IDENTIFIER NEWLINE H_COMPILESIZE IDENTIFIER {setCuobjdumparch($4);}; -identifier : H_IDENTIFIER FILENAME emptylines {setCuobjdumpidentifier($2);}; - | ; +identifier : H_IDENTIFIER FILENAME emptylines {setCuobjdumpidentifier($2);} + | {setCuobjdumpidentifier("default");}; compressedkeyword : H_COMPRESSED emptylines | ; -- cgit v1.3 From 1f25b1cc7a71898eda0216ec0a74cb55266cd4f0 Mon Sep 17 00:00:00 2001 From: Ahmed ElTantawy Date: Fri, 13 May 2016 09:47:22 -0700 Subject: remove the hackish comment and assign a default identifier for CUDA>=7.5 --- libcuda/cuda_runtime_api.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libcuda/cuda_runtime_api.cc') diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index f2e3359..fc6ca03 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -1533,7 +1533,7 @@ cuobjdumpPTXSection* findPTXSectionInList(std::list sectionli ){ cuobjdumpPTXSection* ptxsection; if((ptxsection=dynamic_cast(*iter)) != NULL){ - //if(ptxsection->getIdentifier() == identifier) + if(ptxsection->getIdentifier() == identifier) return ptxsection; } } @@ -1632,10 +1632,13 @@ void** CUDARTAPI __cudaRegisterFatBinary( void *fatCubin ) // - Obtains the pointer to the actual fatbin structure from the FatBin handle (fatCubin). // - An integer inside the fatbin structure contains the relative offset to the source code file name. // - This offset differs among different CUDA and GCC versions. + #if (CUDART_VERSION <= 6000) char * pfatbin = (char*) fatDeviceText->d; int offset = *((int*)(pfatbin+48)); char * filename = (pfatbin+16+offset); - + #else + char * filename = "default"; + #endif // The extracted file name is associated with a fat_cubin_handle passed // into cudaLaunch(). Inside cudaLaunch(), the associated file name is // used to find the PTX/SASS section from cuobjdump, which contains the -- cgit v1.3 From 2cbd1535c4babf19d3fa5a32f05633493d295146 Mon Sep 17 00:00:00 2001 From: sspenst Date: Fri, 13 May 2016 11:51:08 -0700 Subject: changed the SM version flag for generating ptxinfo to be dynamic instead of 20 --- libcuda/cuda_runtime_api.cc | 22 ++++++++++++++++------ src/cuda-sim/ptx_loader.cc | 5 +++-- src/cuda-sim/ptx_loader.h | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'libcuda/cuda_runtime_api.cc') diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index fc6ca03..910bebd 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -1469,8 +1469,8 @@ std::list pruneSectionList(std::list cuobj if(capabilitygetIdentifier()] < capability) || - (cuobjdumpSectionMap.find((*iter)->getIdentifier())==cuobjdumpSectionMap.end())) + if((cuobjdumpSectionMap.find((*iter)->getIdentifier())==cuobjdumpSectionMap.end()) + || (cuobjdumpSectionMap[(*iter)->getIdentifier()] < capability)) cuobjdumpSectionMap[(*iter)->getIdentifier()] = capability; } } @@ -1489,7 +1489,7 @@ std::list pruneSectionList(std::list cuobj } } if(prunedList.empty()){ - printf("Error: No PTX sections found with sm capability that is lower than current forced maximum capability \n minimum ptx capability found = %u, maximum forced ptx capability = %u \n User might want to change either the forced maximum capability from gpgpusim configuration or update the compilation to generate the required PTX version",min_ptx_capability_found,forced_max_capability); + printf("Error: No PTX sections found with sm capability that is lower than current forced maximum capability \n minimum ptx capability found = %u, maximum forced ptx capability = %u \n User might want to change either the forced maximum capability from gpgpusim configuration or update the compilation to generate the required PTX version\n",min_ptx_capability_found,forced_max_capability); abort(); } return prunedList; @@ -1575,6 +1575,16 @@ void cuobjdumpParseBinary(unsigned int handle){ fatbin_registered[handle] = true; CUctx_st *context = GPGPUSim_Context(); + unsigned max_capability = 0; + for ( std::list::iterator iter = cuobjdumpSectionList.begin(); + iter != cuobjdumpSectionList.end(); + iter++){ + unsigned capability = (*iter)->getArch(); + if (capability > max_capability) max_capability = capability; + } + + if (max_capability > 20) printf("WARNING: No guarantee that PTX will be parsed for SM version %u\n", max_capability); + std::string fname = fatbinmap[handle]; cuobjdumpPTXSection* ptx = findPTXSection(fname); @@ -1597,13 +1607,13 @@ void cuobjdumpParseBinary(unsigned int handle){ symtab=gpgpu_ptx_sim_load_ptx_from_string(ptxplus_str, handle); printf("Adding %s with cubin handle %u\n", ptx->getPTXfilename().c_str(), handle); context->add_binary(symtab, handle); - gpgpu_ptxinfo_load_from_string( ptxcode, handle); + gpgpu_ptxinfo_load_from_string( ptxcode, handle, max_capability ); delete[] ptxplus_str; } else { symtab=gpgpu_ptx_sim_load_ptx_from_string(ptxcode, handle); printf("Adding %s with cubin handle %u\n", ptx->getPTXfilename().c_str(), handle); context->add_binary(symtab, handle); - gpgpu_ptxinfo_load_from_string( ptxcode, handle); + gpgpu_ptxinfo_load_from_string( ptxcode, handle, max_capability ); } load_static_globals(symtab,STATIC_ALLOC_LIMIT,0xFFFFFFFF,context->get_device()->get_gpgpu()); load_constants(symtab,STATIC_ALLOC_LIMIT,context->get_device()->get_gpgpu()); @@ -1704,7 +1714,7 @@ void** CUDARTAPI __cudaRegisterFatBinary( void *fatCubin ) } else { symtab=gpgpu_ptx_sim_load_ptx_from_string(ptx,source_num); context->add_binary(symtab,fat_cubin_handle); - gpgpu_ptxinfo_load_from_string( ptx, source_num ); + gpgpu_ptxinfo_load_from_string( ptx, source_num, max_capability ); } source_num++; load_static_globals(symtab,STATIC_ALLOC_LIMIT,0xFFFFFFFF,context->get_device()->get_gpgpu()); diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc index e293065..5a17ec3 100644 --- a/src/cuda-sim/ptx_loader.cc +++ b/src/cuda-sim/ptx_loader.cc @@ -182,7 +182,7 @@ symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source return symtab; } -void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num ) +void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num, unsigned sm_version=20 ) { char fname[1024]; snprintf(fname,1024,"_ptx_XXXXXX"); @@ -216,7 +216,8 @@ void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num extra_flags[0]=0; #if CUDART_VERSION >= 3000 - snprintf(extra_flags,1024,"--gpu-name=sm_20"); + if (sm_version == 0) sm_version = 20; + snprintf(extra_flags,1024,"--gpu-name=sm_%u",sm_version); #endif snprintf(commandline,1024,"$CUDA_INSTALL_PATH/bin/ptxas %s -v %s --output-file /dev/null 2> %s", diff --git a/src/cuda-sim/ptx_loader.h b/src/cuda-sim/ptx_loader.h index cb02eda..e10db1c 100644 --- a/src/cuda-sim/ptx_loader.h +++ b/src/cuda-sim/ptx_loader.h @@ -32,7 +32,7 @@ extern bool g_override_embedded_ptx; class symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source_num ); -void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num ); +void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num, unsigned sm_version ); char* gpgpu_ptx_sim_convert_ptx_and_sass_to_ptxplus(const std::string ptx_str, const std::string sass_str, const std::string elf_str); bool keep_intermediate_files(); -- cgit v1.3