summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan <[email protected]>2018-06-05 17:22:35 -0700
committerJonathan <[email protected]>2018-06-05 17:22:35 -0700
commitb79708980b80b6e50b1612f5436655c724377779 (patch)
tree950ab3128ad9f43e655457afc69be60b38fb406a
parentf7b0d64c68f12d604e09aec8dbba569df354faf6 (diff)
ptx parse only
-rw-r--r--libcuda/cuda_runtime_api.cc48
-rw-r--r--src/cuda-sim/ptx_loader.cc37
-rw-r--r--src/cuda-sim/ptx_parser.cc5
3 files changed, 29 insertions, 61 deletions
diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc
index d03caf7..4efbd68 100644
--- a/libcuda/cuda_runtime_api.cc
+++ b/libcuda/cuda_runtime_api.cc
@@ -112,7 +112,6 @@
#include <regex>
#include <sstream>
#include <fstream>
-#include <queue>
#ifdef OPENGL_SUPPORT
#define GL_GLEXT_PROTOTYPES
#ifdef __APPLE__
@@ -149,7 +148,7 @@
std::map<void *,void **> pinned_memory; //support for pinned memories added
std::map<void *, size_t> pinned_memory_size;
int no_of_ptx=0;
-char ptx_list_file_name[1024];
+std::map<int, std::set<std::string> > version_filename;
std::map<int, std::string> fatbinmap;
std::map<int, bool>fatbin_registered;
std::map<std::string, symbol_table*> name_symtab;
@@ -1510,6 +1509,7 @@ void extract_ptx_files_using_cuobjdump(bool g_cdp_enabled){
char command[1000];
std::string app_binary = get_app_binary();
+ char ptx_list_file_name[1024];
snprintf(ptx_list_file_name,1024,"_cuobjdump_list_ptx_XXXXXX");
int fd2=mkstemp(ptx_list_file_name);
close(fd2);
@@ -1542,6 +1542,27 @@ void extract_ptx_files_using_cuobjdump(bool g_cdp_enabled){
printf("WARNING: Number of ptx in the executable file are 0. One of the reasons might be\n");
printf("\t1. CDP is enabled\n");
}
+
+ std::ifstream infile(ptx_list_file_name);
+ std::string line;
+ while (std::getline(infile, line))
+ {
+ //int pos = line.find(std::string(get_app_binary_name(app_binary)));
+ const char *ptx_file = line.c_str();
+ int pos1 = line.find("sm_");
+ int pos2 = line.find_last_of(".");
+ if (pos1==std::string::npos&&pos2==std::string::npos){
+ printf("ERROR: PTX list is not in correct format");
+ exit(0);
+ }
+ std::string vstr = line.substr(pos1+3,pos2-pos1-3);
+ int version = atoi(vstr.c_str());
+ if (version_filename.find(version)==version_filename.end()){
+ version_filename[version] = std::set<std::string>();
+ }
+ version_filename[version].insert(line);
+ }
+
}
void cuobjdumpParseBinary(unsigned int handle){
@@ -1557,28 +1578,6 @@ void cuobjdumpParseBinary(unsigned int handle){
return;
}
- std::map<int, std::set<std::string> > version_filename;
-
- std::ifstream infile(ptx_list_file_name);
- std::string line;
- while (std::getline(infile, line))
- {
- //int pos = line.find(std::string(get_app_binary_name(app_binary)));
- const char *ptx_file = line.c_str();
- int pos1 = line.find("sm_");
- int pos2 = line.find_last_of(".");
- if (pos1==std::string::npos&&pos2==std::string::npos){
- printf("ERROR: PTX list is not in correct format");
- exit(0);
- }
- std::string vstr = line.substr(pos1+3,pos2-pos1-3);
- int version = atoi(vstr.c_str());
- if (version_filename.find(version)==version_filename.end()){
- version_filename[version] = std::set<std::string>();
- }
- version_filename[version].insert(line);
- }
-
symbol_table *symtab;
//loops through all ptx files from smallest sm version to largest
std::map<int,std::set<std::string> >::iterator itr_m;
@@ -1671,7 +1670,6 @@ void extract_code_using_cuobjdump(){
int result=0;
#if (CUDART_VERSION >= 6000)
extract_ptx_files_using_cuobjdump(g_cdp_enabled);
- cuobjdumpParseBinary(1);
#endif
//TODO: redundant to dump twice. how can it be prevented?
//dump only for specific arch
diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc
index 0348af0..97d5773 100644
--- a/src/cuda-sim/ptx_loader.cc
+++ b/src/cuda-sim/ptx_loader.cc
@@ -152,39 +152,6 @@ char* gpgpu_ptx_sim_convert_ptx_and_sass_to_ptxplus(const std::string ptxfilenam
return ptxplus_str;
}
-
-symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source_num )
-{
- char buf[1024];
- snprintf(buf,1024,"_%u.ptx", source_num );
- if( g_save_embedded_ptx ) {
- FILE *fp = fopen(buf,"w");
- fprintf(fp,"%s",p);
- fclose(fp);
- }
- symbol_table *symtab=init_parser(buf);
- ptx__scan_string(p);
- int errors = ptx_parse ();
- if ( errors ) {
- char fname[1024];
- snprintf(fname,1024,"_ptx_errors_XXXXXX");
- int fd=mkstemp(fname);
- close(fd);
- printf("GPGPU-Sim PTX: parser error detected, exiting... but first extracting .ptx to \"%s\"\n", fname);
- FILE *ptxfile = fopen(fname,"w");
- fprintf(ptxfile,"%s", p );
- fclose(ptxfile);
- abort();
- exit(40);
- }
-
- if ( g_debug_execution >= 100 )
- print_ptx_file(p,source_num,buf);
-
- printf("GPGPU-Sim PTX: finished parsing EMBEDDED .ptx file %s\n",buf);
- return symtab;
-}
-
symbol_table *gpgpu_ptx_sim_load_ptx_from_filename( const char *filename )
{
symbol_table *symtab=init_parser(filename);
@@ -321,6 +288,10 @@ char* get_app_binary_name(){
return self_exe_path;
}
+void gpgpu_ptx_info_load_from_filename( const char *filename )
+{
+}
+
void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num, unsigned sm_version )
{
//do ptxas for individual files instead of one big embedded ptx. This prevents the duplicate defs and declarations.
diff --git a/src/cuda-sim/ptx_parser.cc b/src/cuda-sim/ptx_parser.cc
index 06ca870..c418fac 100644
--- a/src/cuda-sim/ptx_parser.cc
+++ b/src/cuda-sim/ptx_parser.cc
@@ -142,9 +142,7 @@ symbol_table *init_parser( const char *ptx_filename )
g_global_allfiles_symbol_table = new symbol_table("global_allfiles", 0, NULL);
g_global_symbol_table = g_current_symbol_table = g_global_allfiles_symbol_table;
}
-// else {
-// g_global_symbol_table = g_current_symbol_table = new symbol_table("global",0,g_global_allfiles_symbol_table);
-// }
+
ptx_lineno = 1;
#define DEF(X,Y) g_ptx_token_decode[X] = Y;
@@ -164,6 +162,7 @@ symbol_table *init_parser( const char *ptx_filename )
g_ptx_token_decode[global_space] = "global_space";
g_ptx_token_decode[generic_space] = "generic_space";
g_ptx_token_decode[instruction_space] = "instruction_space";
+
init_directive_state();
init_instruction_state();