summaryrefslogtreecommitdiff
path: root/src/cuda-sim
diff options
context:
space:
mode:
authorAaron Barnes <[email protected]>2024-07-16 12:33:16 -0600
committerGitHub <[email protected]>2024-07-16 18:33:16 +0000
commite1afc53b51d24afcfd8b8aab15e4ba5d99b4a772 (patch)
treeffd07cc1a81884761c5b16089b3fc5937cb58b1d /src/cuda-sim
parent55419d7098a433122bf4d940cf38af17e33f045a (diff)
Auto clang format (#74)
* add automated clang formatter * Automated clang-format * use /bin/bash and add print * use default checkout ref * Format only after tests are success * Run CI on merge group --------- Co-authored-by: barnes88 <[email protected]> Co-authored-by: JRPAN <[email protected]>
Diffstat (limited to 'src/cuda-sim')
-rw-r--r--src/cuda-sim/cuda-sim.cc251
-rw-r--r--src/cuda-sim/instructions.cc15
-rw-r--r--src/cuda-sim/ptx_ir.cc15
-rw-r--r--src/cuda-sim/ptx_ir.h2
-rw-r--r--src/cuda-sim/ptx_sim.cc3
5 files changed, 146 insertions, 140 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index 888cf77..833d33f 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -1,18 +1,19 @@
// Copyright (c) 2009-2021, Tor M. Aamodt, Ali Bakhoda, Wilson W.L. Fung,
-// George L. Yuan, Jimmy Kwa, Vijay Kandiah, Nikos Hardavellas,
+// George L. Yuan, Jimmy Kwa, Vijay Kandiah, Nikos Hardavellas,
// Mahmoud Khairy, Junrui Pan, Timothy G. Rogers
-// The University of British Columbia, Northwestern University, Purdue University
-// All rights reserved.
+// The University of British Columbia, Northwestern University, Purdue
+// University All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
-// 1. Redistributions of source code must retain the above copyright notice, this
+// 1. Redistributions of source code must retain the above copyright notice,
+// this
// list of conditions and the following disclaimer;
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution;
-// 3. Neither the names of The University of British Columbia, Northwestern
+// 3. Neither the names of The University of British Columbia, Northwestern
// University nor the names of their contributors may be used to
// endorse or promote products derived from this software without specific
// prior written permission.
@@ -591,118 +592,118 @@ void ptx_instruction::set_fp_or_int_archop() {
}
}
-void ptx_instruction::set_mul_div_or_other_archop(){
- sp_op=OTHER_OP;
- if((m_opcode != MEMBAR_OP) && (m_opcode != SSY_OP) && (m_opcode != BRA_OP) && (m_opcode != BAR_OP) && (m_opcode != EXIT_OP) && (m_opcode != NOP_OP) && (m_opcode != RETP_OP) && (m_opcode != RET_OP) && (m_opcode != CALLP_OP) && (m_opcode != CALL_OP)){
- if(get_type() == F64_TYPE || get_type() == FF64_TYPE){
- switch(get_opcode()){
- case MUL_OP:
- case MAD_OP:
- case FMA_OP:
- sp_op=DP_MUL_OP;
- break;
- case DIV_OP:
- case REM_OP:
- sp_op=DP_DIV_OP;
- break;
- case RCP_OP:
- sp_op=DP_DIV_OP;
- break;
- case LG2_OP:
- sp_op=FP_LG_OP;
- break;
- case RSQRT_OP:
- case SQRT_OP:
- sp_op=FP_SQRT_OP;
- break;
- case SIN_OP:
- case COS_OP:
- sp_op=FP_SIN_OP;
- break;
- case EX2_OP:
- sp_op=FP_EXP_OP;
- break;
- case MMA_OP:
- sp_op=TENSOR__OP;
- break;
- case TEX_OP:
- sp_op=TEX__OP;
- break;
- default:
- if((op==DP_OP) || (op==ALU_OP))
- sp_op=DP___OP;
- break;
- }
+void ptx_instruction::set_mul_div_or_other_archop() {
+ sp_op = OTHER_OP;
+ if ((m_opcode != MEMBAR_OP) && (m_opcode != SSY_OP) && (m_opcode != BRA_OP) &&
+ (m_opcode != BAR_OP) && (m_opcode != EXIT_OP) && (m_opcode != NOP_OP) &&
+ (m_opcode != RETP_OP) && (m_opcode != RET_OP) && (m_opcode != CALLP_OP) &&
+ (m_opcode != CALL_OP)) {
+ if (get_type() == F64_TYPE || get_type() == FF64_TYPE) {
+ switch (get_opcode()) {
+ case MUL_OP:
+ case MAD_OP:
+ case FMA_OP:
+ sp_op = DP_MUL_OP;
+ break;
+ case DIV_OP:
+ case REM_OP:
+ sp_op = DP_DIV_OP;
+ break;
+ case RCP_OP:
+ sp_op = DP_DIV_OP;
+ break;
+ case LG2_OP:
+ sp_op = FP_LG_OP;
+ break;
+ case RSQRT_OP:
+ case SQRT_OP:
+ sp_op = FP_SQRT_OP;
+ break;
+ case SIN_OP:
+ case COS_OP:
+ sp_op = FP_SIN_OP;
+ break;
+ case EX2_OP:
+ sp_op = FP_EXP_OP;
+ break;
+ case MMA_OP:
+ sp_op = TENSOR__OP;
+ break;
+ case TEX_OP:
+ sp_op = TEX__OP;
+ break;
+ default:
+ if ((op == DP_OP) || (op == ALU_OP)) sp_op = DP___OP;
+ break;
}
- else if(get_type()==F16_TYPE || get_type()==F32_TYPE){
- switch(get_opcode()){
- case MUL_OP:
- case MAD_OP:
- case FMA_OP:
- sp_op=FP_MUL_OP;
- break;
- case DIV_OP:
- case REM_OP:
- sp_op=FP_DIV_OP;
- break;
- case RCP_OP:
- sp_op=FP_DIV_OP;
- break;
- case LG2_OP:
- sp_op=FP_LG_OP;
- break;
- case RSQRT_OP:
- case SQRT_OP:
- sp_op=FP_SQRT_OP;
- break;
- case SIN_OP:
- case COS_OP:
- sp_op=FP_SIN_OP;
- break;
- case EX2_OP:
- sp_op=FP_EXP_OP;
- break;
- case MMA_OP:
- sp_op=TENSOR__OP;
- break;
- case TEX_OP:
- sp_op=TEX__OP;
- break;
- default:
- if((op==SP_OP) || (op==ALU_OP))
- sp_op=FP__OP;
- break;
- }
- }else {
- switch(get_opcode()){
- case MUL24_OP:
- case MAD24_OP:
- sp_op=INT_MUL24_OP;
- break;
- case MUL_OP:
- case MAD_OP:
- case FMA_OP:
- if(get_type()==U32_TYPE || get_type()==S32_TYPE || get_type()==B32_TYPE)
- sp_op=INT_MUL32_OP;
- else
- sp_op=INT_MUL_OP;
- break;
- case DIV_OP:
- case REM_OP:
- sp_op=INT_DIV_OP;
- break;
- case MMA_OP:
- sp_op=TENSOR__OP;
- break;
- case TEX_OP:
- sp_op=TEX__OP;
- break;
- default:
- if((op==INTP_OP) || (op==ALU_OP))
- sp_op=INT__OP;
- break;
- }
+ } else if (get_type() == F16_TYPE || get_type() == F32_TYPE) {
+ switch (get_opcode()) {
+ case MUL_OP:
+ case MAD_OP:
+ case FMA_OP:
+ sp_op = FP_MUL_OP;
+ break;
+ case DIV_OP:
+ case REM_OP:
+ sp_op = FP_DIV_OP;
+ break;
+ case RCP_OP:
+ sp_op = FP_DIV_OP;
+ break;
+ case LG2_OP:
+ sp_op = FP_LG_OP;
+ break;
+ case RSQRT_OP:
+ case SQRT_OP:
+ sp_op = FP_SQRT_OP;
+ break;
+ case SIN_OP:
+ case COS_OP:
+ sp_op = FP_SIN_OP;
+ break;
+ case EX2_OP:
+ sp_op = FP_EXP_OP;
+ break;
+ case MMA_OP:
+ sp_op = TENSOR__OP;
+ break;
+ case TEX_OP:
+ sp_op = TEX__OP;
+ break;
+ default:
+ if ((op == SP_OP) || (op == ALU_OP)) sp_op = FP__OP;
+ break;
}
+ } else {
+ switch (get_opcode()) {
+ case MUL24_OP:
+ case MAD24_OP:
+ sp_op = INT_MUL24_OP;
+ break;
+ case MUL_OP:
+ case MAD_OP:
+ case FMA_OP:
+ if (get_type() == U32_TYPE || get_type() == S32_TYPE ||
+ get_type() == B32_TYPE)
+ sp_op = INT_MUL32_OP;
+ else
+ sp_op = INT_MUL_OP;
+ break;
+ case DIV_OP:
+ case REM_OP:
+ sp_op = INT_DIV_OP;
+ break;
+ case MMA_OP:
+ sp_op = TENSOR__OP;
+ break;
+ case TEX_OP:
+ sp_op = TEX__OP;
+ break;
+ default:
+ if ((op == INTP_OP) || (op == ALU_OP)) sp_op = INT__OP;
+ break;
+ }
+ }
}
}
@@ -960,14 +961,16 @@ void ptx_instruction::set_opcode_and_latency() {
break;
}
break;
- case MUL24_OP: //MUL24 is performed on mul32 units (with additional instructions for bitmasking) on devices with compute capability >1.x
- latency = int_latency[2]+1;
- initiation_interval = int_init[2]+1;
+ case MUL24_OP: // MUL24 is performed on mul32 units (with additional
+ // instructions for bitmasking) on devices with compute
+ // capability >1.x
+ latency = int_latency[2] + 1;
+ initiation_interval = int_init[2] + 1;
op = INTP_OP;
break;
case MAD24_OP:
- latency = int_latency[3]+1;
- initiation_interval = int_init[3]+1;
+ latency = int_latency[3] + 1;
+ initiation_interval = int_init[3] + 1;
op = INTP_OP;
break;
case DIV_OP:
@@ -1533,10 +1536,10 @@ void function_info::ptx_jit_config(
filename_c.c_str());
assert(system(buff) != 0);
FILE *fp = fopen(filename_c.c_str(), "r");
- char * ptr = fgets(buff, 1024, fp);
- if(ptr == NULL ){
- printf("can't read file %s \n", filename_c.c_str());
- assert(0);
+ char *ptr = fgets(buff, 1024, fp);
+ if (ptr == NULL) {
+ printf("can't read file %s \n", filename_c.c_str());
+ assert(0);
}
fclose(fp);
std::string fn(buff);
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index 4981c99..4792efc 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -1,18 +1,19 @@
// Copyright (c) 2009-2021, Tor M. Aamodt, Wilson W.L. Fung, Ali Bakhoda,
// Jimmy Kwa, George L. Yuan, Vijay Kandiah, Nikos Hardavellas,
// Mahmoud Khairy, Junrui Pan, Timothy G. Rogers
-// The University of British Columbia, Northwestern University, Purdue University
-// All rights reserved.
+// The University of British Columbia, Northwestern University, Purdue
+// University All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
-// 1. Redistributions of source code must retain the above copyright notice, this
+// 1. Redistributions of source code must retain the above copyright notice,
+// this
// list of conditions and the following disclaimer;
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution;
-// 3. Neither the names of The University of British Columbia, Northwestern
+// 3. Neither the names of The University of British Columbia, Northwestern
// University nor the names of their contributors may be used to
// endorse or promote products derived from this software without specific
// prior written permission.
@@ -1948,7 +1949,7 @@ void mma_impl(const ptx_instruction *pI, core_t *core, warp_inst_t inst) {
hex_val = (v[k / 2].s64 & 0xffff);
else
hex_val = ((v[k / 2].s64 & 0xffff0000) >> 16);
- nw_v[k].f16 = *(reinterpret_cast<half*>(hex_val));
+ nw_v[k].f16 = *(reinterpret_cast<half *>(hex_val));
}
}
if (!((operand_num == 3) && (type2 == F32_TYPE))) {
@@ -3980,7 +3981,7 @@ void mad_def(const ptx_instruction *pI, ptx_thread_info *thread,
fesetround(FE_TOWARDZERO);
break;
default:
- //assert(0);
+ // assert(0);
break;
}
d.f32 = a.f32 * b.f32 + c.f32;
@@ -4326,7 +4327,7 @@ void mul_impl(const ptx_instruction *pI, ptx_thread_info *thread) {
case S64_TYPE:
t.s64 = a.s64 * b.s64;
assert(!pI->is_wide());
- //assert(!pI->is_hi());
+ // assert(!pI->is_hi());
d.s64 = t.s64;
break;
case U16_TYPE:
diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc
index f25f1d5..d309542 100644
--- a/src/cuda-sim/ptx_ir.cc
+++ b/src/cuda-sim/ptx_ir.cc
@@ -1,18 +1,19 @@
// Copyright (c) 2009-2021, Tor M. Aamodt, Ali Bakhoda, Wilson W.L. Fung,
// George L. Yuan, Vijay Kandiah, Nikos Hardavellas,
// Mahmoud Khairy, Junrui Pan, Timothy G. Rogers
-// The University of British Columbia, Northwestern University, Purdue University
-// All rights reserved.
+// The University of British Columbia, Northwestern University, Purdue
+// University All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
-// 1. Redistributions of source code must retain the above copyright notice, this
+// 1. Redistributions of source code must retain the above copyright notice,
+// this
// list of conditions and the following disclaimer;
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution;
-// 3. Neither the names of The University of British Columbia, Northwestern
+// 3. Neither the names of The University of British Columbia, Northwestern
// University nor the names of their contributors may be used to
// endorse or promote products derived from this software without specific
// prior written permission.
@@ -1386,7 +1387,7 @@ ptx_instruction::ptx_instruction(
case CS_OPTION:
case LU_OPTION:
case CV_OPTION:
- case WB_OPTION:
+ case WB_OPTION:
case WT_OPTION:
m_cache_option = last_ptx_inst_option;
break;
@@ -1469,8 +1470,8 @@ std::string ptx_instruction::to_string() const {
char buf[STR_SIZE];
unsigned used_bytes = 0;
if (!is_label()) {
- used_bytes +=
- snprintf(buf + used_bytes, STR_SIZE - used_bytes, " PC=0x%03llx ", m_PC);
+ used_bytes += snprintf(buf + used_bytes, STR_SIZE - used_bytes,
+ " PC=0x%03llx ", m_PC);
} else {
used_bytes +=
snprintf(buf + used_bytes, STR_SIZE - used_bytes, " ");
diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h
index 7ba7171..8b1f19c 100644
--- a/src/cuda-sim/ptx_ir.h
+++ b/src/cuda-sim/ptx_ir.h
@@ -1248,7 +1248,7 @@ class function_info {
const ptx_version &get_ptx_version() const {
return m_symtab->get_ptx_version();
}
- virtual ~function_info(){}
+ virtual ~function_info() {}
unsigned get_sm_target() const { return m_symtab->get_sm_target(); }
bool is_extern() const { return m_extern; }
void set_name(const char *name) { m_name = name; }
diff --git a/src/cuda-sim/ptx_sim.cc b/src/cuda-sim/ptx_sim.cc
index 6503499..2a548ee 100644
--- a/src/cuda-sim/ptx_sim.cc
+++ b/src/cuda-sim/ptx_sim.cc
@@ -369,7 +369,8 @@ static void print_reg(FILE *fp, std::string name, ptx_reg_t value,
fprintf(fp, ".u64 %llu [0x%llx]\n", value.u64, value.u64);
break;
case F16_TYPE:
- fprintf(fp, ".f16 %f [0x%04x]\n", static_cast<float>(value.f16), (unsigned)value.u16);
+ fprintf(fp, ".f16 %f [0x%04x]\n", static_cast<float>(value.f16),
+ (unsigned)value.u16);
break;
case F32_TYPE:
fprintf(fp, ".f32 %.15lf [0x%08x]\n", value.f32, value.u32);