From 5e8eced64a8262b0190c4014e59b93c37ba3af9c Mon Sep 17 00:00:00 2001 From: Tor Aamodt Date: Mon, 23 Aug 2010 09:39:43 -0800 Subject: - add '-keep' option to keep intermediate files (used for OpenCL only right now) - remove redundant initialization code of options (which confuses new users) - make bool option variables bool type - remove some more extern decls [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 7247] --- src/cuda-sim/cuda-sim.cc | 4 +-- src/cuda-sim/cuda_device_printf.cc | 1 + src/cuda-sim/cuda_device_printf.h | 70 ++++++++++++++++++++++++++++++++++++++ src/cuda-sim/instructions.cc | 8 ++--- src/cuda-sim/ptx-stats.cc | 2 +- src/cuda-sim/ptx-stats.h | 2 +- src/cuda-sim/ptx_ir.h | 2 ++ src/cuda-sim/ptx_loader.cc | 6 +++- src/cuda-sim/ptx_sim.cc | 6 +--- 9 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 src/cuda-sim/cuda_device_printf.h (limited to 'src/cuda-sim') diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc index 9d62a59..c471a5c 100644 --- a/src/cuda-sim/cuda-sim.cc +++ b/src/cuda-sim/cuda-sim.cc @@ -83,7 +83,7 @@ #include "ptx_sim.h" #include "../gpgpusim_entrypoint.h" -int gpgpu_ptx_instruction_classification=0; +int gpgpu_ptx_instruction_classification; void ** g_inst_classification_stat = NULL; void ** g_inst_op_classification_stat= NULL; int g_ptx_kernel_count = -1; // used for classification stat collection purposes @@ -1327,7 +1327,7 @@ void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t co fflush(stdout); } -int g_ptx_sim_mode=0; // if non-zero run functional simulation only (i.e., no notion of a clock cycle) +int g_ptx_sim_mode; // if non-zero run functional simulation only (i.e., no notion of a clock cycle) extern "C" int ptx_debug; diff --git a/src/cuda-sim/cuda_device_printf.cc b/src/cuda-sim/cuda_device_printf.cc index 197a5dd..9edeb5e 100644 --- a/src/cuda-sim/cuda_device_printf.cc +++ b/src/cuda-sim/cuda_device_printf.cc @@ -62,6 +62,7 @@ * Vancouver, BC V6T 1Z4 */ +#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); diff --git a/src/cuda-sim/cuda_device_printf.h b/src/cuda-sim/cuda_device_printf.h new file mode 100644 index 0000000..022b555 --- /dev/null +++ b/src/cuda-sim/cuda_device_printf.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2009 by Tor M. Aamodt, Ali Bakhoda, Joey Ting, Dan O'Connor, + * Clive Lin, George L. Yuan, Wilson W. L. Fung and the + * University of British Columbia + * Vancouver, BC V6T 1Z4 + * All Rights Reserved. + * + * THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE + * TERMS AND CONDITIONS. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h + * are derived from the CUDA Toolset available from http://www.nvidia.com/cuda + * (property of NVIDIA). The files benchmarks/BlackScholes/ and + * benchmarks/template/ are derived from the CUDA SDK available from + * http://www.nvidia.com/cuda (also property of NVIDIA). The files from + * src/intersim/ are derived from Booksim (a simulator provided with the + * textbook "Principles and Practices of Interconnection Networks" available + * from http://cva.stanford.edu/books/ppin/). As such, those files are bound by + * the corresponding legal terms and conditions set forth separately (original + * copyright notices are left in files from these sources and where we have + * modified a file our copyright notice appears before the original copyright + * notice). + * + * Using this version of GPGPU-Sim requires a complete installation of CUDA + * which is distributed seperately by NVIDIA under separate terms and + * conditions. To use this version of GPGPU-Sim with OpenCL requires a + * recent version of NVIDIA's drivers which support OpenCL. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the University of British Columbia nor the names of + * its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * 4. This version of GPGPU-SIM is distributed freely for non-commercial use only. + * + * 5. No nonprofit user may place any restrictions on the use of this software, + * including as modified by the user, by any other authorized user. + * + * 6. GPGPU-SIM was developed primarily by Tor M. Aamodt, Wilson W. L. Fung, + * Ali Bakhoda, George L. Yuan, at the University of British Columbia, + * Vancouver, BC V6T 1Z4 + */ + +#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 ); + +#endif diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc index 0924eab..47b3ebb 100644 --- a/src/cuda-sim/instructions.cc +++ b/src/cuda-sim/instructions.cc @@ -75,6 +75,9 @@ #include "cuda-math.h" #include "../abstract_hardware_model.h" #include "ptx_loader.h" +#include "cuda_device_printf.h" +#include "../gpgpu-sim/gpu-sim.h" +#include "../gpgpu-sim/shader.h" #include @@ -678,11 +681,6 @@ void bra_impl( const ptx_instruction *pI, ptx_thread_info *thread ) void brev_impl( const ptx_instruction *pI, ptx_thread_info *thread ) { inst_not_implemented(pI); } void brkpt_impl( const ptx_instruction *pI, ptx_thread_info *thread ) { inst_not_implemented(pI); } -extern int gpgpu_simd_model; -#define POST_DOMINATOR 1 /* must match enum value in shader.h */ -void get_pdom_stack_top_info( unsigned sid, unsigned tid, unsigned *npc, unsigned *rpc ); -void gpgpusim_cuda_vprintf(const ptx_instruction * pI, const ptx_thread_info * thread, const function_info * target_func ); - void call_impl( const ptx_instruction *pI, ptx_thread_info *thread ) { static unsigned call_uid_next = 1; diff --git a/src/cuda-sim/ptx-stats.cc b/src/cuda-sim/ptx-stats.cc index 6e7e6ec..df95960 100644 --- a/src/cuda-sim/ptx-stats.cc +++ b/src/cuda-sim/ptx-stats.cc @@ -71,7 +71,7 @@ extern function_info *g_func_info; // options -int enable_ptx_file_line_stats; +bool enable_ptx_file_line_stats; char * ptx_line_stats_filename = NULL; void ptx_file_line_stats_options(option_parser_t opp) diff --git a/src/cuda-sim/ptx-stats.h b/src/cuda-sim/ptx-stats.h index 200f7a5..004433b 100644 --- a/src/cuda-sim/ptx-stats.h +++ b/src/cuda-sim/ptx-stats.h @@ -63,7 +63,7 @@ #include "../option_parser.h" -extern int enable_ptx_file_line_stats; +extern bool enable_ptx_file_line_stats; // set options void ptx_file_line_stats_options(option_parser_t opp); diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h index ce68505..3a2a4e3 100644 --- a/src/cuda-sim/ptx_ir.h +++ b/src/cuda-sim/ptx_ir.h @@ -1272,6 +1272,8 @@ extern std::map g_sym_name_to_symbol_table; #define STATIC_ALLOC_LIMIT (GLOBAL_HEAP_START - (TOTAL_LOCAL_MEM+TOTAL_SHARED_MEM)) +extern bool g_keep_intermediate_files; + void gpgpu_ptx_assemble( std::string kname, void *kinfo ); #include "../option_parser.h" void ptx_reg_options(option_parser_t opp); diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc index 713bdb3..783ce91 100644 --- a/src/cuda-sim/ptx_loader.cc +++ b/src/cuda-sim/ptx_loader.cc @@ -299,13 +299,17 @@ void gpgpu_ptx_sim_add_ptxstring( const char *ptx_string, const char *sourcefnam } } -static int g_save_embedded_ptx = 0; +static bool g_save_embedded_ptx; +bool g_keep_intermediate_files; void ptx_reg_options(option_parser_t opp) { option_parser_register(opp, "-save_embedded_ptx", OPT_BOOL, &g_save_embedded_ptx, "saves ptx files embedded in binary as .ptx", "0"); + option_parser_register(opp, "-keep", OPT_BOOL, &g_keep_intermediate_files, + "keep intermediate files created by GPGPU-Sim when interfacing with external programs", + "0"); } void print_ptx_file( const char *p, unsigned source_num, const char *filename ) diff --git a/src/cuda-sim/ptx_sim.cc b/src/cuda-sim/ptx_sim.cc index 2156bd6..b433fb3 100644 --- a/src/cuda-sim/ptx_sim.cc +++ b/src/cuda-sim/ptx_sim.cc @@ -65,6 +65,7 @@ #include #include "ptx_ir.h" #include "../gpgpu-sim/gpu-sim.h" +#include "../gpgpu-sim/shader.h" void feature_not_implemented( const char *f ); @@ -358,11 +359,6 @@ void ptx_thread_info::callstack_push( unsigned pc, unsigned rpc, const symbol *r m_local_mem_stack_pointer += m_func_info->local_mem_framesize(); } -#define POST_DOMINATOR 1 /* must match definition in shader.h */ -extern int gpgpu_simd_model; -extern ptx_reg_t get_operand_value( const symbol *reg ); -extern void set_operand_value( const symbol *dst, const ptx_reg_t &data ); - bool ptx_thread_info::callstack_pop() { const symbol *rv_src = m_callstack.back().m_return_var_src; -- cgit v1.3