diff options
| author | Tim Rogers <[email protected]> | 2025-02-18 10:29:07 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-02-18 15:29:07 +0000 |
| commit | 287fe0aa17ec1ac5bdd595ca6e89aa97464bcac7 (patch) | |
| tree | cf52817b95b99f61cf494af5536e32bf6d2889e3 /src/cuda-sim | |
| parent | 7934dfea8a6f44f592866414189970ef9ff994d6 (diff) | |
A bunch of maintenance fixes, the largest of which is getting the PTX simulation to work with CUDA 12. (#95)
* Fixing the formatter to always use a consistent format and running it on the codebase
* Update linux-so-version.txt
* Update Makefile
* A couple of unnecessary files that are lingering around
* Support CUDA 12
* Getting the PTX simulations to work with CUDA 12. The issue is that ptxas added more information (number of barriers and compile time). We have to parse these or lexx/yacc fail.
* Update ptxinfo.l
debug MACRO was ineffective
* Update gpgpusim_check.cmake
Update to make the CUDA version print a warning, not an error and updating the print to be more reflective of what the actual problem is.
Diffstat (limited to 'src/cuda-sim')
| -rw-r--r-- | src/cuda-sim/cuda-sim.cc | 6 | ||||
| -rw-r--r-- | src/cuda-sim/cuda-sim.h | 4 | ||||
| -rw-r--r-- | src/cuda-sim/half.h | 27 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_ir.h | 2 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_sim.h | 4 | ||||
| -rw-r--r-- | src/cuda-sim/ptxinfo.l | 5 | ||||
| -rw-r--r-- | src/cuda-sim/ptxinfo.y | 7 |
7 files changed, 28 insertions, 27 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc index d05549c..69d1eb7 100644 --- a/src/cuda-sim/cuda-sim.cc +++ b/src/cuda-sim/cuda-sim.cc @@ -2782,9 +2782,7 @@ void print_ptxinfo() { } } -struct gpgpu_ptx_sim_info get_ptxinfo() { - return g_ptxinfo; -} +struct gpgpu_ptx_sim_info get_ptxinfo() { return g_ptxinfo; } std::map<unsigned, const char *> get_duplicate() { return g_duplicate; } @@ -2801,6 +2799,8 @@ void ptxinfo_function(const char *fname) { void ptxinfo_regs(unsigned nregs) { g_ptxinfo.regs = nregs; } +void ptxinfo_barriers(unsigned barriers) { g_ptxinfo.barriers = barriers; } + void ptxinfo_lmem(unsigned declared, unsigned system) { g_ptxinfo.lmem = declared + system; } diff --git a/src/cuda-sim/cuda-sim.h b/src/cuda-sim/cuda-sim.h index 21e1ca0..b1caf0c 100644 --- a/src/cuda-sim/cuda-sim.h +++ b/src/cuda-sim/cuda-sim.h @@ -101,8 +101,8 @@ class functionalCoreSim : public core_t { bool *m_warpAtBarrier; }; -#define RECONVERGE_RETURN_PC ((address_type)-2) -#define NO_BRANCH_DIVERGENCE ((address_type)-1) +#define RECONVERGE_RETURN_PC ((address_type) - 2) +#define NO_BRANCH_DIVERGENCE ((address_type) - 1) address_type get_return_pc(void *thd); const char *get_ptxinfo_kname(); void print_ptxinfo(); diff --git a/src/cuda-sim/half.h b/src/cuda-sim/half.h index fab1a22..67e607b 100644 --- a/src/cuda-sim/half.h +++ b/src/cuda-sim/half.h @@ -846,10 +846,8 @@ uint16 int2half_impl(T value) { bits |= 0x7BFF + (R != std::round_toward_zero);
} else if (value) {
unsigned int m = value, exp = 24;
- for (; m < 0x400; m <<= 1, --exp)
- ;
- for (; m > 0x7FF; m >>= 1, ++exp)
- ;
+ for (; m < 0x400; m <<= 1, --exp);
+ for (; m > 0x7FF; m >>= 1, ++exp);
bits |= (exp << 10) + m;
if (exp > 24) {
if (R == std::round_to_nearest)
@@ -1274,8 +1272,7 @@ inline double half2float_impl(uint16 value, double, true_type) { int abs = value & 0x7FFF;
if (abs) {
hi |= 0x3F000000 << static_cast<unsigned>(abs >= 0x7C00);
- for (; abs < 0x400; abs <<= 1, hi -= 0x100000)
- ;
+ for (; abs < 0x400; abs <<= 1, hi -= 0x100000);
hi += static_cast<uint32>(abs) << 10;
}
uint64 bits = static_cast<uint64>(hi) << 32;
@@ -2116,8 +2113,7 @@ struct functions { static half frexp(half arg, int *exp) {
int m = arg.data_ & 0x7FFF, e = -14;
if (m >= 0x7C00 || !m) return *exp = 0, arg;
- for (; m < 0x400; m <<= 1, --e)
- ;
+ for (; m < 0x400; m <<= 1, --e);
return *exp = e + (m >> 10),
half(binary, (arg.data_ & 0x8000) | 0x3800 | (m & 0x3FF));
}
@@ -2135,8 +2131,7 @@ struct functions { unsigned int mask = (1 << (25 - e)) - 1, m = arg.data_ & mask;
iptr->data_ = arg.data_ & ~mask;
if (!m) return half(binary, arg.data_ & 0x8000);
- for (; m < 0x400; m <<= 1, --e)
- ;
+ for (; m < 0x400; m <<= 1, --e);
return half(binary, static_cast<uint16>((arg.data_ & 0x8000) | (e << 10) |
(m & 0x3FF)));
}
@@ -2148,8 +2143,7 @@ struct functions { static half scalbln(half arg, long exp) {
unsigned int m = arg.data_ & 0x7FFF;
if (m >= 0x7C00 || !m) return arg;
- for (; m < 0x400; m <<= 1, --exp)
- ;
+ for (; m < 0x400; m <<= 1, --exp);
exp += m >> 10;
uint16 value = arg.data_ & 0x8000;
if (exp > 30) {
@@ -2191,8 +2185,7 @@ struct functions { if (abs < 0x7C00) {
int exp = (abs >> 10) - 15;
if (abs < 0x400)
- for (; abs < 0x200; abs <<= 1, --exp)
- ;
+ for (; abs < 0x200; abs <<= 1, --exp);
return exp;
}
if (abs > 0x7C00) return FP_ILOGBNAN;
@@ -2208,13 +2201,11 @@ struct functions { if (abs < 0x7C00) {
int exp = (abs >> 10) - 15;
if (abs < 0x400)
- for (; abs < 0x200; abs <<= 1, --exp)
- ;
+ for (; abs < 0x200; abs <<= 1, --exp);
uint16 bits = (exp < 0) << 15;
if (exp) {
unsigned int m = std::abs(exp) << 6, e = 18;
- for (; m < 0x400; m <<= 1, --e)
- ;
+ for (; m < 0x400; m <<= 1, --e);
bits |= (e << 10) + m;
}
return half(binary, bits);
diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h index b08a692..4a7d39b 100644 --- a/src/cuda-sim/ptx_ir.h +++ b/src/cuda-sim/ptx_ir.h @@ -39,7 +39,7 @@ #include <string> #include <vector> -//#include "ptx.tab.h" +// #include "ptx.tab.h" #include "ptx_sim.h" #include "memory.h" diff --git a/src/cuda-sim/ptx_sim.h b/src/cuda-sim/ptx_sim.h index 8eec922..7128f8e 100644 --- a/src/cuda-sim/ptx_sim.h +++ b/src/cuda-sim/ptx_sim.h @@ -340,9 +340,7 @@ class ptx_thread_info { dim3 get_ctaid() const { return m_ctaid; } dim3 get_tid() const { return m_tid; } dim3 get_ntid() const { return m_ntid; } - class gpgpu_sim *get_gpu() { - return (gpgpu_sim *)m_gpu; - } + class gpgpu_sim *get_gpu() { return (gpgpu_sim *)m_gpu; } unsigned get_hw_tid() const { return m_hw_tid; } unsigned get_hw_ctaid() const { return m_hw_ctaid; } unsigned get_hw_wid() const { return m_hw_wid; } diff --git a/src/cuda-sim/ptxinfo.l b/src/cuda-sim/ptxinfo.l index 51371e3..db81bca 100644 --- a/src/cuda-sim/ptxinfo.l +++ b/src/cuda-sim/ptxinfo.l @@ -58,6 +58,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. "Compiling entry function" TC; return FUNC; "Used" TC; return USED; "registers" TC; return REGS; +"used" TC; return USED; +"barriers" TC; return REGS; "bytes" TC; return BYTES; "lmem" TC; return LMEM; "smem" TC; return SMEM; @@ -65,11 +67,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. "gmem" TC; return GMEM; "line" TC; return LINE; "for" TC; return FOR; +"ms" TC; return MS; "textures" TC; return TEXTURES; "error : Duplicate definition of" TC; return DUPLICATE; "function" TC; yylval->string_value = strdup(yytext); return FUNCTION; "variable" TC; yylval->string_value = strdup(yytext); return VARIABLE; "fatal : Ptx assembly aborted due to errors" TC; return FATAL; +"Compile time = " TC; return COMPILETIME; [_A-Za-z$%][_0-9A-Za-z$]* TC; yylval->string_value = strdup(yytext); return IDENTIFIER; [-]{0,1}[0-9]+ TC; yylval->int_value = atoi(yytext); return INT_OPERAND; @@ -79,6 +83,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. "[" TC; return LEFT_SQUARE_BRACKET; "]" TC; return RIGHT_SQUARE_BRACKET; ":" TC; return COLON; +"." TC; return PERIOD; ";" TC; return SEMICOLON; "'" TC; return QUOTE; " " TC; diff --git a/src/cuda-sim/ptxinfo.y b/src/cuda-sim/ptxinfo.y index b303958..7225207 100644 --- a/src/cuda-sim/ptxinfo.y +++ b/src/cuda-sim/ptxinfo.y @@ -49,6 +49,8 @@ typedef void * yyscan_t; %token FUNC %token USED %token REGS +%token BARRIERS +%token COMPILETIME %token BYTES %token LMEM %token SMEM @@ -70,6 +72,8 @@ typedef void * yyscan_t; %token <string_value> FUNCTION %token <string_value> VARIABLE %token FATAL +%token PERIOD +%token MS %{ #include <stdlib.h> @@ -81,6 +85,7 @@ typedef void * yyscan_t; void yyerror(yyscan_t yyscanner, ptxinfo_data* ptxinfo, const char* msg); void ptxinfo_function(const char *fname ); void ptxinfo_regs( unsigned nregs ); + void ptxinfo_barriers( unsigned barriers ); void ptxinfo_lmem( unsigned declared, unsigned system ); void ptxinfo_gmem( unsigned declared, unsigned system ); void ptxinfo_smem( unsigned declared, unsigned system ); @@ -126,8 +131,10 @@ info: USED INT_OPERAND REGS { ptxinfo_regs($2); } | INT_OPERAND BYTES LMEM { ptxinfo_lmem($1,0); } | INT_OPERAND BYTES SMEM { ptxinfo_smem($1,0); } | INT_OPERAND BYTES CMEM { ptxinfo_cmem($1,0); } + | USED INT_OPERAND BARRIERS { ptxinfo_barriers($2); } | INT_OPERAND REGS { ptxinfo_regs($1); } | INT_OPERAND TEXTURES {} + | COMPILETIME INT_OPERAND PERIOD INT_OPERAND MS {} ; tuple: INT_OPERAND PLUS INT_OPERAND BYTES { g_declared=$1; g_system=$3; } |
