diff options
| -rw-r--r-- | libcuda/cuda_runtime_api.cc | 32 | ||||
| -rw-r--r-- | libopencl/opencl_runtime_api.cc | 26 | ||||
| -rw-r--r-- | src/abstract_hardware_model.h | 6 | ||||
| -rw-r--r-- | src/cuda-sim/cuda-sim.cc | 2 | ||||
| -rw-r--r-- | src/cuda-sim/cuda-sim.h | 26 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_ir.cc | 8 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_sim.h | 4 | ||||
| -rw-r--r-- | src/gpgpusim_entrypoint.cc | 6 | ||||
| -rw-r--r-- | src/gpgpusim_entrypoint.h | 73 |
9 files changed, 119 insertions, 64 deletions
diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index a5f2823..df59506 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -167,31 +167,8 @@ struct gpgpu_ptx_sim_arg { struct gpgpu_ptx_sim_arg *g_ptx_sim_params; cudaError_t g_last_cudaError; -extern void gpgpu_ptx_sim_init_perf(); -extern void gpgpu_ptx_sim_main_func( const char *kernel_key, dim3 gridDim, dim3 blockDim, struct gpgpu_ptx_sim_arg *); -extern void gpgpu_ptx_sim_main_perf( const char *kernel_key, - struct dim3 gridDim, - struct dim3 blockDIm, struct gpgpu_ptx_sim_arg *grid_params ); -extern void* gpgpu_ptx_sim_malloc( size_t count ); -extern void* gpgpu_ptx_sim_mallocarray( size_t count ); -extern void gpgpu_ptx_sim_memcpy_to_gpu( size_t dst_start_addr, const void *src, size_t count ); -extern void gpgpu_ptx_sim_memcpy_from_gpu( void *dst, size_t src_start_addr, size_t count ); -extern void gpgpu_ptx_sim_memcpy_gpu_to_gpu( size_t dst, size_t src, size_t count ); -extern void gpgpu_ptx_sim_memset( size_t dst_start_addr, int c, size_t count ); -extern void gpgpu_ptx_sim_init_memory(); -extern void gpgpu_ptx_sim_load_gpu_kernels(); -extern void gpgpu_ptx_sim_register_kernel(const char *hostFun, const char *deviceFun); -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 ); -extern void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t count, size_t offset, int to ); -extern void gpgpu_ptx_sim_bindTextureToArray(const struct textureReference* texref, const struct cudaArray* array); -extern struct cudaArray* gpgpu_ptx_sim_accessArrayofTexture(struct textureReference* texref); -extern void gpgpu_ptx_sim_bindNameToTexture(const char* name, const struct textureReference* texref); -extern struct textureReference* gpgpu_ptx_sim_accessTextureofName(char* name); -extern char* gpgpu_ptx_sim_findNamefromTexture(const struct textureReference* texref); -extern void gpgpu_ptx_sim_add_ptxstring( const char *ptx, const char *source_fname ); - -extern int g_ptx_sim_mode; +#include "../src/cuda-sim/cuda-sim.h" +#include "../src/gpgpusim_entrypoint.h" #if defined __APPLE__ # define __my_func__ __PRETTY_FUNCTION__ @@ -207,8 +184,7 @@ extern int g_ptx_sim_mode; # endif #endif -int g_gpgpusim_init = 0; -extern const char *g_gpgpusim_version_string; +static int g_gpgpusim_init = 0; #define GPGPUSIM_INIT \ if( gpgpu_cuda_devices == NULL ) { \ @@ -627,8 +603,6 @@ __host__ cudaError_t CUDARTAPI cudaMemset(void *mem, int c, size_t count) extern unsigned int gpu_n_shader; #endif -extern unsigned int warp_size; - __host__ cudaError_t CUDARTAPI cudaGetDeviceProperties(struct cudaDeviceProp *prop, int device) { GPGPUSIM_INIT diff --git a/libopencl/opencl_runtime_api.cc b/libopencl/opencl_runtime_api.cc index 972b9d1..2790e53 100644 --- a/libopencl/opencl_runtime_api.cc +++ b/libopencl/opencl_runtime_api.cc @@ -76,6 +76,8 @@ #include "builtin_types.h" #include "__cudaFatFormat.h" #include "../src/abstract_hardware_model.h" +#include "../src/cuda-sim/cuda-sim.h" +#include "../src/gpgpusim_entrypoint.h" struct gpgpu_ptx_sim_arg { const void *m_start; @@ -83,26 +85,10 @@ struct gpgpu_ptx_sim_arg { size_t m_offset; struct gpgpu_ptx_sim_arg *m_next; }; -extern void gpgpu_ptx_sim_init_memory(); -extern void* gpgpu_ptx_sim_malloc( size_t count ); -extern void gpgpu_ptx_sim_memcpy_to_gpu( size_t dst_start_addr, const void *src, size_t count ); -extern void gpgpu_ptx_sim_memcpy_from_gpu( void *dst, size_t src_start_addr, size_t count ); -extern void gpgpu_ptx_sim_memcpy_gpu_to_gpu( size_t dst, size_t src, size_t count ); -extern void gpgpu_ptx_sim_register_kernel(const char *hostFun, const char *deviceFun); -extern void gpgpu_ptx_sim_init_perf(); -extern void gpgpu_ptx_sim_main_func( const char *kernel_key, - dim3 gridDim, - dim3 blockDim, struct gpgpu_ptx_sim_arg *); -extern void gpgpu_ptx_sim_main_perf( const char *kernel_key, - struct dim3 gridDim, - struct dim3 blockDIm, - struct gpgpu_ptx_sim_arg *grid_params ); -extern void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t count, size_t offset, int to ); -extern int g_ptx_sim_mode; -struct cudaDeviceProp the_cuda_device; -struct cudaDeviceProp **gpgpu_cuda_devices; -int g_gpgpusim_init = 0; +static struct cudaDeviceProp the_cuda_device; +static struct cudaDeviceProp **gpgpu_cuda_devices; +static int g_gpgpusim_init = 0; extern const char *g_gpgpusim_version_string; @@ -148,7 +134,7 @@ extern const char *g_gpgpusim_version_string; // global kernel parameters... static dim3 g_cudaGridDim; static dim3 g_cudaBlockDim; -struct gpgpu_ptx_sim_arg *g_ptx_sim_params; +static struct gpgpu_ptx_sim_arg *g_ptx_sim_params; #include <CL/cl.h> diff --git a/src/abstract_hardware_model.h b/src/abstract_hardware_model.h index 3b3d07e..612c46d 100644 --- a/src/abstract_hardware_model.h +++ b/src/abstract_hardware_model.h @@ -3,6 +3,12 @@ #ifdef __cplusplus +#if !defined(__VECTOR_TYPES_H__) +struct dim3 { + unsigned int x, y, z; +}; +#endif + class core_t { public: virtual ~core_t() {} diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc index 5f568b4..4acefe5 100644 --- a/src/cuda-sim/cuda-sim.cc +++ b/src/cuda-sim/cuda-sim.cc @@ -62,6 +62,8 @@ * Vancouver, BC V6T 1Z4 */ +#include "cuda-sim.h" + #include "instructions.h" #include "ptx_ir.h" #include "ptx_sim.h" diff --git a/src/cuda-sim/cuda-sim.h b/src/cuda-sim/cuda-sim.h index 83e274a..25b0cb2 100644 --- a/src/cuda-sim/cuda-sim.h +++ b/src/cuda-sim/cuda-sim.h @@ -1,8 +1,34 @@ #ifndef CUDASIM_H_INCLUDED #define CUDASIM_H_INCLUDED +#include "../abstract_hardware_model.h" +#include <stdlib.h> + class memory_space; +extern const char *g_gpgpusim_version_string; +extern int g_ptx_sim_mode; extern memory_space *g_global_mem; +extern void gpgpu_ptx_sim_add_ptxstring( const char *ptx, const char *source_fname ); +extern void gpgpu_ptx_sim_main_func( const char *kernel_key, dim3 gridDim, dim3 blockDim, struct gpgpu_ptx_sim_arg *); +extern void* gpgpu_ptx_sim_malloc( size_t count ); +extern void* gpgpu_ptx_sim_mallocarray( size_t count ); +extern void gpgpu_ptx_sim_memcpy_to_gpu( size_t dst_start_addr, const void *src, size_t count ); +extern void gpgpu_ptx_sim_memcpy_from_gpu( void *dst, size_t src_start_addr, size_t count ); +extern void gpgpu_ptx_sim_memcpy_gpu_to_gpu( size_t dst, size_t src, size_t count ); +extern void gpgpu_ptx_sim_memset( size_t dst_start_addr, int c, size_t count ); +extern void gpgpu_ptx_sim_init_memory(); +extern void gpgpu_ptx_sim_load_gpu_kernels(); +extern void gpgpu_ptx_sim_register_kernel(const char *hostFun, const char *deviceFun); +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 ); +extern void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t count, size_t offset, int to ); + +extern void gpgpu_ptx_sim_bindTextureToArray(const struct textureReference* texref, const struct cudaArray* array); +extern void gpgpu_ptx_sim_bindNameToTexture(const char* name, const struct textureReference* texref); +extern int gpgpu_ptx_sim_sizeofTexture(const char* name); +extern const char* gpgpu_ptx_sim_findNamefromTexture(const struct textureReference* texref); +extern const struct textureReference* gpgpu_ptx_sim_accessTextureofName(const char* name); + #endif diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc index e0f2316..b2c8552 100644 --- a/src/cuda-sim/ptx_ir.cc +++ b/src/cuda-sim/ptx_ir.cc @@ -71,14 +71,10 @@ #include <algorithm> #include <stdarg.h> +#include "cuda-sim.h" + extern unsigned g_max_regs_per_thread; extern "C" int ptx_error( const char *s ); -void gpgpu_ptx_sim_bindTextureToArray(const struct textureReference* texref, struct cudaArray* array); //texture functions -struct cudaArray* gpgpu_ptx_sim_accessArrayofTexture(struct textureReference* texref); -void gpgpu_ptx_sim_bindNameToTexture(const char* name, struct textureReference* texref); -struct textureReference* gpgpu_ptx_sim_accessTextureofName(const char* name); -const char* gpgpu_ptx_sim_findNamefromTexture(const struct textureReference* texref); -int gpgpu_ptx_sim_sizeofTexture(const char* name); // the program intermediate representation... symbol_table *g_global_symbol_table = NULL; diff --git a/src/cuda-sim/ptx_sim.h b/src/cuda-sim/ptx_sim.h index c2bb533..12075c8 100644 --- a/src/cuda-sim/ptx_sim.h +++ b/src/cuda-sim/ptx_sim.h @@ -71,10 +71,6 @@ #include "../abstract_hardware_model.h" -struct dim3 { - unsigned int x, y, z; -}; - struct gpgpu_ptx_sim_arg { const void *m_start; size_t m_nbytes; diff --git a/src/gpgpusim_entrypoint.cc b/src/gpgpusim_entrypoint.cc index b6770ea..5f0be61 100644 --- a/src/gpgpusim_entrypoint.cc +++ b/src/gpgpusim_entrypoint.cc @@ -62,18 +62,14 @@ * Vancouver, BC V6T 1Z4 */ +#include "gpgpusim_entrypoint.h" #include <stdio.h> #include <time.h> #include "option_parser.h" -//#include "gpgpu-sim/gpu-sim.h" #define MAX(a,b) (((a)>(b))?(a):(b)) -struct dim3 { - unsigned int x, y, z; -}; - struct gpgpu_ptx_sim_arg *grid_params; int g_grid_num=0; int g_argc = 3; diff --git a/src/gpgpusim_entrypoint.h b/src/gpgpusim_entrypoint.h new file mode 100644 index 0000000..8de05c7 --- /dev/null +++ b/src/gpgpusim_entrypoint.h @@ -0,0 +1,73 @@ +/* + * gpgpusim_entrypoint.h + * + * Copyright © 2009 by Tor M. Aamodt, Wilson W. L. Fung, Ali Bakhoda, + * George L. Yuan 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 GPGPUSIM_ENTRYPOINT_H_INCLUDED +#define GPGPUSIM_ENTRYPOINT_H_INCLUDED + +#include "abstract_hardware_model.h" + +void gpgpu_ptx_sim_init_perf(); +int gpgpu_ptx_sim_main_perf( const char *kernel_key, struct dim3 gridDim, struct dim3 blockDim, struct gpgpu_ptx_sim_arg *grid_params ); + +#endif |
