summaryrefslogtreecommitdiff
path: root/src/cuda-sim
diff options
context:
space:
mode:
authorMahmoud <[email protected]>2019-09-12 18:30:18 -0400
committerMahmoud <[email protected]>2019-09-12 18:30:18 -0400
commit5753f2236b73be3e2a1a49a55fc5c52310eba622 (patch)
treec30d62bb70f62a7930f4fa0763c219b103b622d3 /src/cuda-sim
parent6ce5e06d2389cad5041b495d5516b503ec7d2cd2 (diff)
parentbea40c4a22a86fddbf1f7845265697716727f8b1 (diff)
Merge branch 'dev' of https://github.com/purdue-aalp/gpgpu-sim_distribution into dev-traces
Diffstat (limited to 'src/cuda-sim')
-rw-r--r--src/cuda-sim/cuda-sim.cc48
-rw-r--r--src/cuda-sim/cuda_device_runtime.cc3
-rw-r--r--src/cuda-sim/half.h6
-rw-r--r--src/cuda-sim/instructions.cc76
-rw-r--r--src/cuda-sim/ptx_ir.cc2
-rw-r--r--src/cuda-sim/ptx_loader.cc3
-rw-r--r--src/cuda-sim/ptx_parser.cc2
7 files changed, 60 insertions, 80 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index 1b0e841..7a130ea 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -429,7 +429,7 @@ void gpgpu_t::memcpy_to_gpu( size_t dst_start_addr, const void *src, size_t coun
// Copy into the performance model.
//extern gpgpu_sim* g_the_gpu;
- g_the_gpu()->perf_memcpy_to_gpu(dst_start_addr, count);
+ gpgpu_ctx->the_gpgpusim->g_the_gpu->perf_memcpy_to_gpu(dst_start_addr, count);
if(g_debug_execution >= 3) {
printf( " done.\n");
fflush(stdout);
@@ -448,7 +448,7 @@ void gpgpu_t::memcpy_from_gpu( void *dst, size_t src_start_addr, size_t count )
// Copy into the performance model.
//extern gpgpu_sim* g_the_gpu;
- g_the_gpu()->perf_memcpy_to_gpu(src_start_addr, count);
+ gpgpu_ctx->the_gpgpusim->g_the_gpu->perf_memcpy_to_gpu(src_start_addr, count);
if(g_debug_execution >= 3) {
printf( " done.\n");
fflush(stdout);
@@ -1254,7 +1254,7 @@ void function_info::param_to_shared( memory_space *shared_mem, symbol_table *sym
{
// TODO: call this only for PTXPlus with GT200 models
//extern gpgpu_sim* g_the_gpu;
- if (not g_the_gpu()->get_config().convert_to_ptxplus()) return;
+ if (not gpgpu_ctx->the_gpgpusim->g_the_gpu->get_config().convert_to_ptxplus()) return;
// copies parameters into simulated shared memory
for( std::map<unsigned,param_info>::iterator i=m_ptx_kernel_param_info.begin(); i!=m_ptx_kernel_param_info.end(); i++ ) {
@@ -1309,7 +1309,7 @@ void function_info::ptx_jit_config(std::map<unsigned long long, size_t> mallocPt
char buff[1024];
std::string filename_c(filename+"_c");
snprintf(buff,1024,"c++filt %s > %s", get_name().c_str(), filename_c.c_str());
- system(buff);
+ assert(system(buff) != NULL);
FILE *fp = fopen(filename_c.c_str(), "r");
fgets(buff, 1024, fp);
fclose(fp);
@@ -1432,13 +1432,13 @@ void function_info::ptx_jit_config(std::map<unsigned long long, size_t> mallocPt
fout = fopen(ptx_config_fn.c_str(), "a");
assert(fout!=NULL);
for (unsigned i = 0; i<line_number; i++){
- fgets(buff, 1024, fin);
+ assert(fgets(buff, 1024, fin) != NULL);
assert(!feof(fin));
}
fprintf(fout, "\n\n");
do{
fprintf(fout, "%s", buff);
- fgets(buff, 1024, fin);
+ assert(fgets(buff, 1024, fin) != NULL);
if(feof(fin)){
break;
}
@@ -1491,7 +1491,6 @@ static unsigned get_tex_datasize( const ptx_instruction *pI, ptx_thread_info *th
const operand_info &src1 = pI->src1(); //the name of the texture
std::string texname = src1.name();
- gpgpu_t *gpu = thread->get_gpu();
/*
For programs with many streams, textures can be bound and unbound
asynchronously. This means we need to use the kernel's "snapshot" of
@@ -1577,7 +1576,7 @@ void ptx_thread_info::ptx_exec_inst( warp_inst_t &inst, unsigned lane_id)
}
//Tensorcore is warp synchronous operation. So these instructions needs to be executed only once. To make the simulation faster removing the redundant tensorcore operation
- if(!tensorcore_op(inst_opcode)||(tensorcore_op(inst_opcode))&&(lane_id==0)){
+ if(!tensorcore_op(inst_opcode)||((tensorcore_op(inst_opcode))&&(lane_id==0))){
switch ( inst_opcode ) {
#define OP_DEF(OP,FUNC,STR,DST,CLASSIFICATION) case OP: FUNC(pI,this); op_classification = CLASSIFICATION; break;
#define OP_W_DEF(OP,FUNC,STR,DST,CLASSIFICATION) case OP: FUNC(pI,get_core(),inst); op_classification = CLASSIFICATION; break;
@@ -2138,19 +2137,13 @@ void cuda_sim::gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel, bool openCL
kernel_func_info->set_pdom();
}
- unsigned max_cta_tot = max_cta(kernel_info,kernel.threads_per_cta(), g_the_gpu()->getShaderCoreConfig()->warp_size, g_the_gpu()->getShaderCoreConfig()->n_thread_per_shader, g_the_gpu()->getShaderCoreConfig()->gpgpu_shmem_size, g_the_gpu()->getShaderCoreConfig()->gpgpu_shader_registers, g_the_gpu()->getShaderCoreConfig()->max_cta_per_core);
+ unsigned max_cta_tot = max_cta(kernel_info,kernel.threads_per_cta(), gpgpu_ctx->the_gpgpusim->g_the_gpu->getShaderCoreConfig()->warp_size, gpgpu_ctx->the_gpgpusim->g_the_gpu->getShaderCoreConfig()->n_thread_per_shader, gpgpu_ctx->the_gpgpusim->g_the_gpu->getShaderCoreConfig()->gpgpu_shmem_size, gpgpu_ctx->the_gpgpusim->g_the_gpu->getShaderCoreConfig()->gpgpu_shader_registers, gpgpu_ctx->the_gpgpusim->g_the_gpu->getShaderCoreConfig()->max_cta_per_core);
printf("Max CTA : %d\n",max_cta_tot);
-
-
-
-
- int inst_count=50;
- int cp_op= g_the_gpu()->checkpoint_option;
- int cp_CTA = g_the_gpu()->checkpoint_CTA;
- int cp_kernel= g_the_gpu()->checkpoint_kernel;
- cp_count= g_the_gpu()->checkpoint_insn_Y;
- cp_cta_resume= g_the_gpu()->checkpoint_CTA_t;
+ int cp_op= gpgpu_ctx->the_gpgpusim->g_the_gpu->checkpoint_option;
+ int cp_kernel= gpgpu_ctx->the_gpgpusim->g_the_gpu->checkpoint_kernel;
+ cp_count= gpgpu_ctx->the_gpgpusim->g_the_gpu->checkpoint_insn_Y;
+ cp_cta_resume= gpgpu_ctx->the_gpgpusim->g_the_gpu->checkpoint_CTA_t;
int cta_launched =0;
//we excute the kernel one CTA (Block) at the time, as synchronization functions work block wise
@@ -2162,8 +2155,8 @@ void cuda_sim::gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel, bool openCL
{
functionalCoreSim cta(
&kernel,
- g_the_gpu(),
- g_the_gpu()->getShaderCoreConfig()->warp_size
+ gpgpu_ctx->the_gpgpusim->g_the_gpu,
+ gpgpu_ctx->the_gpgpusim->g_the_gpu->getShaderCoreConfig()->warp_size
);
cta.execute(cp_count,temp);
@@ -2184,7 +2177,7 @@ void cuda_sim::gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel, bool openCL
{
char f1name[2048];
snprintf(f1name,2048,"checkpoint_files/global_mem_%d.txt", kernel.get_uid() );
- g_checkpoint->store_global_mem(g_the_gpu()->get_global_memory(), f1name , "%08x");
+ g_checkpoint->store_global_mem(gpgpu_ctx->the_gpgpusim->g_the_gpu->get_global_memory(), f1name , (char *)"%08x");
}
@@ -2195,7 +2188,7 @@ void cuda_sim::gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel, bool openCL
//openCL kernel simulation calls don't register the kernel so we don't register its exit
if(!openCL) {
//extern stream_manager *g_stream_manager;
- g_stream_manager()->register_finished_kernel(kernel.get_uid());
+ gpgpu_ctx->the_gpgpusim->g_stream_manager->register_finished_kernel(kernel.get_uid());
}
//******PRINTING*******
@@ -2210,7 +2203,7 @@ void cuda_sim::gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel, bool openCL
//g_simulation_starttime is initilized by gpgpu_ptx_sim_init_perf() in gpgpusim_entrypoint.cc upon starting gpgpu-sim
time_t end_time, elapsed_time, days, hrs, minutes, sec;
end_time = time((time_t *)NULL);
- elapsed_time = MAX(end_time - GPGPUsim_ctx_ptr()->g_simulation_starttime, 1);
+ elapsed_time = MAX(end_time - gpgpu_ctx->the_gpgpusim->g_simulation_starttime, 1);
//calculating and printing simulation time in terms of days, hours, minutes and seconds
@@ -2312,18 +2305,15 @@ void functionalCoreSim::execute(int inst_count, unsigned ctaid_cp)
checkpoint *g_checkpoint;
g_checkpoint = new checkpoint();
- symbol * sym;
ptx_reg_t regval;
regval.u64= 123;
- symbol_table * symtab= m_kernel->entry()->get_symtab();
-
unsigned ctaid =m_kernel->get_next_cta_id_single();
if(m_gpu->checkpoint_option==1 && (m_kernel->get_uid()==m_gpu->checkpoint_kernel) && (ctaid_cp>=m_gpu->checkpoint_CTA) && (ctaid_cp<m_gpu->checkpoint_CTA_t))
{
char fname[2048];
snprintf(fname,2048,"checkpoint_files/shared_mem_%d.txt",ctaid-1 );
- g_checkpoint->store_global_mem(m_thread[0]->m_shared_mem, fname , "%08x");
+ g_checkpoint->store_global_mem(m_thread[0]->m_shared_mem, fname , (char *)"%08x");
for(int i=0; i<32*m_warp_count;i++)
{
char fname[2048];
@@ -2331,7 +2321,7 @@ void functionalCoreSim::execute(int inst_count, unsigned ctaid_cp)
m_thread[i]->print_reg_thread(fname);
char f1name[2048];
snprintf(f1name,2048,"checkpoint_files/local_mem_thread_%d_%d_reg.txt",i,ctaid-1 );
- g_checkpoint->store_global_mem(m_thread[i]->m_local_mem, f1name , "%08x");
+ g_checkpoint->store_global_mem(m_thread[i]->m_local_mem, f1name , (char *)"%08x");
m_thread[i]->set_done();
m_thread[i]->exitCore();
m_thread[i]->registerExit();
diff --git a/src/cuda-sim/cuda_device_runtime.cc b/src/cuda-sim/cuda_device_runtime.cc
index dc3adc3..4baced5 100644
--- a/src/cuda-sim/cuda_device_runtime.cc
+++ b/src/cuda-sim/cuda_device_runtime.cc
@@ -27,7 +27,6 @@
}
-//extern stream_manager *g_stream_manager();
//Handling device runtime api:
//void * cudaGetParameterBufferV2(void *func, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize)
@@ -285,7 +284,7 @@ void cuda_device_runtime::launch_one_device_kernel() {
device_launch_operation_t &op = g_cuda_device_launch_op.front();
stream_operation stream_op = stream_operation(op.grid, gpgpu_ctx->func_sim->g_ptx_sim_mode, op.stream);
- g_stream_manager()->push(stream_op);
+ gpgpu_ctx->the_gpgpusim->g_stream_manager->push(stream_op);
g_cuda_device_launch_op.pop_front();
}
}
diff --git a/src/cuda-sim/half.h b/src/cuda-sim/half.h
index 8f1a8eb..9f74bb7 100644
--- a/src/cuda-sim/half.h
+++ b/src/cuda-sim/half.h
@@ -642,10 +642,10 @@ namespace half_float
if(exp > 16)
{
if(R == std::round_toward_infinity)
- return hbits | 0x7C00 - (hbits>>15);
+ return hbits | (0x7C00 - (hbits>>15));
else if(R == std::round_toward_neg_infinity)
- return hbits | 0x7BFF + (hbits>>15);
- return hbits | 0x7BFF + (R!=std::round_toward_zero);
+ return hbits | (0x7BFF + (hbits>>15));
+ return hbits | (0x7BFF + (R!=std::round_toward_zero));
}
if(exp < -13)
value = std::ldexp(value, 24);
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index 58a077e..014e588 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -203,7 +203,7 @@ void ptx_thread_info::print_reg_thread(char * fname)
const std::string &name = it->first->name();
const std::string &dec= it->first->decl_location();
unsigned size = it->first->get_size_in_bytes();
- fprintf(fp,"%s %llu %s %d\n",name.c_str(),it->second, dec.c_str(),size );
+ fprintf(fp,"%s %llu %s %d\n", name.c_str(), it->second, dec.c_str(), size);
}
//m_regs.pop_back();
@@ -224,7 +224,6 @@ void ptx_thread_info::resume_reg_thread(char * fname, symbol_table * symtab)
{
symbol *reg;
char * pch;
- unsigned size;
pch = strtok (line," ");
char * name =pch;
reg= symtab->lookup(name);
@@ -232,11 +231,7 @@ void ptx_thread_info::resume_reg_thread(char * fname, symbol_table * symtab)
pch = strtok (NULL," ");
data = atoi(pch);
pch = strtok (NULL," ");
- char * decl= pch;
pch = strtok (NULL," ");
- size = atoi(pch);
-
-
m_regs.back()[reg] = data;
}
fclose ( fp2 );
@@ -1819,9 +1814,7 @@ void mma_impl( const ptx_instruction *pI, core_t *core, warp_inst_t inst )
ptx_reg_t matrix_d[16][16];
ptx_reg_t src_data;
ptx_thread_info *thread;
- int stride;
- unsigned wmma_type = pI->get_wmma_type();
unsigned a_layout = pI->get_wmma_layout(0);
unsigned b_layout = pI->get_wmma_layout(1);
unsigned type = pI->get_type();
@@ -1833,7 +1826,6 @@ void mma_impl( const ptx_instruction *pI, core_t *core, warp_inst_t inst )
tid= inst.warp_id_func()*core->get_warp_size();
else
tid= inst.warp_id()*core->get_warp_size();
- unsigned thread_group_index;
float temp;
half temp2;
@@ -1847,9 +1839,9 @@ void mma_impl( const ptx_instruction *pI, core_t *core, warp_inst_t inst )
ptx_reg_t v[8];
thread->get_vector_operand_values( src_a, v, nelem );
if(core->get_gpu()->gpgpu_ctx->debug_tensorcore){
- printf("Thread%d_Iteration=%d\n:",thrd,operand_num);
- for(k=0;k<nelem;k++){
- printf("%x ",v[k].u64);
+ printf("Thread%d_Iteration=%d\n:", thrd, operand_num);
+ for(k = 0; k < nelem; k++){
+ printf("%llx ",v[k].u64);
}
printf("\n");
}
@@ -2027,7 +2019,7 @@ void mma_impl( const ptx_instruction *pI, core_t *core, warp_inst_t inst )
printf("thread%d:",thrd);
for(k=0;k<8;k++){
- printf("%x ",matrix_d[row_t[k]][col_t[k]].f16);
+ printf("%x ", (unsigned int)matrix_d[row_t[k]][col_t[k]].f16);
}
printf("\n");
}
@@ -2038,7 +2030,7 @@ void mma_impl( const ptx_instruction *pI, core_t *core, warp_inst_t inst )
nw_data4.s64=((matrix_d[row_t[6]][col_t[6]].s64 & 0xffff))|((matrix_d[row_t[7]][col_t[7]].s64&0xffff)<<16);
thread->set_vector_operand_values(dst,nw_data1,nw_data2,nw_data3,nw_data4);
if(core->get_gpu()->gpgpu_ctx->debug_tensorcore)
- printf("thread%d=%x,%x,%x,%x",thrd,nw_data1.s64,nw_data2.s64,nw_data3.s64,nw_data4.s64);
+ printf("thread%d=%llx,%llx,%llx,%llx", thrd, nw_data1.s64, nw_data2.s64, nw_data3.s64, nw_data4.s64);
}
else{
@@ -2298,9 +2290,8 @@ unsigned int saturatei(unsigned int a, unsigned int max)
ptx_reg_t f2x( ptx_reg_t x, unsigned from_width, unsigned to_width, int to_sign, int rounding_mode, int saturation_mode )
{
- half mytemp;
- float myfloat;
- half_float::half tmp_h;
+ half mytemp;
+ half_float::half tmp_h;
//assert( from_width == 32);
enum cudaRoundMode mode = cudaRoundZero;
@@ -3085,7 +3076,7 @@ void mma_st_impl( const ptx_instruction *pI, core_t *core, warp_inst_t &inst )
size_t size;
unsigned smid;
int t;
- int thrd,odd,inx,k;
+ int thrd, k;
ptx_thread_info *thread;
const operand_info &src = pI->operand_lookup(1);
@@ -3105,15 +3096,13 @@ void mma_st_impl( const ptx_instruction *pI, core_t *core, warp_inst_t &inst )
_memory_op_t insn_memory_op = pI->has_memory_read() ? memory_load : memory_store;
for (thrd=0; thrd < core->get_warp_size(); thrd++) {
thread = core->get_thread_info()[tid+thrd];
- odd=thrd%2;
- inx=thrd/2;
- ptx_reg_t addr_reg = thread->get_operand_value(src1, src, type, thread, 1);
+ ptx_reg_t addr_reg = thread->get_operand_value(src1, src, type, thread, 1);
ptx_reg_t src2_data = thread->get_operand_value(src2, src, type, thread, 1);
const operand_info &src_a= pI->operand_lookup(1);
unsigned nelem = src_a.get_vect_nelem();
ptx_reg_t* v= new ptx_reg_t[8];
thread->get_vector_operand_values( src_a, v, nelem );
- stride=src2_data.u32;
+ stride = src2_data.u32;
memory_space_t space = pI->get_space();
@@ -3130,9 +3119,9 @@ void mma_st_impl( const ptx_instruction *pI, core_t *core, warp_inst_t &inst )
}
decode_space(space,thread,src1,mem,addr);
- type_info_key::type_decode(type,size,t);
+ type_info_key::type_decode(type, size, t);
if(core->get_gpu()->gpgpu_ctx->debug_tensorcore)
- printf("mma_st: thrd=%d,addr=%x, fp(size=%d), stride=%d\n",thrd,addr_reg.u32,size,src2_data.u32);
+ printf("mma_st: thrd=%d, addr=%x, fp(size=%zu), stride=%d\n", thrd, addr_reg.u32, size, src2_data.u32);
addr_t new_addr = addr+thread_group_offset(thrd,wmma_type,wmma_layout,type,stride)*size/8;
addr_t push_addr;
@@ -3152,7 +3141,7 @@ void mma_st_impl( const ptx_instruction *pI, core_t *core, warp_inst_t &inst )
mem_txn_addr[num_mem_txn++]=push_addr;
if(core->get_gpu()->gpgpu_ctx->debug_tensorcore){
- printf("wmma:store:thread%d=%x,%x,%x,%x,%x,%x,%x,%x\n",thrd,v[0].s64,v[1].s64,v[2].s64,v[3].s64,v[4].s64,v[5].s64,v[6].s64,v[7].s64);
+ printf("wmma:store:thread%d=%llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n",thrd,v[0].s64,v[1].s64,v[2].s64,v[3].s64,v[4].s64,v[5].s64,v[6].s64,v[7].s64);
float temp;
int l;
printf("thread=%d:",thrd);
@@ -3179,7 +3168,7 @@ void mma_st_impl( const ptx_instruction *pI, core_t *core, warp_inst_t &inst )
}
if(core->get_gpu()->gpgpu_ctx->debug_tensorcore)
- printf("wmma:store:thread%d=%x,%x,%x,%x,%x,%x,%x,%x\n",thrd,nw_v[0].s64,nw_v[1].s64,nw_v[2].s64,nw_v[3].s64,nw_v[4].s64,nw_v[5].s64,nw_v[6].s64,nw_v[7].s64);
+ printf("wmma:store:thread%d=%llx,%llx,%llx,%llx,%llx,%llx,%llx,%llx\n",thrd,nw_v[0].s64,nw_v[1].s64,nw_v[2].s64,nw_v[3].s64,nw_v[4].s64,nw_v[5].s64,nw_v[6].s64,nw_v[7].s64);
}
}
@@ -3238,11 +3227,11 @@ void mma_ld_impl( const ptx_instruction *pI, core_t *core, warp_inst_t &inst )
}
decode_space(space,thread,src1,mem,addr);
- type_info_key::type_decode(type,size,t);
+ type_info_key::type_decode(type, size, t);
ptx_reg_t data[16];
if(core->get_gpu()->gpgpu_ctx->debug_tensorcore)
- printf("mma_ld: thrd=%d,addr=%x, fpsize=%d, stride=%d\n",thrd,src1_data.u32,size,src2_data.u32);
+ printf("mma_ld: thrd=%d,addr=%x, fpsize=%zu, stride=%d\n", thrd, src1_data.u32, size, src2_data.u32);
addr_t new_addr = addr+thread_group_offset(thrd,wmma_type,wmma_layout,type,stride)*size/8;
addr_t fetch_addr;
@@ -3341,7 +3330,7 @@ void mma_ld_impl( const ptx_instruction *pI, core_t *core, warp_inst_t &inst )
if(type==F16_TYPE){
printf("\nmma_ld:thread%d= ",thrd);
for(i=0;i<16;i++){
- printf("%x ",data[i].u64);
+ printf("%llx ",data[i].u64);
}
printf("\n");
@@ -3361,7 +3350,7 @@ void mma_ld_impl( const ptx_instruction *pI, core_t *core, warp_inst_t &inst )
printf("\n");
printf("\nmma_ld:thread%d= ",thrd);
for(i=0;i<8;i++){
- printf("%x ",data[i].u64);
+ printf("%llx ",data[i].u64);
}
printf("\n");
}
@@ -3388,15 +3377,15 @@ void mma_ld_impl( const ptx_instruction *pI, core_t *core, warp_inst_t &inst )
else
thread->set_wmma_vector_operand_values(dst,nw_data[0],nw_data[1],nw_data[2],nw_data[3],nw_data[4],nw_data[5],nw_data[6],nw_data[7]);
if(core->get_gpu()->gpgpu_ctx->debug_tensorcore){
- printf("mma_ld:data[0].s64=%x,data[1].s64=%x,new_data[0].s64=%x\n",data[0].u64,data[1].u64,nw_data[0].u64);
- printf("mma_ld:data[2].s64=%x,data[3].s64=%x,new_data[1].s64=%x\n",data[2].u64,data[3].u64,nw_data[1].u64);
- printf("mma_ld:data[4].s64=%x,data[5].s64=%x,new_data[2].s64=%x\n",data[4].u64,data[5].u64,nw_data[2].u64);
- printf("mma_ld:data[6].s64=%x,data[7].s64=%x,new_data[3].s64=%x\n",data[6].u64,data[7].u64,nw_data[3].u64);
+ printf("mma_ld:data[0].s64=%llx,data[1].s64=%llx,new_data[0].s64=%llx\n",data[0].u64,data[1].u64,nw_data[0].u64);
+ printf("mma_ld:data[2].s64=%llx,data[3].s64=%llx,new_data[1].s64=%llx\n",data[2].u64,data[3].u64,nw_data[1].u64);
+ printf("mma_ld:data[4].s64=%llx,data[5].s64=%llx,new_data[2].s64=%llx\n",data[4].u64,data[5].u64,nw_data[2].u64);
+ printf("mma_ld:data[6].s64=%llx,data[7].s64=%llx,new_data[3].s64=%llx\n",data[6].u64,data[7].u64,nw_data[3].u64);
if(wmma_type!=LOAD_C){
- printf("mma_ld:data[8].s64=%x,data[9].s64=%x,new_data[4].s64=%x\n",data[8].u64,data[9].u64,nw_data[4].s64);
- printf("mma_ld:data[10].s64=%x,data[11].s64=%x,new_data[5].s64=%x\n",data[10].u64,data[11].u64,nw_data[5].u64);
- printf("mma_ld:data[12].s64=%x,data[13].s64=%x,new_data[6].s64=%x\n",data[12].u64,data[13].u64,nw_data[6].u64);
- printf("mma_ld:data[14].s64=%x,data[15].s64=%x,new_data[7].s64=%x\n",data[14].u64,data[15].u64,nw_data[3].u64);
+ printf("mma_ld:data[8].s64=%llx,data[9].s64=%llx,new_data[4].s64=%llx\n",data[8].u64,data[9].u64,nw_data[4].s64);
+ printf("mma_ld:data[10].s64=%llx,data[11].s64=%llx,new_data[5].s64=%llx\n",data[10].u64,data[11].u64,nw_data[5].u64);
+ printf("mma_ld:data[12].s64=%llx,data[13].s64=%llx,new_data[6].s64=%llx\n",data[12].u64,data[13].u64,nw_data[6].u64);
+ printf("mma_ld:data[14].s64=%llx,data[15].s64=%llx,new_data[7].s64=%llx\n",data[14].u64,data[15].u64,nw_data[3].u64);
}
}
}
@@ -4132,9 +4121,9 @@ int prmt_mode_present(int mode)
}
return returnval;
}
-int read_byte(int mode,int control,int d_sel_index,signed long long value){
+int read_byte(int mode, int control, int d_sel_index, signed long long value){
- int returnval;
+ int returnval = 0;
int prmt_f4e_mode[4][4]={{0,1,2,3},{1,2,3,4},{2,3,4,5},{3,4,5,6}};
int prmt_b4e_mode[4][4]={{0,7,6,5},{1,0,7,6},{2,1,0,7},{3,2,1,0}};
int prmt_rc8_mode[4][4]={{0,0,0,0},{1,1,1,1},{2,2,2,2},{3,3,3,3}};
@@ -4157,11 +4146,12 @@ int read_byte(int mode,int control,int d_sel_index,signed long long value){
case PRMT_RC8_MODE: returnval=prmt_rc8_mode[control][d_sel_index];break;
case PRMT_ECL_MODE: returnval=prmt_ecl_mode[control][d_sel_index];break;
case PRMT_ECR_MODE: returnval=prmt_ecr_mode[control][d_sel_index];break;
- case PRMT_RC16_MODE: returnval=prmt_rc16_mode[control][d_sel_index];break;
- default: printf("ERROR\n");break;
+ case PRMT_RC16_MODE: returnval=prmt_rc16_mode[control][d_sel_index];break;
+ // Change the default from printing "ERROR" to just asserting
+ default: assert(false);
}
}
- return (returnval<<8*d_sel_index);
+ return (returnval << 8 * d_sel_index);
}
void prmt_impl( const ptx_instruction *pI, ptx_thread_info *thread ) {
diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc
index 6978cc1..d8943d2 100644
--- a/src/cuda-sim/ptx_ir.cc
+++ b/src/cuda-sim/ptx_ir.cc
@@ -1415,7 +1415,7 @@ unsigned function_info::print_insn( unsigned pc, FILE * fp ) const
snprintf(command,1024,"c++filt -p %s",m_name.c_str());
FILE *p = popen(command,"r");
buffer[0]=0;
- fgets(buffer, 1023, p);
+ assert(fgets(buffer, 1023, p) != NULL);
// Remove trailing "\n" in buffer
char *c;
if ((c=strchr(buffer, '\n')) != NULL) *c = '\0';
diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc
index 207fa1f..f06fefd 100644
--- a/src/cuda-sim/ptx_loader.cc
+++ b/src/cuda-sim/ptx_loader.cc
@@ -214,7 +214,8 @@ void fix_duplicate_errors(char fname2[1024]) {
long filesize = ftell(ptxsource);
rewind(ptxsource);
char *ptxdata = (char*)malloc((filesize+1)*sizeof(char));
- fread(ptxdata, filesize, 1, ptxsource);
+ // Fail if we do not read the file
+ assert(fread(ptxdata, filesize, 1, ptxsource) == 1);
fclose(ptxsource);
FILE *ptxdest = fopen(fname2,"w");
diff --git a/src/cuda-sim/ptx_parser.cc b/src/cuda-sim/ptx_parser.cc
index 9e9d500..24af3ad 100644
--- a/src/cuda-sim/ptx_parser.cc
+++ b/src/cuda-sim/ptx_parser.cc
@@ -421,7 +421,7 @@ void ptx_recognizer::add_identifier( const char *identifier, int array_dim, unsi
assert( (num_bits%8) == 0 );
addr = g_current_symbol_table->get_sstarr_next();
addr_pad = pad_address(addr, num_bits/8, 128);
- printf("from 0x%x to 0x%lx (sstarr memory space)\n",
+ printf("from 0x%llx to 0x%llx (sstarr memory space)\n",
addr+addr_pad,
addr+addr_pad + num_bits/8);
fflush(stdout);