From 4d4d5938d715d2b79a617c32583184426b4a642d Mon Sep 17 00:00:00 2001 From: Mengchi Zhang Date: Tue, 9 Jul 2019 23:16:17 -0400 Subject: Move g_ptx_sim_mode Signed-off-by: Mengchi Zhang --- src/cuda-sim/cuda_device_runtime.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/cuda-sim/cuda_device_runtime.h') 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 -- cgit v1.3 From 8019833f6c9d9552c70739dc2bf45e53655666ec Mon Sep 17 00:00:00 2001 From: Mengchi Zhang Date: Thu, 11 Jul 2019 11:01:27 -0400 Subject: Move g_total_param_size Signed-off-by: Mengchi Zhang --- src/abstract_hardware_model.cc | 3 +-- src/cuda-sim/cuda_device_runtime.cc | 3 +-- src/cuda-sim/cuda_device_runtime.h | 4 +++- src/cuda-sim/instructions.cc | 4 +++- 4 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/cuda-sim/cuda_device_runtime.h') diff --git a/src/abstract_hardware_model.cc b/src/abstract_hardware_model.cc index ef09051..0f4291d 100644 --- a/src/abstract_hardware_model.cc +++ b/src/abstract_hardware_model.cc @@ -771,8 +771,7 @@ bool kernel_info_t::children_all_finished() { void kernel_info_t::notify_parent_finished() { if(m_parent_kernel) { - extern unsigned long long g_total_param_size; - g_total_param_size -= ((m_kernel_entry->get_args_aligned_size() + 255)/256*256); + m_kernel_entry->gpgpu_ctx->device_runtime->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()); } diff --git a/src/cuda-sim/cuda_device_runtime.cc b/src/cuda-sim/cuda_device_runtime.cc index 354fa79..22304db 100644 --- a/src/cuda-sim/cuda_device_runtime.cc +++ b/src/cuda-sim/cuda_device_runtime.cc @@ -5,7 +5,6 @@ #include #include -unsigned long long g_total_param_size = 0; unsigned long long g_max_total_param_size = 0; @@ -70,7 +69,7 @@ std::list g_cuda_device_launch_op; //Handling device runtime api: //void * cudaGetParameterBufferV2(void *func, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize) -void gpgpusim_cuda_getParameterBufferV2(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func) +void cuda_device_runtime::gpgpusim_cuda_getParameterBufferV2(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func) { DEV_RUNTIME_REPORT("Calling cudaGetParameterBufferV2"); diff --git a/src/cuda-sim/cuda_device_runtime.h b/src/cuda-sim/cuda_device_runtime.h index 851fed2..dd908ae 100644 --- a/src/cuda-sim/cuda_device_runtime.h +++ b/src/cuda-sim/cuda_device_runtime.h @@ -3,7 +3,6 @@ #if (CUDART_VERSION >= 5000) #pragma once -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); #endif @@ -14,10 +13,13 @@ class gpgpu_context; class cuda_device_runtime { public: cuda_device_runtime( gpgpu_context* ctx ) { + g_total_param_size = 0; gpgpu_ctx = ctx; } + unsigned long long g_total_param_size; // backward pointer class gpgpu_context* gpgpu_ctx; + void gpgpusim_cuda_getParameterBufferV2(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func); void launch_all_device_kernels(); void launch_one_device_kernel(); }; diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc index 46a262d..a72bc0c 100644 --- a/src/cuda-sim/instructions.cc +++ b/src/cuda-sim/instructions.cc @@ -56,6 +56,8 @@ class ptx_recognizer; #include "cuda_device_runtime.h" #include +#include "../../libcuda/gpgpu_context.h" + using half_float::half; unsigned ptx_instruction::g_num_ptx_inst_uid=0; @@ -2095,7 +2097,7 @@ void call_impl( const ptx_instruction *pI, ptx_thread_info *thread ) #if (CUDART_VERSION >= 5000) //Jin: handle device runtime apis for CDP else if(fname == "cudaGetParameterBufferV2") { - gpgpusim_cuda_getParameterBufferV2(pI, thread, target_func); + target_func->gpgpu_ctx->device_runtime->gpgpusim_cuda_getParameterBufferV2(pI, thread, target_func); return; } else if(fname == "cudaLaunchDeviceV2") { -- cgit v1.3 From b1385157251803aa45eaff154637218c9f6b15b1 Mon Sep 17 00:00:00 2001 From: Mengchi Zhang Date: Thu, 11 Jul 2019 14:23:13 -0400 Subject: Move g_cuda_device_launch_param_map and g_cuda_device_launch_op Signed-off-by: Mengchi Zhang --- src/cuda-sim/cuda_device_runtime.cc | 41 ++---------------------------------- src/cuda-sim/cuda_device_runtime.h | 42 +++++++++++++++++++++++++++++++++---- src/cuda-sim/instructions.cc | 4 ++-- 3 files changed, 42 insertions(+), 45 deletions(-) (limited to 'src/cuda-sim/cuda_device_runtime.h') diff --git a/src/cuda-sim/cuda_device_runtime.cc b/src/cuda-sim/cuda_device_runtime.cc index 22304db..326a1c5 100644 --- a/src/cuda-sim/cuda_device_runtime.cc +++ b/src/cuda-sim/cuda_device_runtime.cc @@ -27,44 +27,7 @@ unsigned long long g_max_total_param_size = 0; std::cout.flush(); \ } -class device_launch_config_t { - -public: - device_launch_config_t() {} - - device_launch_config_t(dim3 _grid_dim, - dim3 _block_dim, - unsigned int _shared_mem, - function_info * _entry): - grid_dim(_grid_dim), - block_dim(_block_dim), - shared_mem(_shared_mem), - entry(_entry) {} - - dim3 grid_dim; - dim3 block_dim; - unsigned int shared_mem; - function_info * entry; - -}; - -class device_launch_operation_t { - -public: - device_launch_operation_t() {} - device_launch_operation_t(kernel_info_t *_grid, - CUstream_st * _stream) : - grid(_grid), stream(_stream) {} - - kernel_info_t * grid; //a new child grid - - CUstream_st * stream; - -}; - -std::map g_cuda_device_launch_param_map; -std::list g_cuda_device_launch_op; //extern stream_manager *g_stream_manager(); //Handling device runtime api: @@ -142,7 +105,7 @@ void cuda_device_runtime::gpgpusim_cuda_getParameterBufferV2(const ptx_instructi //Handling device runtime api: //cudaError_t cudaLaunchDeviceV2(void *parameterBuffer, cudaStream_t stream) -void gpgpusim_cuda_launchDeviceV2(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func) { +void cuda_device_runtime::gpgpusim_cuda_launchDeviceV2(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func) { DEV_RUNTIME_REPORT("Calling cudaLaunchDeviceV2"); unsigned n_return = target_func->has_return(); @@ -263,7 +226,7 @@ void gpgpusim_cuda_launchDeviceV2(const ptx_instruction * pI, ptx_thread_info * //Handling device runtime api: //cudaError_t cudaStreamCreateWithFlags ( cudaStream_t* pStream, unsigned int flags) //flags can only be cudaStreamNonBlocking -void gpgpusim_cuda_streamCreateWithFlags(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func) { +void cuda_device_runtime::gpgpusim_cuda_streamCreateWithFlags(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func) { DEV_RUNTIME_REPORT("Calling cudaStreamCreateWithFlags"); unsigned n_return = target_func->has_return(); diff --git a/src/cuda-sim/cuda_device_runtime.h b/src/cuda-sim/cuda_device_runtime.h index dd908ae..b49d0eb 100644 --- a/src/cuda-sim/cuda_device_runtime.h +++ b/src/cuda-sim/cuda_device_runtime.h @@ -3,10 +3,40 @@ #if (CUDART_VERSION >= 5000) #pragma once -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); -#endif -#if (CUDART_VERSION >= 5000) +class device_launch_config_t { + +public: + device_launch_config_t() {} + + device_launch_config_t(dim3 _grid_dim, + dim3 _block_dim, + unsigned int _shared_mem, + function_info * _entry): + grid_dim(_grid_dim), + block_dim(_block_dim), + shared_mem(_shared_mem), + entry(_entry) {} + + dim3 grid_dim; + dim3 block_dim; + unsigned int shared_mem; + function_info * entry; + +}; + +class device_launch_operation_t { + +public: + device_launch_operation_t() {} + device_launch_operation_t(kernel_info_t *_grid, + CUstream_st * _stream) : + grid(_grid), stream(_stream) {} + + kernel_info_t * grid; //a new child grid + + CUstream_st * stream; + +}; class gpgpu_context; @@ -17,8 +47,12 @@ class cuda_device_runtime { gpgpu_ctx = ctx; } unsigned long long g_total_param_size; + std::map g_cuda_device_launch_param_map; + std::list g_cuda_device_launch_op; // backward pointer class gpgpu_context* gpgpu_ctx; + 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 gpgpusim_cuda_getParameterBufferV2(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func); void launch_all_device_kernels(); void launch_one_device_kernel(); diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc index dfe5af6..565340c 100644 --- a/src/cuda-sim/instructions.cc +++ b/src/cuda-sim/instructions.cc @@ -2101,11 +2101,11 @@ void call_impl( const ptx_instruction *pI, ptx_thread_info *thread ) return; } else if(fname == "cudaLaunchDeviceV2") { - gpgpusim_cuda_launchDeviceV2(pI, thread, target_func); + target_func->gpgpu_ctx->device_runtime->gpgpusim_cuda_launchDeviceV2(pI, thread, target_func); return; } else if(fname == "cudaStreamCreateWithFlags") { - gpgpusim_cuda_streamCreateWithFlags(pI, thread, target_func); + target_func->gpgpu_ctx->device_runtime->gpgpusim_cuda_streamCreateWithFlags(pI, thread, target_func); return; } #endif -- cgit v1.3 From 2f22ddb07752bc956063f6548d4bc26a6ae066f2 Mon Sep 17 00:00:00 2001 From: Mengchi Zhang Date: Thu, 11 Jul 2019 16:56:29 -0400 Subject: Fix symbols Signed-off-by: Mengchi Zhang --- libcuda/gpgpu_context.h | 4 ---- src/cuda-sim/cuda_device_runtime.h | 10 ++++++---- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/cuda-sim/cuda_device_runtime.h') diff --git a/libcuda/gpgpu_context.h b/libcuda/gpgpu_context.h index 3c9f87c..c0b250a 100644 --- a/libcuda/gpgpu_context.h +++ b/libcuda/gpgpu_context.h @@ -16,9 +16,7 @@ class gpgpu_context { ptx_parser = new ptx_recognizer(this); the_gpgpusim = new GPGPUsim_ctx(this); func_sim = new cuda_sim(this); -#if (CUDART_VERSION >= 5000) device_runtime = new cuda_device_runtime(this); -#endif } // global list symbol_table *g_global_allfiles_symbol_table; @@ -29,9 +27,7 @@ class gpgpu_context { ptx_recognizer* ptx_parser; GPGPUsim_ctx* the_gpgpusim; cuda_sim* func_sim; -#if (CUDART_VERSION >= 5000) cuda_device_runtime* device_runtime; -#endif // member function list void cuobjdumpParseBinary(unsigned int handle); class symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source_num ); diff --git a/src/cuda-sim/cuda_device_runtime.h b/src/cuda-sim/cuda_device_runtime.h index b49d0eb..a6303b9 100644 --- a/src/cuda-sim/cuda_device_runtime.h +++ b/src/cuda-sim/cuda_device_runtime.h @@ -1,8 +1,7 @@ +#ifndef __cuda_device_runtime_h__ +#define __cuda_device_runtime_h__ //Jin: cuda_device_runtime.h //Defines CUDA device runtime APIs for CDP support -#if (CUDART_VERSION >= 5000) -#pragma once - class device_launch_config_t { public: @@ -51,11 +50,14 @@ class cuda_device_runtime { std::list g_cuda_device_launch_op; // backward pointer class gpgpu_context* gpgpu_ctx; +#if (CUDART_VERSION >= 5000) +#pragma once 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 gpgpusim_cuda_getParameterBufferV2(const ptx_instruction * pI, ptx_thread_info * thread, const function_info * target_func); void launch_all_device_kernels(); void launch_one_device_kernel(); +#endif }; -#endif +#endif /* __cuda_device_runtime_h__ */ -- cgit v1.3 From 0f5f90ebd896b807270abfae2cd7634733654668 Mon Sep 17 00:00:00 2001 From: Mengchi Zhang Date: Thu, 11 Jul 2019 23:29:21 -0400 Subject: Move g_kernel_launch_latency Signed-off-by: Mengchi Zhang --- src/abstract_hardware_model.cc | 3 +-- src/cuda-sim/cuda_device_runtime.h | 1 + src/gpgpu-sim/gpu-sim.cc | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/cuda-sim/cuda_device_runtime.h') diff --git a/src/abstract_hardware_model.cc b/src/abstract_hardware_model.cc index 0f4291d..450087b 100644 --- a/src/abstract_hardware_model.cc +++ b/src/abstract_hardware_model.cc @@ -693,7 +693,6 @@ void warp_inst_t::completed( unsigned long long cycle ) const //Jin: CDP support bool g_cdp_enabled; -unsigned g_kernel_launch_latency; unsigned kernel_info_t::m_next_uid = 1; @@ -717,7 +716,7 @@ kernel_info_t::kernel_info_t( dim3 gridDim, dim3 blockDim, class function_info * m_parent_kernel = NULL; //Jin: launch latency management - m_launch_latency = g_kernel_launch_latency; + m_launch_latency = entry->gpgpu_ctx->device_runtime->g_kernel_launch_latency; volta_cache_config_set=false; m_NameToCudaArray = nameToCudaArray; diff --git a/src/cuda-sim/cuda_device_runtime.h b/src/cuda-sim/cuda_device_runtime.h index a6303b9..5927b54 100644 --- a/src/cuda-sim/cuda_device_runtime.h +++ b/src/cuda-sim/cuda_device_runtime.h @@ -48,6 +48,7 @@ class cuda_device_runtime { unsigned long long g_total_param_size; std::map g_cuda_device_launch_param_map; std::list g_cuda_device_launch_op; + unsigned g_kernel_launch_latency; // backward pointer class gpgpu_context* gpgpu_ctx; #if (CUDART_VERSION >= 5000) diff --git a/src/gpgpu-sim/gpu-sim.cc b/src/gpgpu-sim/gpu-sim.cc index 93f041a..9726cf5 100644 --- a/src/gpgpu-sim/gpu-sim.cc +++ b/src/gpgpu-sim/gpu-sim.cc @@ -548,9 +548,8 @@ void gpgpu_sim_config::reg_options(option_parser_t opp) ptx_file_line_stats_options(opp); //Jin: kernel launch latency - extern unsigned g_kernel_launch_latency; option_parser_register(opp, "-gpgpu_kernel_launch_latency", OPT_INT32, - &g_kernel_launch_latency, "Kernel launch latency in cycles. Default: 0", + &(gpgpu_ctx->device_runtime->g_kernel_launch_latency), "Kernel launch latency in cycles. Default: 0", "0"); extern bool g_cdp_enabled; option_parser_register(opp, "-gpgpu_cdp_enabled", OPT_BOOL, -- cgit v1.3 From 524c7e2ff37bba3ec60706605b34c6e354f928f1 Mon Sep 17 00:00:00 2001 From: Mengchi Zhang Date: Fri, 12 Jul 2019 00:02:57 -0400 Subject: Move g_max_total_param_size Signed-off-by: Mengchi Zhang --- src/cuda-sim/cuda_device_runtime.cc | 1 - src/cuda-sim/cuda_device_runtime.h | 2 ++ src/gpgpu-sim/gpu-sim.cc | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/cuda-sim/cuda_device_runtime.h') diff --git a/src/cuda-sim/cuda_device_runtime.cc b/src/cuda-sim/cuda_device_runtime.cc index 326a1c5..dc3adc3 100644 --- a/src/cuda-sim/cuda_device_runtime.cc +++ b/src/cuda-sim/cuda_device_runtime.cc @@ -5,7 +5,6 @@ #include #include -unsigned long long g_max_total_param_size = 0; #if (CUDART_VERSION >= 5000) diff --git a/src/cuda-sim/cuda_device_runtime.h b/src/cuda-sim/cuda_device_runtime.h index 5927b54..f37849b 100644 --- a/src/cuda-sim/cuda_device_runtime.h +++ b/src/cuda-sim/cuda_device_runtime.h @@ -43,12 +43,14 @@ class cuda_device_runtime { public: cuda_device_runtime( gpgpu_context* ctx ) { g_total_param_size = 0; + g_max_total_param_size = 0; gpgpu_ctx = ctx; } unsigned long long g_total_param_size; std::map g_cuda_device_launch_param_map; std::list g_cuda_device_launch_op; unsigned g_kernel_launch_latency; + unsigned long long g_max_total_param_size; // backward pointer class gpgpu_context* gpgpu_ctx; #if (CUDART_VERSION >= 5000) diff --git a/src/gpgpu-sim/gpu-sim.cc b/src/gpgpu-sim/gpu-sim.cc index 9726cf5..a3d6a8a 100644 --- a/src/gpgpu-sim/gpu-sim.cc +++ b/src/gpgpu-sim/gpu-sim.cc @@ -1106,8 +1106,7 @@ void gpgpu_sim::gpu_print_stat() printf("gpu_tot_occupancy = %.4f\% \n", (gpu_occupancy + gpu_tot_occupancy).get_occ_fraction() * 100); - extern unsigned long long g_max_total_param_size; - fprintf(statfout, "max_total_param_size = %llu\n", g_max_total_param_size); + fprintf(statfout, "max_total_param_size = %llu\n", gpgpu_ctx->device_runtime->g_max_total_param_size); // performance counter for stalls due to congestion. printf("gpu_stall_dramfull = %d\n", gpu_stall_dramfull); -- cgit v1.3 From 4671280cfe7252bf875d071e667f57064250a1b7 Mon Sep 17 00:00:00 2001 From: Mengchi Zhang Date: Fri, 12 Jul 2019 00:09:29 -0400 Subject: Move g_cdp_enabled Signed-off-by: Mengchi Zhang --- libcuda/cuda_api_object.h | 1 + libcuda/cuda_runtime_api.cc | 11 ++++------- src/abstract_hardware_model.cc | 3 --- src/cuda-sim/cuda_device_runtime.h | 2 ++ src/cuda-sim/ptx_loader.cc | 9 +++------ src/gpgpu-sim/gpu-sim.cc | 3 +-- 6 files changed, 11 insertions(+), 18 deletions(-) (limited to 'src/cuda-sim/cuda_device_runtime.h') diff --git a/libcuda/cuda_api_object.h b/libcuda/cuda_api_object.h index db5e6a4..51416f2 100644 --- a/libcuda/cuda_api_object.h +++ b/libcuda/cuda_api_object.h @@ -199,6 +199,7 @@ class cuda_runtime_api { std::list mergeSections(); cuobjdumpELFSection* findELFSection(const std::string identifier); cuobjdumpPTXSection* findPTXSection(const std::string identifier); + cuobjdumpPTXSection* findPTXSectionInList(std::list §ionlist, const std::string identifier); void cuobjdumpRegisterFatBinary(unsigned int handle, const char* filename, CUctx_st *context); kernel_info_t *gpgpu_cuda_ptx_sim_init_grid( const char *kernel_key, gpgpu_ptx_sim_arg_list_t args, diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index 59d2a60..10a651a 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -2421,7 +2421,6 @@ __host__ cudaError_t CUDARTAPI cudaGetExportTable(const void **ppExportTable, co //extracts all ptx files from binary and dumps into prog_name.unique_no.sm_<>.ptx files void cuda_runtime_api::extract_ptx_files_using_cuobjdump(CUctx_st *context){ - extern bool g_cdp_enabled; char command[1000]; char *pytorch_bin = getenv("PYTORCH_BIN"); std::string app_binary = get_app_binary(); @@ -2442,7 +2441,7 @@ void cuda_runtime_api::extract_ptx_files_using_cuobjdump(CUctx_st *context){ printf("WARNING: Failed to execute cuobjdump to get list of ptx files \n"); exit(0); } - if(!g_cdp_enabled) { + if(!gpgpu_ctx->device_runtime->g_cdp_enabled) { //based on the list above, dump ptx files individually. Format of dumped ptx file is prog_name.unique_no.sm_<>.ptx std::ifstream infile(ptx_list_file_name); @@ -2515,7 +2514,6 @@ void cuda_runtime_api::extract_code_using_cuobjdump(){ } // Running cuobjdump using dynamic link to current process // Needs the option '-all' to extract PTX from CDP-enabled binary - extern bool g_cdp_enabled; //dump ptx for all individial ptx files into sepearte files which is later used by ptxas. int result=0; @@ -2530,7 +2528,7 @@ void cuda_runtime_api::extract_code_using_cuobjdump(){ snprintf(fname,1024,"_cuobjdump_complete_output_XXXXXX"); int fd=mkstemp(fname); close(fd); - if(!g_cdp_enabled) + if(!gpgpu_ctx->device_runtime->g_cdp_enabled) snprintf(command,1000,"$CUDA_INSTALL_PATH/bin/cuobjdump -ptx -elf -sass %s > %s", app_binary.c_str(), fname); else snprintf(command,1000,"$CUDA_INSTALL_PATH/bin/cuobjdump -ptx -elf -sass -all %s > %s", app_binary.c_str(), fname); @@ -2822,7 +2820,7 @@ cuobjdumpELFSection* cuda_runtime_api::findELFSection(const std::string identifi } //! Within the section list, find the PTX section corresponding to a given identifier -cuobjdumpPTXSection* findPTXSectionInList(std::list §ionlist, const std::string identifier){ +cuobjdumpPTXSection* cuda_runtime_api::findPTXSectionInList(std::list §ionlist, const std::string identifier){ std::list::iterator iter; for ( iter = sectionlist.begin(); iter != sectionlist.end(); @@ -2833,8 +2831,7 @@ cuobjdumpPTXSection* findPTXSectionInList(std::list §ionl if(ptxsection->getIdentifier() == identifier) return ptxsection; else { - extern bool g_cdp_enabled; - if(g_cdp_enabled) { + if(gpgpu_ctx->device_runtime->g_cdp_enabled) { printf("Warning: __cudaRegisterFatBinary needs %s, but find PTX section with %s\n", identifier.c_str(), ptxsection->getIdentifier().c_str()); return ptxsection; diff --git a/src/abstract_hardware_model.cc b/src/abstract_hardware_model.cc index 450087b..fde7874 100644 --- a/src/abstract_hardware_model.cc +++ b/src/abstract_hardware_model.cc @@ -691,9 +691,6 @@ void warp_inst_t::completed( unsigned long long cycle ) const ptx_file_line_stats_add_latency(pc, latency * active_count()); } -//Jin: CDP support -bool g_cdp_enabled; - unsigned kernel_info_t::m_next_uid = 1; /*A snapshot of the texture mappings needs to be stored in the kernel's info as diff --git a/src/cuda-sim/cuda_device_runtime.h b/src/cuda-sim/cuda_device_runtime.h index f37849b..7f7a0ca 100644 --- a/src/cuda-sim/cuda_device_runtime.h +++ b/src/cuda-sim/cuda_device_runtime.h @@ -51,6 +51,8 @@ class cuda_device_runtime { std::list g_cuda_device_launch_op; unsigned g_kernel_launch_latency; unsigned long long g_max_total_param_size; + bool g_cdp_enabled; + // backward pointer class gpgpu_context* gpgpu_ctx; #if (CUDART_VERSION >= 5000) diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc index 6e36a62..dca3cec 100644 --- a/src/cuda-sim/ptx_loader.cc +++ b/src/cuda-sim/ptx_loader.cc @@ -330,8 +330,7 @@ void gpgpu_context::gpgpu_ptx_info_load_from_filename( const char *filename, uns std::string ptxas_filename(std::string(filename) + "as"); char buff[1024], extra_flags[1024]; extra_flags[0]=0; - extern bool g_cdp_enabled; - if(!g_cdp_enabled) + if(!device_runtime->g_cdp_enabled) snprintf(extra_flags,1024,"--gpu-name=sm_%u",sm_version); else snprintf(extra_flags,1024,"--compile-only --gpu-name=sm_%u",sm_version); @@ -398,8 +397,7 @@ void gpgpu_context::gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsi "A register size/SM mismatch may result in occupancy differences." ); exit(1); } - extern bool g_cdp_enabled; - if(!g_cdp_enabled) + if(!device_runtime->g_cdp_enabled) snprintf(extra_flags,1024,"--gpu-name=sm_%u", g_occupancy_sm_number); else snprintf(extra_flags,1024,"--compile-only --gpu-name=sm_%u",g_occupancy_sm_number); @@ -467,8 +465,7 @@ void gpgpu_context::gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsi #if CUDART_VERSION >= 3000 if (sm_version == 0) sm_version = 20; - extern bool g_cdp_enabled; - if(!g_cdp_enabled) + if(!device_runtime->g_cdp_enabled) snprintf(extra_flags,1024,"--gpu-name=sm_%u",sm_version); else snprintf(extra_flags,1024,"--compile-only --gpu-name=sm_%u",sm_version); diff --git a/src/gpgpu-sim/gpu-sim.cc b/src/gpgpu-sim/gpu-sim.cc index a3d6a8a..0481259 100644 --- a/src/gpgpu-sim/gpu-sim.cc +++ b/src/gpgpu-sim/gpu-sim.cc @@ -551,9 +551,8 @@ void gpgpu_sim_config::reg_options(option_parser_t opp) option_parser_register(opp, "-gpgpu_kernel_launch_latency", OPT_INT32, &(gpgpu_ctx->device_runtime->g_kernel_launch_latency), "Kernel launch latency in cycles. Default: 0", "0"); - extern bool g_cdp_enabled; option_parser_register(opp, "-gpgpu_cdp_enabled", OPT_BOOL, - &g_cdp_enabled, "Turn on CDP", + &(gpgpu_ctx->device_runtime->g_cdp_enabled), "Turn on CDP", "0"); } -- cgit v1.3