summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMahmoud <[email protected]>2019-05-30 18:28:15 -0400
committerMahmoud <[email protected]>2019-05-30 18:28:15 -0400
commited9f0e6b2a99840e9649551825a40a04e236dcd9 (patch)
tree1840987c3e43edd75df14892fb1977e0d114275b /src
parent876504e46d942a851a26792b395e307e2849c16e (diff)
adding new values to gpu context
Diffstat (limited to 'src')
-rw-r--r--src/abstract_hardware_model.cc9
-rw-r--r--src/abstract_hardware_model.h2
-rw-r--r--src/cuda-sim/cuda-sim.cc36
-rw-r--r--src/cuda-sim/cuda_device_runtime.cc5
-rw-r--r--src/gpgpusim_entrypoint.cc12
-rw-r--r--src/gpgpusim_entrypoint.h24
6 files changed, 56 insertions, 32 deletions
diff --git a/src/abstract_hardware_model.cc b/src/abstract_hardware_model.cc
index 63b139e..7755477 100644
--- a/src/abstract_hardware_model.cc
+++ b/src/abstract_hardware_model.cc
@@ -34,6 +34,7 @@
#include "cuda-sim/cuda-sim.h"
#include "gpgpu-sim/gpu-sim.h"
#include "option_parser.h"
+#include "gpgpusim_entrypoint.h"
#include <algorithm>
#include <sys/stat.h>
#include <sstream>
@@ -771,14 +772,14 @@ void kernel_info_t::notify_parent_finished() {
extern unsigned long long g_total_param_size;
g_total_param_size -= ((m_kernel_entry->get_args_aligned_size() + 255)/256*256);
m_parent_kernel->remove_child(this);
- g_stream_manager->register_finished_kernel(m_parent_kernel->get_uid());
+ g_stream_manager()->register_finished_kernel(m_parent_kernel->get_uid());
}
}
CUstream_st * kernel_info_t::create_stream_cta(dim3 ctaid) {
assert(get_default_stream_cta(ctaid));
CUstream_st * stream = new CUstream_st();
- g_stream_manager->add_stream(stream);
+ g_stream_manager()->add_stream(stream);
assert(m_cta_streams.find(ctaid) != m_cta_streams.end());
assert(m_cta_streams[ctaid].size() >= 1); //must have default stream
m_cta_streams[ctaid].push_back(stream);
@@ -794,7 +795,7 @@ CUstream_st * kernel_info_t::get_default_stream_cta(dim3 ctaid) {
else {
m_cta_streams[ctaid] = std::list<CUstream_st *>();
CUstream_st * stream = new CUstream_st();
- g_stream_manager->add_stream(stream);
+ g_stream_manager()->add_stream(stream);
m_cta_streams[ctaid].push_back(stream);
return stream;
}
@@ -826,7 +827,7 @@ void kernel_info_t::destroy_cta_streams() {
for(auto s = m_cta_streams.begin(); s != m_cta_streams.end(); s++) {
stream_size += s->second.size();
for(auto ss = s->second.begin(); ss != s->second.end(); ss++)
- g_stream_manager->destroy_stream(*ss);
+ g_stream_manager()->destroy_stream(*ss);
s->second.clear();
}
printf("size %lu\n", stream_size);
diff --git a/src/abstract_hardware_model.h b/src/abstract_hardware_model.h
index 1735c2f..77d5f58 100644
--- a/src/abstract_hardware_model.h
+++ b/src/abstract_hardware_model.h
@@ -197,7 +197,7 @@ void increment_x_then_y_then_z( dim3 &i, const dim3 &bound);
#include "stream_manager.h"
class stream_manager;
struct CUstream_st;
-extern stream_manager * g_stream_manager;
+//extern stream_manager * g_stream_manager;
//support for pinned memories added
extern std::map<void *,void **> pinned_memory;
extern std::map<void *, size_t> pinned_memory_size;
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index e733b7f..a456978 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -448,8 +448,8 @@ void gpgpu_t::memcpy_to_gpu( size_t dst_start_addr, const void *src, size_t coun
m_global_mem->write(dst_start_addr+n,1, src_data+n,NULL,NULL);
// Copy into the performance model.
- extern gpgpu_sim* g_the_gpu;
- g_the_gpu->perf_memcpy_to_gpu(dst_start_addr, count);
+ //extern gpgpu_sim* g_the_gpu;
+ g_the_gpu()->perf_memcpy_to_gpu(dst_start_addr, count);
if(g_debug_execution >= 3) {
printf( " done.\n");
fflush(stdout);
@@ -467,8 +467,8 @@ void gpgpu_t::memcpy_from_gpu( void *dst, size_t src_start_addr, size_t count )
m_global_mem->read(src_start_addr+n,1,dst_data+n);
// Copy into the performance model.
- extern gpgpu_sim* g_the_gpu;
- g_the_gpu->perf_memcpy_to_gpu(src_start_addr, count);
+ //extern gpgpu_sim* g_the_gpu;
+ g_the_gpu()->perf_memcpy_to_gpu(src_start_addr, count);
if(g_debug_execution >= 3) {
printf( " done.\n");
fflush(stdout);
@@ -1270,8 +1270,8 @@ void function_info::finalize( memory_space *param_mem )
void function_info::param_to_shared( memory_space *shared_mem, symbol_table *symtab )
{
// 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;
+ //extern gpgpu_sim* g_the_gpu;
+ if (not 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++ ) {
@@ -2150,7 +2150,7 @@ void gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel, bool openCL )
printf("GPGPU-Sim: Performing Functional Simulation, executing kernel %s...\n",kernel.name().c_str());
//using a shader core object for book keeping, it is not needed but as most function built for performance simulation need it we use it here
- extern gpgpu_sim *g_the_gpu;
+ //extern gpgpu_sim *g_the_gpu;
//before we execute, we should do PDOM analysis for functional simulation scenario.
function_info *kernel_func_info = kernel.entry();
const struct gpgpu_ptx_sim_info *kernel_info = ptx_sim_kernel_info(kernel_func_info);
@@ -2165,7 +2165,7 @@ void 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(), 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);
printf("Max CTA : %d\n",max_cta_tot);
@@ -2173,11 +2173,11 @@ void gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel, bool openCL )
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= 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 cta_launched =0;
//we excute the kernel one CTA (Block) at the time, as synchronization functions work block wise
@@ -2189,8 +2189,8 @@ void gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel, bool openCL )
{
functionalCoreSim cta(
&kernel,
- g_the_gpu,
- g_the_gpu->getShaderCoreConfig()->warp_size
+ g_the_gpu(),
+ g_the_gpu()->getShaderCoreConfig()->warp_size
);
cta.execute(cp_count,temp);
@@ -2211,7 +2211,7 @@ void 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(g_the_gpu()->get_global_memory(), f1name , "%08x");
}
@@ -2221,8 +2221,8 @@ void 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());
+ //extern stream_manager *g_stream_manager;
+ g_stream_manager()->register_finished_kernel(kernel.get_uid());
}
//******PRINTING*******
diff --git a/src/cuda-sim/cuda_device_runtime.cc b/src/cuda-sim/cuda_device_runtime.cc
index 86e8147..be8369f 100644
--- a/src/cuda-sim/cuda_device_runtime.cc
+++ b/src/cuda-sim/cuda_device_runtime.cc
@@ -18,6 +18,7 @@ unsigned long long g_max_total_param_size = 0;
#include "cuda-sim.h"
#include "ptx_ir.h"
#include "../stream_manager.h"
+#include "../gpgpusim_entrypoint.h"
#include "cuda_device_runtime.h"
#define DEV_RUNTIME_REPORT(a) \
@@ -64,7 +65,7 @@ public:
std::map<void *, device_launch_config_t> g_cuda_device_launch_param_map;
std::list<device_launch_operation_t> g_cuda_device_launch_op;
-extern stream_manager *g_stream_manager;
+//extern stream_manager *g_stream_manager();
//Handling device runtime api:
//void * cudaGetParameterBufferV2(void *func, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize)
@@ -322,7 +323,7 @@ void launch_one_device_kernel() {
device_launch_operation_t &op = g_cuda_device_launch_op.front();
stream_operation stream_op = stream_operation(op.grid, g_ptx_sim_mode, op.stream);
- g_stream_manager->push(stream_op);
+ g_stream_manager()->push(stream_op);
g_cuda_device_launch_op.pop_front();
}
}
diff --git a/src/gpgpusim_entrypoint.cc b/src/gpgpusim_entrypoint.cc
index c8770e2..de937b0 100644
--- a/src/gpgpusim_entrypoint.cc
+++ b/src/gpgpusim_entrypoint.cc
@@ -41,8 +41,6 @@
struct GPGPUsim_ctx* the_gpgpusim = NULL;
-static void print_simulation_time();
-
struct GPGPUsim_ctx* GPGPUsim_ctx_ptr(){
if(the_gpgpusim == NULL)
the_gpgpusim = new GPGPUsim_ctx();
@@ -50,6 +48,16 @@ struct GPGPUsim_ctx* GPGPUsim_ctx_ptr(){
return the_gpgpusim;
}
+class gpgpu_sim* g_the_gpu() {
+ return GPGPUsim_ctx_ptr()->g_the_gpu;
+}
+
+class stream_manager* g_stream_manager() {
+ return GPGPUsim_ctx_ptr()->g_stream_manager;
+}
+
+static void print_simulation_time();
+
void *gpgpu_sim_thread_sequential(void*)
{
// at most one kernel running at a time
diff --git a/src/gpgpusim_entrypoint.h b/src/gpgpusim_entrypoint.h
index e29159b..2ad0fdf 100644
--- a/src/gpgpusim_entrypoint.h
+++ b/src/gpgpusim_entrypoint.h
@@ -46,9 +46,15 @@ struct GPGPUsim_ctx {
sg_argc = 3;
sg_argv = {"", "-config","gpgpusim.config"};
+
+ g_the_gpu_config=NULL;
+ g_the_gpu=NULL;
+ g_stream_manager=NULL;
+ the_cude_device=NULL;
+ the_context=NULL;
}
- struct gpgpu_ptx_sim_arg *grid_params;
+ //struct gpgpu_ptx_sim_arg *grid_params;
sem_t g_sim_signal_start;
sem_t g_sim_signal_finish;
@@ -60,19 +66,27 @@ struct GPGPUsim_ctx {
class gpgpu_sim *g_the_gpu;
class stream_manager *g_stream_manager;
+ struct _cuda_device_id *the_cude_device;
+ struct CUctx_st* the_context;
+
+
int sg_argc;
const char *sg_argv[3];
- pthread_mutex_t g_sim_lock;
- bool g_sim_active;
- bool g_sim_done;
- bool break_limit;
+ pthread_mutex_t g_sim_lock;
+ bool g_sim_active;
+ bool g_sim_done;
+ bool break_limit;
};
class gpgpu_sim *gpgpu_ptx_sim_init_perf();
void start_sim_thread(int api);
+class gpgpu_sim* g_the_gpu();
+struct GPGPUsim_ctx* GPGPUsim_ctx_ptr();
+class stream_manager* g_stream_manager();
+
int gpgpu_opencl_ptx_sim_main_perf( kernel_info_t *grid );
int gpgpu_opencl_ptx_sim_main_func( kernel_info_t *grid );