summaryrefslogtreecommitdiff
path: root/src/cuda-sim
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuda-sim')
-rw-r--r--src/cuda-sim/cuda-sim.cc6
-rw-r--r--src/cuda-sim/cuda-sim.h10
-rw-r--r--src/cuda-sim/cuda_device_runtime.cc7
-rw-r--r--src/cuda-sim/cuda_device_runtime.h18
4 files changed, 29 insertions, 12 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index b3e2965..7a7d205 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -2033,13 +2033,11 @@ void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t co
fflush(stdout);
}
-int g_ptx_sim_mode; // if non-zero run functional simulation only (i.e., no notion of a clock cycle)
-
extern int ptx_debug;
bool g_cuda_launch_blocking = false;
-void read_sim_environment_variables()
+void cuda_sim::read_sim_environment_variables()
{
ptx_debug = 0;
g_debug_execution = 0;
@@ -2185,7 +2183,7 @@ void cuda_sim::gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel, bool openCL
cta.execute(cp_count,temp);
#if (CUDART_VERSION >= 5000)
- launch_all_device_kernels();
+ gpgpu_ctx->device_runtime->launch_all_device_kernels();
#endif
}
else
diff --git a/src/cuda-sim/cuda-sim.h b/src/cuda-sim/cuda-sim.h
index 25ebf7b..3c4336d 100644
--- a/src/cuda-sim/cuda-sim.h
+++ b/src/cuda-sim/cuda-sim.h
@@ -36,12 +36,12 @@
#include <string>
#include"ptx_sim.h"
+class gpgpu_context;
class memory_space;
class function_info;
class symbol_table;
extern const char *g_gpgpusim_version_string;
-extern int g_ptx_sim_mode;
extern int g_debug_execution;
extern int g_debug_thread_uid;
extern void ** g_inst_classification_stat;
@@ -50,7 +50,6 @@ extern void ** g_inst_op_classification_stat;
extern void print_splash();
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 read_sim_environment_variables();
extern void ptxinfo_opencl_addinfo( std::map<std::string,function_info*> &kernels );
unsigned ptx_sim_init_thread( kernel_info_t &kernel,
class ptx_thread_info** thread_info,
@@ -124,9 +123,10 @@ struct gpgpu_ptx_sim_info get_ptxinfo();
class cuda_sim {
public:
- cuda_sim() {
+ cuda_sim( gpgpu_context* ctx ) {
g_ptx_sim_num_insn = 0;
g_ptx_kernel_count = -1; // used for classification stat collection purposes
+ gpgpu_ctx = ctx;
}
//global variables
char *opcode_latency_int;
@@ -147,6 +147,9 @@ class cuda_sim {
int g_ptx_kernel_count; // used for classification stat collection purposes
std::map<const void*,std::string> g_global_name_lookup; // indexed by hostVar
std::map<const void*,std::string> g_const_name_lookup; // indexed by hostVar
+ int g_ptx_sim_mode; // if non-zero run functional simulation only (i.e., no notion of a clock cycle)
+ // backward pointer
+ class gpgpu_context* gpgpu_ctx;
//global functions
void ptx_opcocde_latency_options (option_parser_t opp);
void gpgpu_cuda_ptx_sim_main_func( kernel_info_t &kernel, bool openCL = false );
@@ -159,6 +162,7 @@ class cuda_sim {
gpgpu_t *gpu );
void gpgpu_ptx_sim_register_global_variable(void *hostVar, const char *deviceName, size_t size );
void gpgpu_ptx_sim_register_const_variable(void*, const char *deviceName, size_t size );
+ void read_sim_environment_variables();
};
#endif
diff --git a/src/cuda-sim/cuda_device_runtime.cc b/src/cuda-sim/cuda_device_runtime.cc
index be8369f..354fa79 100644
--- a/src/cuda-sim/cuda_device_runtime.cc
+++ b/src/cuda-sim/cuda_device_runtime.cc
@@ -20,6 +20,7 @@ unsigned long long g_max_total_param_size = 0;
#include "../stream_manager.h"
#include "../gpgpusim_entrypoint.h"
#include "cuda_device_runtime.h"
+#include "../../libcuda/gpgpu_context.h"
#define DEV_RUNTIME_REPORT(a) \
if( g_debug_execution ) { \
@@ -318,17 +319,17 @@ void gpgpusim_cuda_streamCreateWithFlags(const ptx_instruction * pI, ptx_thread_
}
-void launch_one_device_kernel() {
+void cuda_device_runtime::launch_one_device_kernel() {
if(!g_cuda_device_launch_op.empty()) {
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);
+ stream_operation stream_op = stream_operation(op.grid, gpgpu_ctx->func_sim->g_ptx_sim_mode, op.stream);
g_stream_manager()->push(stream_op);
g_cuda_device_launch_op.pop_front();
}
}
-void launch_all_device_kernels() {
+void cuda_device_runtime::launch_all_device_kernels() {
while(!g_cuda_device_launch_op.empty()) {
launch_one_device_kernel();
}
diff --git a/src/cuda-sim/cuda_device_runtime.h b/src/cuda-sim/cuda_device_runtime.h
index 6dbcd71..851fed2 100644
--- a/src/cuda-sim/cuda_device_runtime.h
+++ b/src/cuda-sim/cuda_device_runtime.h
@@ -6,6 +6,20 @@
void gpgpusim_cuda_getParameterBufferV2(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func);
void gpgpusim_cuda_launchDeviceV2(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func);
void gpgpusim_cuda_streamCreateWithFlags(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func);
-void launch_all_device_kernels();
-void launch_one_device_kernel();
+#endif
+#if (CUDART_VERSION >= 5000)
+
+class gpgpu_context;
+
+class cuda_device_runtime {
+ public:
+ cuda_device_runtime( gpgpu_context* ctx ) {
+ gpgpu_ctx = ctx;
+ }
+ // backward pointer
+ class gpgpu_context* gpgpu_ctx;
+ void launch_all_device_kernels();
+ void launch_one_device_kernel();
+};
+
#endif