diff options
| author | Mengchi Zhang <[email protected]> | 2019-05-23 22:44:37 -0400 |
|---|---|---|
| committer | Mengchi Zhang <[email protected]> | 2019-05-24 00:47:28 -0400 |
| commit | dc835911d5320008b2c227722a90240a8f6b0f3a (patch) | |
| tree | f3ab9f96fb1c50541709d7e5a6ce7d1305cc1b7d /src | |
| parent | 579047c1dd9fec1b69e7904aeb6a25553c8dbd69 (diff) | |
Fix linebuf for ptxinfo
Signed-off-by: Mengchi Zhang <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cuda-sim/ptx_loader.cc | 32 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_loader.h | 10 | ||||
| -rw-r--r-- | src/cuda-sim/ptxinfo.l | 19 | ||||
| -rw-r--r-- | src/cuda-sim/ptxinfo.y | 10 |
4 files changed, 42 insertions, 29 deletions
diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc index 7eb18ee..735ff84 100644 --- a/src/cuda-sim/ptx_loader.cc +++ b/src/cuda-sim/ptx_loader.cc @@ -58,7 +58,7 @@ const char *g_ptxinfo_filename; typedef void * yyscan_t; extern int ptxinfo_lex_init(yyscan_t* scanner); extern void ptxinfo_set_in (FILE * _in_str ,yyscan_t yyscanner ); -extern int ptxinfo_parse(yyscan_t scanner); +extern int ptxinfo_parse(yyscan_t scanner, ptxinfo_data* ptxinfo); extern int ptxinfo_lex_destroy(yyscan_t scanner); static bool g_save_embedded_ptx; @@ -359,11 +359,11 @@ void gpgpu_ptx_info_load_from_filename( const char *filename, unsigned sm_versio g_ptxinfo_filename = strdup(ptxas_filename.c_str()); FILE *ptxinfo_in; ptxinfo_in = fopen(g_ptxinfo_filename,"r"); - yyscan_t scanner; - ptxinfo_lex_init(&scanner); - ptxinfo_set_in(ptxinfo_in, scanner); - ptxinfo_parse(scanner); - ptxinfo_lex_destroy(scanner); + ptxinfo_data ptxinfo; + ptxinfo_lex_init(&(ptxinfo.scanner)); + ptxinfo_set_in(ptxinfo_in, ptxinfo.scanner); + ptxinfo_parse(ptxinfo.scanner, &ptxinfo); + ptxinfo_lex_destroy(ptxinfo.scanner); fclose(ptxinfo_in); } @@ -428,11 +428,11 @@ void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num FILE *ptxinfo_in; ptxinfo_in = fopen(tempfile_ptxinfo,"r"); g_ptxinfo_filename = tempfile_ptxinfo; - yyscan_t scanner; - ptxinfo_lex_init(&scanner); - ptxinfo_set_in(ptxinfo_in, scanner); - ptxinfo_parse(scanner); - ptxinfo_lex_destroy(scanner); + ptxinfo_data ptxinfo; + ptxinfo_lex_init(&(ptxinfo.scanner)); + ptxinfo_set_in(ptxinfo_in, ptxinfo.scanner); + ptxinfo_parse(ptxinfo.scanner, &ptxinfo); + ptxinfo_lex_destroy(ptxinfo.scanner); fclose(ptxinfo_in); fix_duplicate_errors(fname2); @@ -519,11 +519,11 @@ void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num FILE *ptxinfo_in; ptxinfo_in = fopen(g_ptxinfo_filename,"r"); - yyscan_t scanner; - ptxinfo_lex_init(&scanner); - ptxinfo_set_in(ptxinfo_in, scanner); - ptxinfo_parse(scanner); - ptxinfo_lex_destroy(scanner); + ptxinfo_data ptxinfo; + ptxinfo_lex_init(&(ptxinfo.scanner)); + ptxinfo_set_in(ptxinfo_in, ptxinfo.scanner); + ptxinfo_parse(ptxinfo.scanner, &ptxinfo); + ptxinfo_lex_destroy(ptxinfo.scanner); fclose(ptxinfo_in); snprintf(commandline,1024,"rm -f *info"); diff --git a/src/cuda-sim/ptx_loader.h b/src/cuda-sim/ptx_loader.h index e5df6a9..36e439e 100644 --- a/src/cuda-sim/ptx_loader.h +++ b/src/cuda-sim/ptx_loader.h @@ -29,6 +29,16 @@ #define PTX_LOADER_H_INCLUDED #include <string> +#define LINEBUF_SIZE 1024 +typedef void * yyscan_t; +class ptxinfo_data{ + public: + yyscan_t scanner; + char linebuf[LINEBUF_SIZE]; + unsigned col; +}; + + extern bool g_override_embedded_ptx; extern int no_of_ptx; //counter to track number of ptx files to be extracted in an application. diff --git a/src/cuda-sim/ptxinfo.l b/src/cuda-sim/ptxinfo.l index a190e6d..92f7a30 100644 --- a/src/cuda-sim/ptxinfo.l +++ b/src/cuda-sim/ptxinfo.l @@ -36,14 +36,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %option reentrant %{ +#include "ptx_loader.h" #include "ptxinfo.tab.h" #include <string.h> #define LINEBUF_SIZE 1024 -#define TC if( (yylineno == 1) && (yylval->col + strlen(yytext) < LINEBUF_SIZE) ) { \ - strncpy(yylval->linebuf+yylval->col,yytext,strlen(yytext)); \ +#define TC if( (yylineno == 1) && (ptxinfo->col + strlen(yytext) < LINEBUF_SIZE) ) { \ + strncpy(ptxinfo->linebuf+ptxinfo->col,yytext,strlen(yytext)); \ } \ - yylval->col+=strlen(yytext); + ptxinfo->col+=strlen(yytext); +#define YY_DECL int ptxinfo_lex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner, ptxinfo_data* ptxinfo) %} %% @@ -80,7 +83,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. " " TC; "\t" TC; -\n.* yylval->col=0; strncpy(yylval->linebuf, yytext + 1, 1024); yyless( 1 ); +\n.* ptxinfo->col=0; strncpy(ptxinfo->linebuf, yytext + 1, 1024); yyless( 1 ); %% @@ -88,7 +91,7 @@ extern int g_ptxinfo_error_detected; extern const char *g_filename; extern const char *g_ptxinfo_filename; -int ptxinfo_error(yyscan_t yyscanner, const char* msg) +int ptxinfo_error(yyscan_t yyscanner, ptxinfo_data* ptxinfo, const char* msg) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; int i; @@ -97,10 +100,10 @@ int ptxinfo_error(yyscan_t yyscanner, const char* msg) printf("GPGPU-Sim: ERROR while parsing output of ptxas (used to capture resource usage information)\n"); if( msg != NULL ) printf("GPGPU-Sim: %s (%s:%u) Syntax error:\n\n", g_filename, g_ptxinfo_filename, yylineno ); - printf(" %s\n", yylval->linebuf ); + printf(" %s\n", ptxinfo->linebuf ); printf(" "); - for( i=0; i < yylval->col-1; i++ ) { - if( yylval->linebuf[i] == '\t' ) printf("\t"); + for( i=0; i < ptxinfo->col-1; i++ ) { + if( ptxinfo->linebuf[i] == '\t' ) printf("\t"); else printf(" "); } diff --git a/src/cuda-sim/ptxinfo.y b/src/cuda-sim/ptxinfo.y index eed304c..00c81e0 100644 --- a/src/cuda-sim/ptxinfo.y +++ b/src/cuda-sim/ptxinfo.y @@ -29,18 +29,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %{ typedef void * yyscan_t; +class ptxinfo_data; %} %define api.pure full %parse-param {yyscan_t scanner} +%parse-param {ptxinfo_data* ptxinfo} %lex-param {yyscan_t scanner} +%lex-param {ptxinfo_data* ptxinfo} %union { -#define LINEBUF_SIZE 1024 int int_value; char * string_value; - char linebuf[LINEBUF_SIZE]; - unsigned col; } %token <int_value> INT_OPERAND @@ -77,8 +77,8 @@ typedef void * yyscan_t; static unsigned g_declared; static unsigned g_system; - int ptxinfo_lex(YYSTYPE * yylval_param, yyscan_t yyscanner); - void yyerror(yyscan_t yyscanner, const char* msg); + int ptxinfo_lex(YYSTYPE * yylval_param, yyscan_t yyscanner, ptxinfo_data* ptxinfo); + void yyerror(yyscan_t yyscanner, ptxinfo_data* ptxinfo, const char* msg); void ptxinfo_addinfo(); void ptxinfo_function(const char *fname ); void ptxinfo_regs( unsigned nregs ); |
