aboutsummaryrefslogtreecommitdiff
path: root/src/cuda-sim
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuda-sim')
-rw-r--r--src/cuda-sim/cuda-sim.cc109
-rw-r--r--src/cuda-sim/cuda-sim.h17
-rw-r--r--src/cuda-sim/cuda_device_printf.cc4
-rw-r--r--src/cuda-sim/cuda_device_printf.h2
-rw-r--r--src/cuda-sim/instructions.cc38
-rw-r--r--src/cuda-sim/ptx_ir.cc2
-rw-r--r--src/cuda-sim/ptx_ir.h15
-rw-r--r--src/cuda-sim/ptx_loader.cc19
-rw-r--r--src/cuda-sim/ptx_loader.h11
-rw-r--r--src/cuda-sim/ptx_sim.cc1
-rw-r--r--src/cuda-sim/ptx_sim.h21
11 files changed, 102 insertions, 137 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index dcf1fd4..7f4eebd 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -309,20 +309,6 @@ void function_info::ptx_assemble()
m_assembled = true;
}
-
-
-void gpgpu_ptx_sim_init_memory()
-{
- static bool initialized = false;
- if ( !initialized ) {
- g_global_mem = new memory_space_impl<8192>("global",64*1024);
- g_param_mem = new memory_space_impl<8192>("param",64*1024);
- g_tex_mem = new memory_space_impl<8192>("tex",64*1024);
- g_surf_mem = new memory_space_impl<8192>("surf",64*1024);
- initialized = true;
- }
-}
-
addr_t shared_to_generic( unsigned smid, addr_t addr )
{
assert( addr < SHARED_MEM_SIZE_MAX );
@@ -392,9 +378,7 @@ addr_t generic_to_global( addr_t addr )
}
-unsigned long long g_dev_malloc=GLOBAL_HEAP_START;
-
-void* gpgpu_ptx_sim_malloc( size_t size )
+void* gpgpu_t::gpgpu_ptx_sim_malloc( size_t size )
{
unsigned long long result = g_dev_malloc;
printf("GPGPU-Sim PTX: allocating %zu bytes on GPU starting at address 0x%Lx\n", size, g_dev_malloc );
@@ -404,7 +388,7 @@ void* gpgpu_ptx_sim_malloc( size_t size )
return(void*) result;
}
-void* gpgpu_ptx_sim_mallocarray( size_t size )
+void* gpgpu_t::gpgpu_ptx_sim_mallocarray( size_t size )
{
unsigned long long result = g_dev_malloc;
printf("GPGPU-Sim PTX: allocating %zu bytes on GPU starting at address 0x%Lx\n", size, g_dev_malloc );
@@ -415,7 +399,7 @@ void* gpgpu_ptx_sim_mallocarray( size_t size )
}
-void gpgpu_ptx_sim_memcpy_to_gpu( size_t dst_start_addr, const void *src, size_t count )
+void gpgpu_t::gpgpu_ptx_sim_memcpy_to_gpu( size_t dst_start_addr, const void *src, size_t count )
{
printf("GPGPU-Sim PTX: copying %zu bytes from CPU[0x%Lx] to GPU[0x%Lx] ... ", count, (unsigned long long) src, (unsigned long long) dst_start_addr );
fflush(stdout);
@@ -426,7 +410,7 @@ void gpgpu_ptx_sim_memcpy_to_gpu( size_t dst_start_addr, const void *src, size_t
fflush(stdout);
}
-void gpgpu_ptx_sim_memcpy_from_gpu( void *dst, size_t src_start_addr, size_t count )
+void gpgpu_t::gpgpu_ptx_sim_memcpy_from_gpu( void *dst, size_t src_start_addr, size_t count )
{
printf("GPGPU-Sim PTX: copying %zu bytes from GPU[0x%Lx] to CPU[0x%Lx] ...", count, (unsigned long long) src_start_addr, (unsigned long long) dst );
fflush(stdout);
@@ -437,7 +421,7 @@ void gpgpu_ptx_sim_memcpy_from_gpu( void *dst, size_t src_start_addr, size_t cou
fflush(stdout);
}
-void gpgpu_ptx_sim_memcpy_gpu_to_gpu( size_t dst, size_t src, size_t count )
+void gpgpu_t::gpgpu_ptx_sim_memcpy_gpu_to_gpu( size_t dst, size_t src, size_t count )
{
printf("GPGPU-Sim PTX: copying %zu bytes from GPU[0x%Lx] to GPU[0x%Lx] ...", count,
(unsigned long long) src, (unsigned long long) dst );
@@ -451,7 +435,7 @@ void gpgpu_ptx_sim_memcpy_gpu_to_gpu( size_t dst, size_t src, size_t count )
fflush(stdout);
}
-void gpgpu_ptx_sim_memset( size_t dst_start_addr, int c, size_t count )
+void gpgpu_t::gpgpu_ptx_sim_memset( size_t dst_start_addr, int c, size_t count )
{
printf("GPGPU-Sim PTX: setting %zu bytes of memory to 0x%x starting at 0x%Lx... ",
count, (unsigned char) c, (unsigned long long) dst_start_addr );
@@ -890,6 +874,12 @@ void ptx_thread_info::ptx_exec_inst( warp_inst_t &inst, unsigned lane_id )
}
}
if( !skip ) {
+ ptx_instruction *pJ = NULL;
+ if( pI->get_opcode() == VOTE_OP ) {
+ pJ = new ptx_instruction(*pI);
+ *((warp_inst_t*)pJ) = inst;
+ pI = pJ;
+ }
switch ( pI->get_opcode() ) {
#define OP_DEF(OP,FUNC,STR,DST,CLASSIFICATION) case OP: FUNC(pI,this); op_classification = CLASSIFICATION; break;
#include "opcodes.def"
@@ -899,6 +889,7 @@ void ptx_thread_info::ptx_exec_inst( warp_inst_t &inst, unsigned lane_id )
printf( "Execution error: Invalid opcode (0x%x)\n", pI->get_opcode() );
break;
}
+ delete pJ;
// Run exit instruction if exit option included
if(pI->is_exit())
@@ -1045,11 +1036,6 @@ void ptx_thread_info::ptx_exec_inst( warp_inst_t &inst, unsigned lane_id )
}
}
-std::list<ptx_thread_info *> g_active_threads;
-std::map<unsigned,memory_space*> g_shared_memory_lookup;
-std::map<unsigned,ptx_cta_info*> g_ptx_cta_lookup;
-std::map<unsigned,std::map<unsigned,memory_space*> > g_local_memory_lookup;
-
void set_param_gpgpu_num_shaders(int num_shaders)
{
gpgpu_param_num_shaders = num_shaders;
@@ -1073,8 +1059,14 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
unsigned num_threads,
core_t *core,
unsigned hw_cta_id,
- unsigned hw_warp_id )
+ unsigned hw_warp_id,
+ gpgpu_t *gpu )
{
+ static std::list<ptx_thread_info *> active_threads;
+ static std::map<unsigned,memory_space*> shared_memory_lookup;
+ static std::map<unsigned,ptx_cta_info*> ptx_cta_lookup;
+ static std::map<unsigned,std::map<unsigned,memory_space*> > local_memory_lookup;
+
if ( *thread_info != NULL ) {
ptx_thread_info *thd = *thread_info;
assert( thd->is_done() );
@@ -1091,16 +1083,12 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
*thread_info = NULL;
}
- if ( !g_active_threads.empty() ) { //if g_active_threads not empty...
- assert( g_active_threads.size() <= threads_left );
- ptx_thread_info *thd = g_active_threads.front();
- g_active_threads.pop_front();
+ if ( !active_threads.empty() ) { //if g_active_threads not empty...
+ assert( active_threads.size() <= threads_left );
+ ptx_thread_info *thd = active_threads.front();
+ active_threads.pop_front();
*thread_info = thd;
- thd->set_hw_tid(tid);
- thd->set_hw_wid(hw_warp_id);
- thd->set_hw_ctaid(hw_cta_id);
- thd->set_core(core);
- thd->set_hw_sid(sid);
+ thd->init(gpu, core, sid, hw_cta_id, hw_warp_id, tid );
return 1;
}
@@ -1127,7 +1115,7 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
unsigned sm_idx = (tid/cta_size)*gpgpu_param_num_shaders + sid;
- if ( g_shared_memory_lookup.find(sm_idx) == g_shared_memory_lookup.end() ) {
+ if ( shared_memory_lookup.find(sm_idx) == shared_memory_lookup.end() ) {
if ( g_debug_execution >= 1 ) {
printf(" <CTA alloc> : sm_idx=%u sid=%u max_cta_per_sm=%u\n",
sm_idx, sid, max_cta_per_sm );
@@ -1135,20 +1123,20 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
char buf[512];
snprintf(buf,512,"shared_%u", sid);
shared_mem = new memory_space_impl<16*1024>(buf,4);
- g_shared_memory_lookup[sm_idx] = shared_mem;
+ shared_memory_lookup[sm_idx] = shared_mem;
cta_info = new ptx_cta_info(sm_idx);
- g_ptx_cta_lookup[sm_idx] = cta_info;
+ ptx_cta_lookup[sm_idx] = cta_info;
} else {
if ( g_debug_execution >= 1 ) {
printf(" <CTA realloc> : sm_idx=%u sid=%u max_cta_per_sm=%u\n",
sm_idx, sid, max_cta_per_sm );
}
- shared_mem = g_shared_memory_lookup[sm_idx];
- cta_info = g_ptx_cta_lookup[sm_idx];
+ shared_mem = shared_memory_lookup[sm_idx];
+ cta_info = ptx_cta_lookup[sm_idx];
cta_info->check_cta_thread_status_and_reset();
}
- std::map<unsigned,memory_space*> &local_mem_lookup = g_local_memory_lookup[sid];
+ std::map<unsigned,memory_space*> &local_mem_lookup = local_memory_lookup[sid];
while( kernel.more_threads_in_cta() ) {
dim3 ctaid3d = kernel.get_next_cta_id();
unsigned new_tid = kernel.get_next_thread_id();
@@ -1174,11 +1162,6 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
thd->set_tid(tid3d);
if( kernel.entry()->get_ptx_version().extensions() )
thd->cpy_tid_to_reg(tid3d);
- thd->set_hw_tid((unsigned)-1);
- thd->set_hw_wid((unsigned)-1);
- thd->set_hw_ctaid((unsigned)-1);
- thd->set_core(NULL);
- thd->set_hw_sid((unsigned)-1);
thd->set_valid();
thd->m_shared_mem = shared_mem;
function_info *finfo = thd->func_info();
@@ -1192,7 +1175,7 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
ctaid3d.x,ctaid3d.y,ctaid3d.z,tid3d.x,tid3d.y,tid3d.z, (unsigned long long)thd );
fflush(stdout);
}
- g_active_threads.push_back(thd);
+ active_threads.push_back(thd);
}
if ( g_debug_execution==-1 ) {
printf("GPGPU-Sim PTX simulator: <-- FINISHING THREAD ALLOCATION\n");
@@ -1201,16 +1184,10 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
kernel.increment_cta_id();
- assert( g_active_threads.size() <= threads_left );
-
- *thread_info = g_active_threads.front();
- (*thread_info)->set_hw_tid(tid);
- (*thread_info)->set_hw_wid(hw_warp_id);
- (*thread_info)->set_hw_ctaid(hw_cta_id);
- (*thread_info)->set_core(core);
- (*thread_info)->set_hw_sid(sid);
- g_active_threads.pop_front();
-
+ assert( active_threads.size() <= threads_left );
+ *thread_info = active_threads.front();
+ (*thread_info)->init(gpu, core, sid, hw_cta_id, hw_warp_id, tid );
+ active_threads.pop_front();
return 1;
}
@@ -1220,7 +1197,11 @@ size_t get_kernel_code_size( class function_info *entry )
}
-kernel_info_t gpgpu_opencl_ptx_sim_init_grid(class function_info *entry,gpgpu_ptx_sim_arg_list_t args, struct dim3 gridDim, struct dim3 blockDim )
+kernel_info_t gpgpu_opencl_ptx_sim_init_grid(class function_info *entry,
+ gpgpu_ptx_sim_arg_list_t args,
+ struct dim3 gridDim,
+ struct dim3 blockDim,
+ gpgpu_t *gpu )
{
unsigned argcount=args.size();
unsigned argn=1;
@@ -1228,7 +1209,7 @@ kernel_info_t gpgpu_opencl_ptx_sim_init_grid(class function_info *entry,gpgpu_pt
entry->add_param_data(argcount-argn,&(*a));
argn++;
}
- entry->finalize(g_param_mem);
+ entry->finalize(gpu->get_param_memory());
g_ptx_kernel_count++;
fflush(stdout);
@@ -1263,7 +1244,7 @@ void gpgpu_ptx_sim_register_global_variable(void *hostVar, const char *deviceNam
g_global_name_lookup[hostVar] = deviceName;
}
-void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t count, size_t offset, int to )
+void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t count, size_t offset, int to, gpgpu_t *gpu )
{
printf("GPGPU-Sim PTX: starting gpgpu_ptx_sim_memcpy_symbol with hostVar 0x%p\n", hostVar);
bool found_sym = false;
@@ -1314,11 +1295,11 @@ void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t co
unsigned dst = sym->get_address() + offset;
switch (mem_region.get_type()) {
case const_space:
- mem = g_global_mem;
+ mem = gpu->get_global_memory();
mem_name = "global";
break;
case global_space:
- mem = g_global_mem;
+ mem = gpu->get_global_memory();
mem_name = "global";
break;
default:
diff --git a/src/cuda-sim/cuda-sim.h b/src/cuda-sim/cuda-sim.h
index 322e8a2..b72a157 100644
--- a/src/cuda-sim/cuda-sim.h
+++ b/src/cuda-sim/cuda-sim.h
@@ -13,7 +13,6 @@ class symbol_table;
extern const char *g_gpgpusim_version_string;
extern int g_ptx_sim_mode;
-extern memory_space *g_global_mem;
extern int g_debug_execution;
extern int g_debug_thread_uid;
extern void ** g_inst_classification_stat;
@@ -25,20 +24,13 @@ extern FILE* ptx_inst_debug_file;
extern class kernel_info_t gpgpu_opencl_ptx_sim_init_grid(class function_info *entry,
gpgpu_ptx_sim_arg_list_t args,
struct dim3 gridDim,
- struct dim3 blockDim );
+ struct dim3 blockDim,
+ class gpgpu_t *gpu );
extern void gpgpu_cuda_ptx_sim_main_func( kernel_info_t kernel, dim3 gridDim, dim3 blockDim, gpgpu_ptx_sim_arg_list_t args);
extern void print_splash();
-extern void* gpgpu_ptx_sim_malloc( size_t count );
-extern void* gpgpu_ptx_sim_mallocarray( size_t count );
-extern void gpgpu_ptx_sim_memcpy_to_gpu( size_t dst_start_addr, const void *src, size_t count );
-extern void gpgpu_ptx_sim_memcpy_from_gpu( void *dst, size_t src_start_addr, size_t count );
-extern void gpgpu_ptx_sim_memcpy_gpu_to_gpu( size_t dst, size_t src, size_t count );
-extern void gpgpu_ptx_sim_memset( size_t dst_start_addr, int c, size_t count );
-extern void gpgpu_ptx_sim_init_memory();
-extern void gpgpu_ptx_sim_register_kernel(void **fatCubinHandle,const char *hostFun, const char *deviceFun);
extern void gpgpu_ptx_sim_register_const_variable(void*, const char *deviceName, size_t size );
extern void gpgpu_ptx_sim_register_global_variable(void *hostVar, const char *deviceName, size_t size );
-extern void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t count, size_t offset, int to );
+extern void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t count, size_t offset, int to, gpgpu_t *gpu );
extern void gpgpu_ptx_sim_bindTextureToArray(const struct textureReference* texref, const struct cudaArray* array);
extern void gpgpu_ptx_sim_bindNameToTexture(const char* name, const struct textureReference* texref);
@@ -55,7 +47,8 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
unsigned num_threads,
class core_t *core,
unsigned hw_cta_id,
- unsigned hw_warp_id );
+ unsigned hw_warp_id,
+ gpgpu_t *gpu );
const warp_inst_t *ptx_fetch_inst( address_type pc );
const struct gpgpu_ptx_sim_kernel_info* ptx_sim_kernel_info(class function_info *kernel);
void ptx_print_insn( address_type pc, FILE *fp );
diff --git a/src/cuda-sim/cuda_device_printf.cc b/src/cuda-sim/cuda_device_printf.cc
index 9edeb5e..8483dd9 100644
--- a/src/cuda-sim/cuda_device_printf.cc
+++ b/src/cuda-sim/cuda_device_printf.cc
@@ -65,7 +65,7 @@
#include "cuda_device_printf.h"
#include "ptx_ir.h"
-void decode_space( memory_space_t &space, const ptx_thread_info *thread, const operand_info &op, memory_space *&mem, addr_t &addr);
+void decode_space( memory_space_t &space, ptx_thread_info *thread, const operand_info &op, memory_space *&mem, addr_t &addr);
void my_cuda_printf(const char *fmtstr,const char *arg_list)
{
@@ -104,7 +104,7 @@ void my_cuda_printf(const char *fmtstr,const char *arg_list)
}
}
-void gpgpusim_cuda_vprintf(const ptx_instruction * pI, const ptx_thread_info * thread, const function_info * target_func )
+void gpgpusim_cuda_vprintf(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func )
{
char *fmtstr = NULL;
char *arg_list = NULL;
diff --git a/src/cuda-sim/cuda_device_printf.h b/src/cuda-sim/cuda_device_printf.h
index 022b555..7b2a5ef 100644
--- a/src/cuda-sim/cuda_device_printf.h
+++ b/src/cuda-sim/cuda_device_printf.h
@@ -65,6 +65,6 @@
#ifndef CUDA_DEVICE_PRINTF_INCLUDED
#define CUDA_DEVICE_PRINTF_INCLUDED
-void gpgpusim_cuda_vprintf(const class ptx_instruction * pI, const class ptx_thread_info * thread, const class function_info * target_func );
+void gpgpusim_cuda_vprintf(const class ptx_instruction * pI, class ptx_thread_info * thread, const class function_info * target_func );
#endif
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index 23d6cc8..335ea59 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -249,7 +249,7 @@ ptx_reg_t ptx_thread_info::get_operand_value( const operand_info &op, operand_in
//complete other cases for reading from memory, such as reading from other const memory
if((op.get_addr_space() == 1)&&(derefFlag)) {
// global memory - g[4], g[$r0]
- mem = g_global_mem;
+ mem = thread->get_global_memory();
type_info_key::type_decode(opType,size,t);
mem->read(result.u32,size/8,&finalResult.u128);
thread->m_last_effective_address = result.u32;
@@ -269,7 +269,7 @@ ptx_reg_t ptx_thread_info::get_operand_value( const operand_info &op, operand_in
sign_extend(finalResult,size,dstInfo);
} else if((op.get_addr_space() == 3)&&(derefFlag)) {
// const memory - ce0c1[4], ce0c1[$r0]
- mem = g_global_mem;
+ mem = thread->get_global_memory();
type_info_key::type_decode(opType,size,t);
mem->read((result.u32 + op.get_const_mem_offset()),size/8,&finalResult.u128);
thread->m_last_effective_address = result.u32;
@@ -606,7 +606,7 @@ void ptx_thread_info::set_operand_value( const operand_info &dst, const ptx_reg_
else if(dst.get_addr_space() == 1)
{
dstData = thread->get_operand_value(dst, dst, type, thread, 0);
- mem = g_global_mem;
+ mem = thread->get_global_memory();
type_info_key::type_decode(type,size,t);
mem->write(dstData.u32,size/8,&data.u128,thread,pI);
@@ -863,7 +863,7 @@ void atom_callback( const inst_t* inst, ptx_thread_info* thread )
// Copy value pointed to in operand 'a' into register 'd'
// (i.e. copy src1_data to dst)
- g_global_mem->read(src1_data.u32,size/8,&data.s64);
+ thread->get_global_memory()->read(src1_data.u32,size/8,&data.s64);
thread->set_operand_value(dst, data, to_type, thread, pI); // Write value into register 'd'
// Get the atomic operation to be performed
@@ -1086,7 +1086,7 @@ void atom_callback( const inst_t* inst, ptx_thread_info* thread )
// Write operation result into global memory
// (i.e. copy src1_data to dst)
- g_global_mem->write(src1_data.u32,size/8,&op_result.s64,thread,pI);
+ thread->get_global_memory()->write(src1_data.u32,size/8,&op_result.s64,thread,pI);
gpgpu_sim *gpu = thread->get_gpu();
gpu->decrement_atomic_count(thread->get_hw_sid(),thread->get_hw_wid());
}
@@ -1998,7 +1998,7 @@ void isspacep_impl( const ptx_instruction *pI, ptx_thread_info *thread )
thread->set_reg(dst.get_symbol(),p);
}
-void decode_space( memory_space_t &space, const ptx_thread_info *thread, const operand_info &op, memory_space *&mem, addr_t &addr)
+void decode_space( memory_space_t &space, ptx_thread_info *thread, const operand_info &op, memory_space *&mem, addr_t &addr)
{
unsigned smid = thread->get_hw_sid();
unsigned hwtid = thread->get_hw_tid();
@@ -2018,23 +2018,23 @@ void decode_space( memory_space_t &space, const ptx_thread_info *thread, const o
}
}
switch ( space.get_type() ) {
- case global_space: mem = g_global_mem; break;
+ case global_space: mem = thread->get_global_memory(); break;
case param_space_local:
case local_space:
mem = thread->m_local_mem;
addr += thread->get_local_mem_stack_pointer();
break;
- case tex_space: mem = g_tex_mem; break;
- case surf_space: mem = g_surf_mem; break;
- case param_space_kernel: mem = g_param_mem; break;
+ case tex_space: mem = thread->get_tex_memory(); break;
+ case surf_space: mem = thread->get_surf_memory(); break;
+ case param_space_kernel: mem = thread->get_param_memory(); break;
case shared_space: mem = thread->m_shared_mem; break;
- case const_space: mem = g_global_mem; break;
+ case const_space: mem = thread->get_global_memory(); break;
case generic_space:
if( thread->get_ptx_version().ver() >= 2.0 ) {
// convert generic address to memory space address
space = whichspace(addr);
switch ( space.get_type() ) {
- case global_space: mem = g_global_mem; addr = generic_to_global(addr); break;
+ case global_space: mem = thread->get_global_memory(); addr = generic_to_global(addr); break;
case local_space: mem = thread->m_local_mem; addr = generic_to_local(smid,hwtid,addr); break;
case shared_space: mem = thread->m_shared_mem; addr = generic_to_shared(smid,addr); break;
default: abort();
@@ -3555,7 +3555,7 @@ void tex_impl( const ptx_instruction *pI, ptx_thread_info *thread )
//assume always 2D f32 input
//access array with src2 coordinates
- memory_space *mem = g_global_mem;
+ memory_space *mem = thread->get_global_memory();
float x_f32, y_f32;
size_t size;
int t;
@@ -3799,12 +3799,10 @@ void vote_impl( const ptx_instruction *pI, ptx_thread_info *thread )
threads_in_warp.clear();
and_all = true;
or_all = false;
- unsigned mask=0x80000000;
- unsigned offset=31;
- while( mask && !pI->active(mask) ) {
- mask = mask>>1;
+ int offset=31;
+ while( (offset>=0) && !pI->active(offset) )
offset--;
- }
+ assert( offset >= 0 );
last_tid = (thread->get_hw_tid() - (thread->get_hw_tid()%pI->warp_size())) + offset;
}
@@ -3883,7 +3881,7 @@ ptx_reg_t srcOperandModifiers(ptx_reg_t opData, operand_info opInfo, operand_inf
//complete other cases for reading from memory, such as reading from other const memory
if(opInfo.get_addr_space() == 1)
{
- mem = g_global_mem;
+ mem = thread->get_global_memory();
type_info_key::type_decode(type,size,t);
mem->read(opData.u32,size/8,&result.u64);
if( type == S16_TYPE || type == S32_TYPE )
@@ -3901,7 +3899,7 @@ ptx_reg_t srcOperandModifiers(ptx_reg_t opData, operand_info opInfo, operand_inf
}
else if(opInfo.get_addr_space() == 3)
{
- mem = g_global_mem;
+ mem = thread->get_global_memory();
type_info_key::type_decode(type,size,t);
mem->read((opData.u32 + opInfo.get_const_mem_offset()),size/8,&result.u64);
diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc
index b7ec3ac..8172f80 100644
--- a/src/cuda-sim/ptx_ir.cc
+++ b/src/cuda-sim/ptx_ir.cc
@@ -1162,7 +1162,7 @@ void ptx_instruction::print_insn( FILE *fp ) const
snprintf(buf,1024,"%s", m_source.c_str());
p = strtok(buf,";");
if( !is_label() )
- fprintf(fp," PC=%3u [%3u] ", m_PC, m_instr_mem_index );
+ fprintf(fp," PC=0x%03x ", m_PC );
else
fprintf(fp," " );
fprintf(fp,"(%s:%u) %s", m_source_file.c_str(), m_source_line, p );
diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h
index 6010caf..612326c 100644
--- a/src/cuda-sim/ptx_ir.h
+++ b/src/cuda-sim/ptx_ir.h
@@ -803,7 +803,6 @@ public:
const char *source,
unsigned warp_size );
-
void print_insn() const;
virtual void print_insn( FILE *fp ) const;
unsigned inst_size() const { return m_inst_size; }
@@ -1404,20 +1403,6 @@ struct textureInfo {
extern std::map<std::string,symbol_table*> g_sym_name_to_symbol_table;
-#define GLOBAL_HEAP_START 0x80000000
- // start allocating from this address (lower values used for allocating globals in .ptx file)
-#define SHARED_MEM_SIZE_MAX (64*1024)
-#define LOCAL_MEM_SIZE_MAX (16*1024)
-#define MAX_STREAMING_MULTIPROCESSORS 64
-#define MAX_THREAD_PER_SM 1024
-#define TOTAL_LOCAL_MEM_PER_SM (MAX_THREAD_PER_SM*LOCAL_MEM_SIZE_MAX)
-#define TOTAL_SHARED_MEM (MAX_STREAMING_MULTIPROCESSORS*SHARED_MEM_SIZE_MAX)
-#define TOTAL_LOCAL_MEM (MAX_STREAMING_MULTIPROCESSORS*MAX_THREAD_PER_SM*LOCAL_MEM_SIZE_MAX)
-#define SHARED_GENERIC_START (GLOBAL_HEAP_START-TOTAL_SHARED_MEM)
-#define LOCAL_GENERIC_START (SHARED_GENERIC_START-TOTAL_LOCAL_MEM)
-#define STATIC_ALLOC_LIMIT (GLOBAL_HEAP_START - (TOTAL_LOCAL_MEM+TOTAL_SHARED_MEM))
-
-
extern bool g_keep_intermediate_files;
diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc
index d4f3822..2387528 100644
--- a/src/cuda-sim/ptx_loader.cc
+++ b/src/cuda-sim/ptx_loader.cc
@@ -87,9 +87,6 @@ extern "C" int ptxinfo_parse();
extern "C" int ptxinfo_debug;
extern "C" FILE *ptxinfo_in;
-extern int g_ptx_save_converted_ptxplus;
-
-
static bool g_save_embedded_ptx;
bool g_keep_intermediate_files;
@@ -129,7 +126,7 @@ void print_ptx_file( const char *p, unsigned source_num, const char *filename )
fflush(stdout);
}
-char* gpgpu_ptx_sim_convert_ptx_to_ptxplus(const char *ptx_str, const char *cubin_str, unsigned source_num)
+char* gpgpu_ptx_sim_convert_ptx_to_ptxplus(const char *ptx_str, const char *cubin_str, unsigned source_num, bool save_converted )
{
printf("GPGPU-Sim PTX: converting EMBEDDED .ptx file to ptxplus \n");
@@ -201,7 +198,7 @@ char* gpgpu_ptx_sim_convert_ptx_to_ptxplus(const char *ptx_str, const char *cubi
strcpy(ptxplus_str, text.c_str());
// Save ptxplus to file if specified
- if(g_ptx_save_converted_ptxplus) {
+ if(save_converted) {
char fname_ptxplus_save[1024];
snprintf(fname_ptxplus_save,1024,"_%u.ptxplus", source_num );
printf("GPGPU-Sim PTX: saving converted ptxplus to file \"%s\"\n", fname_ptxplus_save);
@@ -224,11 +221,10 @@ char* gpgpu_ptx_sim_convert_ptx_to_ptxplus(const char *ptx_str, const char *cubi
printf("GPGPU-Sim PTX: DONE converting EMBEDDED .ptx file to ptxplus \n");
return ptxplus_str;
-
}
-symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, const char *p_for_info, unsigned source_num )
+symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source_num )
{
char buf[1024];
snprintf(buf,1024,"_%u.ptx", source_num );
@@ -242,7 +238,7 @@ symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, const char *p_f
int errors = ptx_parse ();
if ( errors ) {
char fname[1024];
- snprintf(fname,1024,"_ptx_XXXXXX");
+ snprintf(fname,1024,"_ptx_errors_XXXXXX");
int fd=mkstemp(fname);
close(fd);
printf("GPGPU-Sim PTX: parser error detected, exiting... but first extracting .ptx to \"%s\"\n", fname);
@@ -257,7 +253,11 @@ symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, const char *p_f
print_ptx_file(p,source_num,buf);
printf("GPGPU-Sim PTX: finished parsing EMBEDDED .ptx file %s\n",buf);
+ return symtab;
+}
+void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num )
+{
char fname[1024];
snprintf(fname,1024,"_ptx_XXXXXX");
int fd=mkstemp(fname);
@@ -287,9 +287,11 @@ symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, const char *p_f
char commandline[1024];
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);
@@ -310,6 +312,5 @@ symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, const char *p_f
printf("GPGPU-Sim PTX: ERROR ** while loading PTX (c) %d\n", result);
exit(1);
}
- return symtab;
}
diff --git a/src/cuda-sim/ptx_loader.h b/src/cuda-sim/ptx_loader.h
index e9efd9b..da0d10e 100644
--- a/src/cuda-sim/ptx_loader.h
+++ b/src/cuda-sim/ptx_loader.h
@@ -66,15 +66,10 @@
#ifndef PTX_LOADER_H_INCLUDED
#define PTX_LOADER_H_INCLUDED
-class memory_space;
-
-extern memory_space *g_global_mem;
-extern memory_space *g_tex_mem;
-extern memory_space *g_surf_mem;
-extern memory_space *g_param_mem;
extern bool g_override_embedded_ptx;
-class symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, const char *p_for_info, unsigned source_num );
-char* gpgpu_ptx_sim_convert_ptx_to_ptxplus(const char *ptx_str, const char *cubin_str, unsigned source_num);
+class symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source_num );
+void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num );
+char* gpgpu_ptx_sim_convert_ptx_to_ptxplus(const char *ptx_str, const char *cubin_str, unsigned source_num, bool save_converted );
#endif
diff --git a/src/cuda-sim/ptx_sim.cc b/src/cuda-sim/ptx_sim.cc
index 2cd0ba6..59f4522 100644
--- a/src/cuda-sim/ptx_sim.cc
+++ b/src/cuda-sim/ptx_sim.cc
@@ -245,6 +245,7 @@ ptx_thread_info::ptx_thread_info()
m_last_was_call = false;
m_enable_debug_trace = false;
m_local_mem_stack_pointer = 0;
+ m_gpu = NULL;
}
const ptx_version &ptx_thread_info::get_ptx_version() const
diff --git a/src/cuda-sim/ptx_sim.h b/src/cuda-sim/ptx_sim.h
index 80ccde3..298122e 100644
--- a/src/cuda-sim/ptx_sim.h
+++ b/src/cuda-sim/ptx_sim.h
@@ -276,6 +276,16 @@ public:
~ptx_thread_info();
ptx_thread_info();
+ void init(gpgpu_t *gpu, core_t *core, unsigned sid, unsigned cta_id, unsigned wid, unsigned tid )
+ {
+ m_gpu = gpu;
+ m_core = core;
+ m_hw_sid=sid;
+ m_hw_ctaid=cta_id;
+ m_hw_wid=wid;
+ m_hw_tid=tid;
+ }
+
void ptx_fetch_inst( inst_t &inst ) const;
void ptx_exec_inst( warp_inst_t &inst, unsigned lane_id );
@@ -310,11 +320,6 @@ public:
unsigned get_hw_ctaid() const { return m_hw_ctaid;}
unsigned get_hw_wid() const { return m_hw_wid;}
unsigned get_hw_sid() const { return m_hw_sid;}
- void set_hw_tid(unsigned tid) { m_hw_tid=tid;}
- void set_hw_wid(unsigned wid) { m_hw_wid=wid;}
- void set_hw_sid(unsigned sid) { m_hw_sid=sid;}
- void set_hw_ctaid(unsigned cta_id) { m_hw_ctaid=cta_id;}
- void set_core(core_t *core) { m_core = core; }
core_t *get_core() { return m_core; }
unsigned get_icount() const { return m_icount;}
@@ -421,6 +426,11 @@ public:
void enable_debug_trace() { m_enable_debug_trace = true; }
unsigned get_local_mem_stack_pointer() const { return m_local_mem_stack_pointer; }
+ memory_space *get_global_memory() { return m_gpu->get_global_memory(); }
+ memory_space *get_tex_memory() { return m_gpu->get_tex_memory(); }
+ memory_space *get_surf_memory() { return m_gpu->get_surf_memory(); }
+ memory_space *get_param_memory() { return m_gpu->get_param_memory(); }
+
public:
addr_t m_last_effective_address;
bool m_branch_taken;
@@ -436,6 +446,7 @@ private:
unsigned m_uid;
core_t *m_core;
+ gpgpu_t *m_gpu;
bool m_valid;
dim3 m_ntid;
dim3 m_tid;