summaryrefslogtreecommitdiff
path: root/libcuda
diff options
context:
space:
mode:
authorAndrew M. B. Boktor <[email protected]>2012-05-04 09:51:53 -0800
committerAndrew Boktor <[email protected]>2014-08-14 13:19:37 -0700
commit05f02e48963660d60120aca2f0198e0723e257d5 (patch)
treeca3a86afb038eb3d6bcaaee15a0fa587e19b881d /libcuda
parent2893b0694e028d62e7b0849024b620a50a409de0 (diff)
Supporting the option for removing temporary files
. the option -gpgpu_ptx_save_converted_ptxplus allows keeping the ptxplus file . the option -gpgpu_keep allows keeping intermediate files used to communicate with other programs (e.g. cuobjdump) [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 12304]
Diffstat (limited to 'libcuda')
-rw-r--r--libcuda/cuda_runtime_api.cc39
1 files changed, 29 insertions, 10 deletions
diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc
index e9744d0..85664a7 100644
--- a/libcuda/cuda_runtime_api.cc
+++ b/libcuda/cuda_runtime_api.cc
@@ -1159,10 +1159,15 @@ extern "C" FILE *cuobjdump_in;
/*!
* This Function extract the whole PTX (for all the files) using cuobjdump
* */
-void extract_ptx(){
+void extract_code_using_cuobjdump(){
char command[1000];
+
+ char fname[1024];
+ snprintf(fname,1024,"_cuobjdump_complete_output_XXXXXX");
+ int fd=mkstemp(fname);
+ close(fd);
+
char* whole_code;
- char fname[1024]="_ptx_whole_code_WESWW";
//! Running CUobjdump using dynamic link to current process
snprintf(command,1000,"$CUDA_INSTALL_PATH/bin/cuobjdump -ptx -elf -sass /proc/%d/exe > %s",getpid(),fname);
printf("Running cuobjdump using \"%s\"\n", command);
@@ -1177,10 +1182,10 @@ void extract_ptx(){
printf("Done parsing!!!\n");
}
-//! Return proper ptx version
+//! Find the proper sm version to be used
/*!
- * This function return newest ptx version inside the argument
- * which is is not newer than forced_max_capability
+ * The function finds the highest sm version lower than the option
+ * force_max_capability
*/
unsigned get_best_version(std::list<cuobjdumpSection> sectionlist, CUctx_st *context){
@@ -1209,9 +1214,10 @@ unsigned get_best_version(std::list<cuobjdumpSection> sectionlist, CUctx_st *con
return max_capability;
}
+//! Find number of files with a certain sm version
/*!
- * Return number of diffrent ptx files generated in first argument
- * which have sm version equal to selected_capability
+ * Once the sm verison to be used is known (using get_best_version), this
+ * function counts the number of files that use this sm version
*/
unsigned get_number_of_ptx(std::list<cuobjdumpSection> sectionlist, unsigned selected_capability){
int result = 0;
@@ -1275,7 +1281,7 @@ void useCuobjdump() {
CUctx_st *context = GPGPUSim_Context();
unsigned source_num=1;
char *sass, *elf;
- extract_ptx(); //extract all the output of cuobjdump to _cuobjdump_*.*
+ extract_code_using_cuobjdump(); //extract all the output of cuobjdump to _cuobjdump_*.*
unsigned selected_capability = get_best_version(cuobjdump, context); //Find max capability less than forced_max_capability
unsigned total_ptx_files = get_number_of_ptx(cuobjdump,selected_capability); //Count ptx files for the given capability
@@ -1311,6 +1317,19 @@ void useCuobjdump() {
load_constants(symtab,STATIC_ALLOC_LIMIT,context->get_device()->get_gpgpu());
}
}
+ if(!keep_intermediate_files()){
+ char rm_commandline[1024];
+
+ snprintf(rm_commandline,1024,"rm -f _cuobjdump_*");
+
+ 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);
+ }
+ }
+
}
void** CUDARTAPI __cudaRegisterFatBinary( void *fatCubin )
@@ -1326,8 +1345,8 @@ void** CUDARTAPI __cudaRegisterFatBinary( void *fatCubin )
next_fat_bin_handle++;
printf("GPGPU-Sim PTX: __cudaRegisterFatBinary, fat_cubin_handle = %u\n", fat_cubin_handle);
/*!
- * This function extracting all data from all files in first call
- * then for next calls, only return the appropriate number
+ * This function extracts all data from all files in first call
+ * then for next calls, only returns the appropriate number
*/
assert(fat_cubin_handle >= 1);
if(fat_cubin_handle == 1)