diff options
| author | Andrew M. B. Boktor <[email protected]> | 2012-04-25 19:44:41 -0800 |
|---|---|---|
| committer | Andrew Boktor <[email protected]> | 2014-08-14 13:19:06 -0700 |
| commit | 2c72a869f0bf5c27a9b4a159975e926ebc75b902 (patch) | |
| tree | c422ea5dadda7da6aa413d4ef89805ccfde1f6f3 | |
| parent | 93501bce1672d204b2fa8c2c2361a6485f813e9c (diff) | |
Removing all remaining traced of decuda
Stopping if someone tries to use PTXPlus without cuobjdump
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 12138]
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | getDecuda/decuda.patch | 37 | ||||
| -rwxr-xr-x | getDecuda/getDecuda.sh | 13 | ||||
| -rw-r--r-- | libcuda/cuda_runtime_api.cc | 66 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_loader.cc | 148 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_loader.h | 1 |
6 files changed, 8 insertions, 261 deletions
@@ -61,7 +61,6 @@ else TARGETS += $(SIM_LIB_DIR)/libOpenCL.so endif TARGETS += decuda_to_ptxplus/decuda_to_ptxplus - TARGETS += decuda gpgpusim: makedirs $(TARGETS) @@ -135,9 +134,6 @@ decuda_to_ptxplus/decuda_to_ptxplus: $(MAKE) -C ./decuda_to_ptxplus/ depend $(MAKE) -C ./decuda_to_ptxplus/ -decuda: - ./getDecuda/getDecuda.sh - makedirs: if [ ! -d $(SIM_LIB_DIR) ]; then mkdir -p $(SIM_LIB_DIR); fi; if [ ! -d $(SIM_OBJ_FILES_DIR)/libcuda ]; then mkdir -p $(SIM_OBJ_FILES_DIR)/libcuda; fi; diff --git a/getDecuda/decuda.patch b/getDecuda/decuda.patch deleted file mode 100644 index eab6c50..0000000 --- a/getDecuda/decuda.patch +++ /dev/null @@ -1,37 +0,0 @@ -diff -crB decuda/Instruction.py decudaplus/Instruction.py -*** decuda/Instruction.py 2010-07-24 05:28:03.000000000 -0700 ---- decudaplus/Instruction.py 2010-09-27 12:52:24.000000000 -0700 -*************** -*** 401,406 **** ---- 401,409 ---- - value = self.bits(0,0x001F0000) - else: - value = self.bits(0,0x007F0000) -+ if len(self.inst)==2: -+ if self.bits(1,0x00200000): -+ t_offset = 0 - - if opt_imm and self.fullinst and self.bits(1,0x00100000): - # Operand 3 is immediate -diff -crB decuda/Operand.py decudaplus/Operand.py -*** decuda/Operand.py 2010-07-24 05:28:03.000000000 -0700 ---- decudaplus/Operand.py 2010-09-27 12:52:24.000000000 -0700 -*************** -*** 176,183 **** - rv.write(("0x%06x") % value) - elif self.offset != None: - rv.write(("%s[$ofs%i%s%s0x%0"+width+"x]") % (_indir[self.indirection], self.offset, _ofs_inc[self.offset_inc], times, value)) -! elif self.indirection == OP_INDIRECTION_SHARED and self.size==16 and value in _param_space: -! rv.write(_param_space[value]) - elif self.indirection == OP_INDIRECTION_INTERNAL and value in _ldgpu_ops: - rv.write(_ldgpu_ops[value]) - else: ---- 176,183 ---- - rv.write(("0x%06x") % value) - elif self.offset != None: - rv.write(("%s[$ofs%i%s%s0x%0"+width+"x]") % (_indir[self.indirection], self.offset, _ofs_inc[self.offset_inc], times, value)) -! elif self.indirection == OP_INDIRECTION_SHARED and self.size==16 and value/2 in _param_space: -! rv.write(_param_space[value/2]) - elif self.indirection == OP_INDIRECTION_INTERNAL and value in _ldgpu_ops: - rv.write(_ldgpu_ops[value]) - else: diff --git a/getDecuda/getDecuda.sh b/getDecuda/getDecuda.sh deleted file mode 100755 index a63a2ec..0000000 --- a/getDecuda/getDecuda.sh +++ /dev/null @@ -1,13 +0,0 @@ -# This script downloads the latest version of decuda from http://github.com/laanwj/decuda, untars it and patches it. -# Only works with decuda 0.4.2. - -# decuda.patch must be in the same folder as getDecuda.sh - -cd ./getDecuda -wget -O decuda.tgz --no-check-certificate http://github.com/laanwj/decuda/tarball/master -tar -xf ./decuda.tgz -mv laanwj-decuda-c30bd17 decuda # if this fails, we need to check what has changed in decuda, or get a perminant link to decuda 0.4.2 -patch -d ./decuda < ./decuda.patch -rm ./decuda.tgz -mv decuda ../decuda -cd .. diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index c0d7be3..aca7167 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -1154,7 +1154,8 @@ void setCuobjdumpsassfilename(const char* filename){ } extern "C" int cuobjdump_parse(); extern "C" FILE *cuobjdump_in; -//! Return PTX file + +//! Call cuobjdump to extract everything (-elf -sass -ptx) to a file /*! * This Function extract the whole PTX (for all the files) using cuobjdump * */ @@ -1163,7 +1164,7 @@ void extract_ptx(){ char* whole_code; char fname[1024]="_ptx_whole_code_WESWW"; //! Running CUobjdump using dynamic link to current process - snprintf(command,1000,"cuobjdump -ptx -elf -sass /proc/%d/exe > %s",getpid(),fname); + snprintf(command,1000,"$CUDA_INSTALL_PATH/bin/cuobjdump -ptx -elf -sass /proc/%d/exe > %s",getpid(),fname); printf("Running cuobjdump using \"%s\"\n", command); int result = system(command); if(result) {printf("ERROR: Failed to execute: %s\n", command); exit(1);} @@ -1174,23 +1175,6 @@ void extract_ptx(){ cuobjdump_parse(); fclose(cuobjdump_in); printf("Done parsing!!!\n"); - // Just to stop things here - - /* Hadi's old code - FILE* fp = fopen(fname,"r"); - //! finding size of the file - int lSize= 0; - fseek (fp , 0 , SEEK_END); - lSize = ftell (fp); - rewind (fp); - //! allocate and copy the entire ptx - whole_code = (char*)malloc(lSize * sizeof(char)); - fread(whole_code,1,lSize,fp); - fclose(fp); - snprintf(command,1000,"rm %s",fname); - //system(command); - return whole_code; - */ } //! Return proper ptx version @@ -1217,23 +1201,8 @@ unsigned get_best_version(std::list<cuobjdumpSection> sectionlist, CUctx_st *con } } return max_capability; - - /* Hadi's old code - char* start_entry; - char* arch_pointer; - start_entry = strstr(ptx,"Fatbin ptx code:"); - while(start_entry){ - arch_pointer = strstr (start_entry,"arch = "); - unsigned int capability = 0; - sscanf(arch_pointer,"arch = sm_%u",&capability); - if(capability > max_capability && (forced_max_capability == 0 || capability <= forced_max_capability)){ - max_capability = capability; - } - start_entry = strstr(arch_pointer,"Fatbin ptx code:"); - } - return max_capability; - */ } + /*! * Return number of diffrent ptx files generated in first argument * which have sm version equal to selected_capability @@ -1254,20 +1223,6 @@ unsigned get_number_of_ptx(std::list<cuobjdumpSection> sectionlist, unsigned sel } } return result; - /* Hadi's old code - char* start_entry; - char* arch_pointer; - start_entry = strstr(ptx,"Fatbin ptx code:"); - while(start_entry){ - arch_pointer = strstr (start_entry,"arch = "); - unsigned int capability = 0; - sscanf(arch_pointer,"arch = sm_%u",&capability); - if(capability == selected_capability) - result++; - start_entry = strstr(arch_pointer,"Fatbin ptx code:"); - } - */ - } char* readfile (const char* filename){ @@ -1415,16 +1370,9 @@ void** CUDARTAPI __cudaRegisterFatBinary( void *fatCubin ) symbol_table *symtab; const char *ptx = info->ptx[selected_capability].ptx; if(context->get_device()->get_gpgpu()->get_config().convert_to_ptxplus() ) { - if (info->cubin[selected_capability].cubin ==NULL) { - printf("GPGPU-Sim PTX: Cannot convert to ptxplus no cubin found, probably because it was compiled using newer version of cuda (>=3.0)\nGPGPU-Sim PTX: Exiting ...\n"); - exit(1); - } - char *ptxplus_str = gpgpu_ptx_sim_convert_ptx_to_ptxplus(ptx, info->cubin[selected_capability].cubin, source_num++, - context->get_device()->get_gpgpu()->get_config().saved_converted_ptxplus(), false); - symtab=gpgpu_ptx_sim_load_ptx_from_string(ptxplus_str,source_num); - context->add_binary(symtab,fat_cubin_handle); - gpgpu_ptxinfo_load_from_string(ptx,source_num); - delete[] ptxplus_str; + printf("GPGPU-Sim PTX: ERROR ** PTXPlus is only supported through cuobjdump\n" + "\tEither enable cuobjdump or disable PTXPlus in your configuration file\n"); + exit(1); } else { symtab=gpgpu_ptx_sim_load_ptx_from_string(ptx,source_num); context->add_binary(symtab,fat_cubin_handle); diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc index 0c34c99..2879251 100644 --- a/src/cuda-sim/ptx_loader.cc +++ b/src/cuda-sim/ptx_loader.cc @@ -90,157 +90,11 @@ void print_ptx_file( const char *p, unsigned source_num, const char *filename ) fflush(stdout); } -char* gpgpu_ptx_sim_convert_ptx_to_ptxplus(const char *ptx_str, const char *cubin_str, unsigned source_num, bool save_converted, bool cuobjdump) -{ - - printf("GPGPU-Sim PTX: converting EMBEDDED .ptx file to ptxplus \n"); - - // Extract ptx to a file - char fname_ptx[1024]; - snprintf(fname_ptx,1024,"_ptx_XXXXXX"); - int fd=mkstemp(fname_ptx); - close(fd); - - printf("GPGPU-Sim PTX: extracting embedded .ptx to temporary file \"%s\"\n", fname_ptx); - FILE *ptxfile = fopen(fname_ptx,"w"); - fprintf(ptxfile,"%s",ptx_str); - fclose(ptxfile); - - char fname_ptxplus[1024]; - snprintf(fname_ptxplus,1024,"_ptxplus_XXXXXX"); - int fd4=mkstemp(fname_ptxplus); - close(fd4); - - // Extract cubin to a file - char fname_decuda[1024]; - char fname_cubin[1024]; - if( !cuobjdump){ - - snprintf(fname_cubin,1024,"_cubin_XXXXXX"); - int fd2=mkstemp(fname_cubin); - close(fd2); - - printf("GPGPU-Sim PTX: extracting embedded cubin to temporary file \"%s\"\n", fname_cubin); - FILE *cubinfile = fopen(fname_cubin,"w"); - fprintf(cubinfile,"%s",cubin_str); - fclose(cubinfile); - - - snprintf(fname_decuda,1024,"_decuda_XXXXXX"); - int fd3=mkstemp(fname_decuda); - close(fd3); - - // Run decuda - char decuda_commandline[1024]; - snprintf(decuda_commandline,1024,"$DECUDA_INSTALL_PATH/decuda.py -o %s %s", fname_decuda, fname_cubin); - printf("GPGPU-Sim PTX: calling decuda on cubin file, decuda output file = \"%s\"\n", fname_decuda); - int decuda_result = system(decuda_commandline); - if( decuda_result != 0 ) { - printf("GPGPU-Sim PTX: ERROR ** while calling decuda (b) %d\n", decuda_result); - printf(" Ensure env variable DECUDA_INSTALL_PATH is set and points to decuda base directory.\n"); - exit(1); - } - // Run decuda_to_ptxplus - char d2pp_commandline[1024]; - snprintf(d2pp_commandline,1024,"$D2PP_INSTALL_PATH/decuda_to_ptxplus %s %s %s %s > /dev/null", fname_decuda, fname_ptx, fname_cubin, fname_ptxplus); - printf("GPGPU-Sim PTX: calling decuda_to_ptxplus, ptxplus output file = \"%s\"\n", fname_ptxplus); - int d2pp_result = system(d2pp_commandline); - if( d2pp_result != 0 ) { - printf("GPGPU-Sim PTX: ERROR ** while calling decuda_to_ptxplus %d\n", d2pp_result); - printf(" Ensure env variable D2PP_INSTALL_PATH is set and points to decuda_to_ptxplus base directory.\n"); - exit(1); - } - } - else { - // Run cuobjdump_to_ptxplus - char commandline[1024]; - int result; - snprintf(commandline, 1024, "$GPGPUSIM_ROOT/cuobjdump_to_ptxplus/cuobjdump_to_ptxplus /proc/%d/exe %s", getpid(), fname_ptxplus); - fflush(stdout); - printf("GPGPU-Sim PTX: calling cuobjdump_to_ptxplus on exe file, output file = \"%s\"\n", fname_ptxplus); - result = system(commandline); - if(result){printf("GPGPU-Sim PTX: ERROR ** could not execute %s\n", commandline); exit(1);} - } - - // Get ptxplus from file - std::ifstream fileStream(fname_ptxplus, std::ios::in); - std::string text, line; - while(getline(fileStream,line)) { - text += (line + "\n"); - } - fileStream.close(); - - char* ptxplus_str = new char [strlen(text.c_str())+1]; - strcpy(ptxplus_str, text.c_str()); - - // Save ptxplus to file if specified - if(save_converted) { - char fname_ptxplus_save[1024]; - snprintf(fname_ptxplus_save,1024,"_%u.ptxplus", source_num ); - printf("GPGPU-Sim PTX: saving converted ptxplus to file \"%s\"\n", fname_ptxplus_save); - - FILE *file_ptxplus_save = fopen(fname_ptxplus_save,"w"); - fprintf(file_ptxplus_save,"%s",ptxplus_str); - fclose(file_ptxplus_save); - } - - // Remove temporary files - char rm_commandline[1024]; - if (!cuobjdump) { - snprintf(rm_commandline,1024,"rm -f %s %s %s %s", fname_ptx, fname_cubin, fname_decuda, fname_ptxplus); - } - else { - snprintf(rm_commandline,1024,"rm -f %s %s", fname_ptx, fname_ptxplus); - } - printf("GPGPU-Sim PTX: removing temporary files using \"%s\"\n", rm_commandline); - int rm_result = system(rm_commandline); - if( rm_result != 0 ) { - printf("GPGPU-Sim PTX: ERROR ** while removing temporary files %d\n", rm_result); - exit(1); - } - - printf("GPGPU-Sim PTX: DONE converting EMBEDDED .ptx file to ptxplus \n"); - - return ptxplus_str; -} - char* gpgpu_ptx_sim_convert_ptx_and_sass_to_ptxplus(const char *ptxfilename, const char *elffilename, const char *sassfilename) { printf("GPGPU-Sim PTX: converting EMBEDDED .ptx file to ptxplus \n"); -/* - // Extract ptx to a file - char fname_ptx[1024]; - snprintf(fname_ptx,1024,"_ptx_XXXXXX"); - int fd1=mkstemp(fname_ptx); - close(fd1); - - printf("GPGPU-Sim PTX: extracting embedded .ptx to temporary file \"%s\"\n", fname_ptx); - FILE *ptxfile = fopen(fname_ptx,"w"); - fprintf(ptxfile,"%s",ptx_str); - fclose(ptxfile); - - char fname_sass[1024]; - snprintf(fname_sass,1024,"_sass_XXXXXX"); - int fd2=mkstemp(fname_sass); - close(fd2); - - printf("GPGPU-Sim PTX: extracting .sass to temporary file \"%s\"\n", fname_sass); - FILE *sassfile = fopen(fname_sass,"w"); - fprintf(sassfile,"%s",sass_str); - fclose(sassfile); - - char fname_elf[1024]; - snprintf(fname_elf,1024,"_elf_XXXXXX"); - int fd3=mkstemp(fname_elf); - close(fd3); - - printf("GPGPU-Sim PTX: extracting .elf to temporary file \"%s\"\n", fname_elf); - FILE *elffile = fopen(fname_elf,"w"); - fprintf(elffile,"%s",elf_str); - fclose(elffile); -*/ char fname_ptxplus[1024]; snprintf(fname_ptxplus,1024,"_ptxplus_XXXXXX"); int fd4=mkstemp(fname_ptxplus); @@ -250,7 +104,6 @@ char* gpgpu_ptx_sim_convert_ptx_and_sass_to_ptxplus(const char *ptxfilename, con char fname_decuda[1024]; char fname_cubin[1024]; - // Run cuobjdump_to_ptxplus char commandline[1024]; int result; @@ -273,6 +126,7 @@ char* gpgpu_ptx_sim_convert_ptx_and_sass_to_ptxplus(const char *ptxfilename, con strcpy(ptxplus_str, text.c_str()); // Remove temporary files + // TODO: Fix deleting/keeping PTXPlus files /* char rm_commandline[1024]; diff --git a/src/cuda-sim/ptx_loader.h b/src/cuda-sim/ptx_loader.h index aa98a91..9227d85 100644 --- a/src/cuda-sim/ptx_loader.h +++ b/src/cuda-sim/ptx_loader.h @@ -32,7 +32,6 @@ 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 ); -char* gpgpu_ptx_sim_convert_ptx_to_ptxplus(const char *ptx_str, const char *cubin_str, unsigned source_num, bool save_converted, bool cuobjdump ); char* gpgpu_ptx_sim_convert_ptx_and_sass_to_ptxplus(const char *ptx_str, const char *sass_str, const char *elf_str); #endif |
