summaryrefslogtreecommitdiff
path: root/src/cuda-sim
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuda-sim')
-rw-r--r--src/cuda-sim/cuda-math.h23
-rw-r--r--src/cuda-sim/cuda-sim.cc12
-rw-r--r--src/cuda-sim/ptxinfo.l12
-rw-r--r--src/cuda-sim/ptxinfo.y2
4 files changed, 29 insertions, 20 deletions
diff --git a/src/cuda-sim/cuda-math.h b/src/cuda-sim/cuda-math.h
index ea7f5fd..5abf4f3 100644
--- a/src/cuda-sim/cuda-math.h
+++ b/src/cuda-sim/cuda-math.h
@@ -47,7 +47,6 @@ namespace cuda_math {
#define __attribute__(a) // to remove warnings inside math_functions.h
#undef INT_MAX
-#if CUDART_VERSION < 3000
// DEVICE_BUILTIN
struct int4 {
int x, y, z, w;
@@ -70,27 +69,21 @@ namespace cuda_math {
typedef struct float2 float2;
extern float rsqrtf(float); // CUDA 2.3 beta
-#else
-#define UINT_MAX ((unsigned int)-1)
-#endif
+#if CUDART_VERSION < 3000
#define CUDA_FLOAT_MATH_FUNCTIONS
#include <device_types.h>
#define __CUDA_INTERNAL_COMPILATION__
-#if CUDART_VERSION >= 3000
-#define __CUDACC__
-#include <device_functions.h>
-#else
#include <math_functions.h>
-#endif
#undef __CUDA_INTERNAL_COMPILATION__
#undef __attribute__
-
-#if CUDART_VERSION >= 3000
-#define __internal_float2int float2int
-#define __internal_float2uint float2uint
-#include <math.h>
-#define __internal_accurate_fdividef fdividef
+#else
+#define CUDA_FLOAT_MATH_FUNCTIONS
+#include "/home/taamodt/nvcuda/2.3/cuda/include/device_types.h"
+#define __CUDA_INTERNAL_COMPILATION__
+#include "/home/taamodt/nvcuda/2.3/cuda/include/math_functions.h"
+#undef __CUDA_INTERNAL_COMPILATION__
+#undef __attribute__
#endif
}
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index d691a64..4480221 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -1617,6 +1617,7 @@ static FILE *open_ptxinfo (const char* ptx_filename)
struct ptx_info_t {
char *str;
+ char *fname;
ptx_info_t *next;
};
@@ -1624,11 +1625,12 @@ ptx_info_t *g_ptx_source_array = NULL;
unsigned g_used_embedded_ptx_files;
extern double g_ptx_version;
-void gpgpu_ptx_sim_add_ptxstring( const char *ptx_string )
+void gpgpu_ptx_sim_add_ptxstring( const char *ptx_string, const char *sourcefname )
{
ptx_info_t *t = new ptx_info_t;
t->next = NULL;
t->str = strdup(ptx_string);
+ t->fname = strdup(sourcefname);
// put ptx source into a fifo
if (g_ptx_source_array == NULL) {
@@ -1732,7 +1734,13 @@ void gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source_num )
char tempfile_ptxinfo[1024];
snprintf(tempfile_ptxinfo,1024,"%sinfo",fname);
char commandline[1024];
- snprintf(commandline,1024,"ptxas -v %s --output-file /dev/null 2> %s", fname2, tempfile_ptxinfo);
+ char extra_flags[1024];
+ extra_flags[0]=0;
+#if CUDART_VERSION >= 3000
+ snprintf(extra_flags,1024,"--gpu-name=sm_20");
+#endif
+ snprintf(commandline,1024,"ptxas %s -v %s --output-file /dev/null 2> %s",
+ extra_flags, fname2, tempfile_ptxinfo);
printf("GPGPU-Sim PTX: generating ptxinfo using \"%s\"\n", commandline);
result = system(commandline);
if( result != 0 ) {
diff --git a/src/cuda-sim/ptxinfo.l b/src/cuda-sim/ptxinfo.l
index 3a2ab52..bec382b 100644
--- a/src/cuda-sim/ptxinfo.l
+++ b/src/cuda-sim/ptxinfo.l
@@ -67,9 +67,13 @@
#include "ptxinfo.tab.h"
#include <string.h>
-char ptxinfo_linebuf[1024];
+#define LINEBUF_SIZE 1024
+char ptxinfo_linebuf[LINEBUF_SIZE];
unsigned ptxinfo_col = 0;
-#define TC ptxinfo_col+=strlen(ptxinfo_text);
+#define TC if( (ptxinfo_lineno == 1) && ((ptxinfo_col + strlen(ptxinfo_text)) < LINEBUF_SIZE) ) { \
+ strncpy(ptxinfo_linebuf+ptxinfo_col,ptxinfo_text,strlen(ptxinfo_text)); \
+ } \
+ ptxinfo_col+=strlen(ptxinfo_text);
%}
%%
@@ -85,6 +89,7 @@ unsigned ptxinfo_col = 0;
"smem" TC; return SMEM;
"cmem" TC; return CMEM;
"line" TC; return LINE;
+"for" TC; return FOR;
[_A-Za-z$%][_0-9A-Za-z$]* TC; ptxinfo_lval.string_value = strdup(yytext); return IDENTIFIER;
[-]{0,1}[0-9]+ TC; ptxinfo_lval.int_value = atoi(yytext); return INT_OPERAND;
@@ -112,8 +117,9 @@ int ptxinfo_error( const char *s )
int i;
g_ptxinfo_error_detected = 1;
fflush(stdout);
+ printf("GPGPU-Sim: ERROR while parsing output of ptxas (used to capture resource usage information)\n");
if( s != NULL )
- printf("ptxas -v %s (%s:%u) Syntax error:\n\n", g_filename, g_ptxinfo_filename, ptxinfo_lineno );
+ printf("GPGPU-Sim: %s (%s:%u) Syntax error:\n\n", g_filename, g_ptxinfo_filename, ptxinfo_lineno );
printf(" %s\n", ptxinfo_linebuf );
printf(" ");
for( i=0; i < ptxinfo_col-1; i++ ) {
diff --git a/src/cuda-sim/ptxinfo.y b/src/cuda-sim/ptxinfo.y
index c9c84b8..6d2f7a7 100644
--- a/src/cuda-sim/ptxinfo.y
+++ b/src/cuda-sim/ptxinfo.y
@@ -86,6 +86,7 @@
%token QUOTE
%token LINE
%token WARNING
+%token FOR
%{
#include <stdlib.h>
@@ -118,6 +119,7 @@ line_info: function_name
;
function_name: FUNC QUOTE IDENTIFIER QUOTE { ptxinfo_function($3); }
+ | FUNC QUOTE IDENTIFIER QUOTE FOR QUOTE IDENTIFIER QUOTE { ptxinfo_function($3); }
function_info: info
| function_info COMMA info