summaryrefslogtreecommitdiff
path: root/src/cuda-sim
diff options
context:
space:
mode:
authorTor Aamodt <[email protected]>2010-12-28 17:25:52 -0800
committerTor Aamodt <[email protected]>2010-12-28 17:25:52 -0800
commit47afff48be8f59c6cfcb86eded3a337b63130b18 (patch)
tree5cc3510b8712c5846741a370c73d0db6dfdd8693 /src/cuda-sim
parente7b3dd442fceb30eaa8008d97429a1d33dad2044 (diff)
- parameter memory and active threads now part of kernel_info_t:
Parameters are finalized at kernel launch, which means the contents of parameter memory are initialized. Kernel arguement names have a fixed order, hence same address should be assigned on subsequent kernel launches of same kernel in other streams provided the data size param_t::size of arguments for each kernel launch is identical (an assertion has been added to check this is true). - passing regression [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 8303]
Diffstat (limited to 'src/cuda-sim')
-rw-r--r--src/cuda-sim/cuda-sim.cc18
-rw-r--r--src/cuda-sim/cuda-sim.h4
-rw-r--r--src/cuda-sim/ptx_sim.cc3
-rw-r--r--src/cuda-sim/ptx_sim.h5
4 files changed, 17 insertions, 13 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index b6a15e8..e33181f 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -1075,7 +1075,8 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
unsigned hw_warp_id,
gpgpu_t *gpu )
{
- static std::list<ptx_thread_info *> active_threads;
+ std::list<ptx_thread_info *> &active_threads = kernel.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;
@@ -1096,7 +1097,7 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
*thread_info = NULL;
}
- if ( !active_threads.empty() ) { //if g_active_threads not empty...
+ if ( !active_threads.empty() ) {
assert( active_threads.size() <= threads_left );
ptx_thread_info *thd = active_threads.front();
active_threads.pop_front();
@@ -1156,7 +1157,7 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
dim3 tid3d = kernel.get_next_thread_id_3d();
kernel.increment_thread_id();
new_tid += tid;
- ptx_thread_info *thd = new ptx_thread_info();
+ ptx_thread_info *thd = new ptx_thread_info(kernel);
memory_space *local_mem = NULL;
std::map<unsigned,memory_space*>::iterator l = local_mem_lookup.find(new_tid);
@@ -1210,23 +1211,24 @@ size_t get_kernel_code_size( class function_info *entry )
}
-kernel_info_t gpgpu_opencl_ptx_sim_init_grid(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,
gpgpu_t *gpu )
{
+ kernel_info_t *result = new kernel_info_t(gridDim,blockDim,entry);
unsigned argcount=args.size();
unsigned argn=1;
for( gpgpu_ptx_sim_arg_list_t::iterator a = args.begin(); a != args.end(); a++ ) {
entry->add_param_data(argcount-argn,&(*a));
argn++;
}
- entry->finalize(gpu->get_param_memory());
+ entry->finalize(result->get_param_memory());
g_ptx_kernel_count++;
fflush(stdout);
- return kernel_info_t(gridDim,blockDim,entry);
+ return result;
}
const char *g_gpgpusim_version_string = "2.1.1b (beta)";
@@ -1395,7 +1397,7 @@ ptx_cta_info *g_func_cta_info = NULL;
#define MAX(a,b) (((a)>(b))?(a):(b))
-void gpgpu_cuda_ptx_sim_main_func( kernel_info_t kernel )
+void gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel )
{
printf("GPGPU-Sim: Performing Functional Simulation...\n");
@@ -1416,7 +1418,7 @@ void gpgpu_cuda_ptx_sim_main_func( kernel_info_t kernel )
g_func_cta_info->check_cta_thread_status_and_reset();
while( kernel.more_threads_in_cta() ) {
memory_space *local_mem = NULL;
- ptx_thread_info *thd = new ptx_thread_info();
+ ptx_thread_info *thd = new ptx_thread_info(kernel);
dim3 tid3d = kernel.get_next_thread_id_3d();
unsigned lm_idx = kernel.get_next_thread_id();
kernel.increment_thread_id();
diff --git a/src/cuda-sim/cuda-sim.h b/src/cuda-sim/cuda-sim.h
index ef045fb..3bc915d 100644
--- a/src/cuda-sim/cuda-sim.h
+++ b/src/cuda-sim/cuda-sim.h
@@ -20,12 +20,12 @@ extern void ** g_inst_op_classification_stat;
extern int g_ptx_kernel_count; // used for classification stat collection purposes
-extern class kernel_info_t gpgpu_opencl_ptx_sim_init_grid(class function_info *entry,
+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,
class gpgpu_t *gpu );
-extern void gpgpu_cuda_ptx_sim_main_func( kernel_info_t kernel );
+extern void gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel );
extern void print_splash();
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 );
diff --git a/src/cuda-sim/ptx_sim.cc b/src/cuda-sim/ptx_sim.cc
index 59f4522..3ab0594 100644
--- a/src/cuda-sim/ptx_sim.cc
+++ b/src/cuda-sim/ptx_sim.cc
@@ -211,7 +211,8 @@ ptx_thread_info::~ptx_thread_info()
g_ptx_thread_info_delete_count++;
}
-ptx_thread_info::ptx_thread_info()
+ptx_thread_info::ptx_thread_info( kernel_info_t &kernel )
+ : m_kernel(kernel)
{
m_uid = g_ptx_thread_info_uid_next++;
m_core = NULL;
diff --git a/src/cuda-sim/ptx_sim.h b/src/cuda-sim/ptx_sim.h
index d60955b..cc555cf 100644
--- a/src/cuda-sim/ptx_sim.h
+++ b/src/cuda-sim/ptx_sim.h
@@ -274,7 +274,7 @@ private:
class ptx_thread_info {
public:
~ptx_thread_info();
- ptx_thread_info();
+ ptx_thread_info( kernel_info_t &kernel );
void init(gpgpu_t *gpu, core_t *core, unsigned sid, unsigned cta_id, unsigned wid, unsigned tid )
{
@@ -429,7 +429,7 @@ public:
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(); }
+ memory_space *get_param_memory() { return m_kernel.get_param_memory(); }
const gpgpu_functional_sim_config &get_config() const { return m_gpu->get_config(); }
public:
@@ -446,6 +446,7 @@ private:
unsigned m_uid;
+ kernel_info_t &m_kernel;
core_t *m_core;
gpgpu_t *m_gpu;
bool m_valid;