summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcuda/cuda_runtime_api.cc668
-rw-r--r--libcuda/gpgpu_context.h2
-rw-r--r--libopencl/opencl_runtime_api.cc4
-rw-r--r--src/cuda-sim/ptx_parser.cc3
-rw-r--r--src/cuda-sim/ptx_parser.h3
-rw-r--r--src/gpgpusim_entrypoint.cc5
-rw-r--r--src/gpgpusim_entrypoint.h1
7 files changed, 372 insertions, 314 deletions
diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc
index 61f8415..a34727f 100644
--- a/libcuda/cuda_runtime_api.cc
+++ b/libcuda/cuda_runtime_api.cc
@@ -197,7 +197,7 @@ void register_ptx_function( const char *name, function_info *impl )
# endif
#endif
-struct _cuda_device_id *GPGPUSim_Init()
+struct _cuda_device_id *gpgpu_context::GPGPUSim_Init()
{
//static _cuda_device_id *the_device = NULL;
_cuda_device_id *the_device = GPGPUsim_ctx_ptr()->the_cude_device;
@@ -255,9 +255,10 @@ struct _cuda_device_id *GPGPUSim_Init()
static CUctx_st* GPGPUSim_Context()
{
//static CUctx_st *the_context = NULL;
+ gpgpu_context *cur_ctx = GPGPU_Context();
CUctx_st *the_context = GPGPUsim_ctx_ptr()->the_context;
if( the_context == NULL ) {
- _cuda_device_id *the_gpu = GPGPUSim_Init();
+ _cuda_device_id *the_gpu = cur_ctx->GPGPUSim_Init();
GPGPUsim_ctx_ptr()->the_context = new CUctx_st(the_gpu);
the_context = GPGPUsim_ctx_ptr()->the_context;
}
@@ -496,7 +497,7 @@ cudaError_t cudaSetDeviceInternal(int device, gpgpu_context* gpgpu_ctx = NULL)
announce_call(__my_func__);
}
//set the active device to run cuda
- if ( device <= GPGPUSim_Init()->num_devices() ) {
+ if ( device <= ctx->GPGPUSim_Init()->num_devices() ) {
ctx->api->g_active_device = device;
return g_last_cudaError = cudaSuccess;
} else {
@@ -519,6 +520,55 @@ cudaError_t cudaGetDeviceInternal(int *device, gpgpu_context* gpgpu_ctx = NULL)
return g_last_cudaError = cudaSuccess;
}
+__host__ cudaError_t CUDARTAPI cudaDeviceGetLimitInternal( size_t* pValue, cudaLimit limit, gpgpu_context* gpgpu_ctx = NULL )
+{
+ gpgpu_context *ctx;
+ if (gpgpu_ctx){
+ ctx = gpgpu_ctx;
+ } else {
+ ctx = GPGPU_Context();
+ }
+ if(g_debug_execution >= 3){
+ announce_call(__my_func__);
+ }
+ _cuda_device_id *dev = ctx->GPGPUSim_Init();
+ const struct cudaDeviceProp *prop = dev->get_prop();
+ const gpgpu_sim_config& config=dev->get_gpgpu()->get_config();
+ switch(limit) {
+ case 0: // cudaLimitStackSize
+ *pValue=config.stack_limit();
+ break;
+ case 2: // cudaLimitMallocHeapSize
+ *pValue=config.heap_limit();
+ break;
+#if (CUDART_VERSION > 5050)
+ case 3: // cudaLimitDevRuntimeSyncDepth
+ if(prop->major > 2){
+ *pValue=config.sync_depth_limit();
+ break;
+ }
+ else{
+ printf("ERROR:Limit %s is not supported on this architecture \n",limit);
+ abort();
+ }
+ case 4: // cudaLimitDevRuntimePendingLaunchCount
+ if(prop->major > 2){
+ *pValue=config.pending_launch_count_limit();
+ break;
+ }
+ else{
+ printf("ERROR:Limit %s is not supported on this architecture \n",limit);
+ abort();
+ }
+#endif
+ default:
+ printf("ERROR:Limit %s unimplemented \n",limit);
+ abort();
+ }
+ return g_last_cudaError = cudaSuccess;
+
+}
+
void** cudaRegisterFatBinaryInternal( void *fatCubin, gpgpu_context* gpgpu_ctx = NULL)
{
@@ -739,6 +789,260 @@ cudaError_t cudaConfigureCallInternal(dim3 gridDim, dim3 blockDim, size_t shared
return g_last_cudaError = cudaSuccess;
}
+__host__ cudaError_t CUDARTAPI cudaGetDeviceCountInternal(int *count, gpgpu_context* gpgpu_ctx = NULL)
+{
+ gpgpu_context *ctx;
+ if (gpgpu_ctx){
+ ctx = gpgpu_ctx;
+ } else {
+ ctx = GPGPU_Context();
+ }
+ if(g_debug_execution >= 3){
+ announce_call(__my_func__);
+ }
+ _cuda_device_id *dev = ctx->GPGPUSim_Init();
+ *count = dev->num_devices();
+ return g_last_cudaError = cudaSuccess;
+}
+
+__host__ cudaError_t CUDARTAPI cudaGetDevicePropertiesInternal(struct cudaDeviceProp *prop, int device, gpgpu_context* gpgpu_ctx = NULL)
+{
+ gpgpu_context *ctx;
+ if (gpgpu_ctx){
+ ctx = gpgpu_ctx;
+ } else {
+ ctx = GPGPU_Context();
+ }
+ if(g_debug_execution >= 3){
+ announce_call(__my_func__);
+ }
+ _cuda_device_id *dev = ctx->GPGPUSim_Init();
+ if (device <= dev->num_devices() ) {
+ *prop= *dev->get_prop();
+ return g_last_cudaError = cudaSuccess;
+ } else {
+ return g_last_cudaError = cudaErrorInvalidDevice;
+ }
+}
+
+#if (CUDART_VERSION > 5000)
+__host__ cudaError_t CUDARTAPI cudaDeviceGetAttributeInternal(int *value, enum cudaDeviceAttr attr, int device, gpgpu_context* gpgpu_ctx = NULL)
+{
+ gpgpu_context *ctx;
+ if (gpgpu_ctx){
+ ctx = gpgpu_ctx;
+ } else {
+ ctx = GPGPU_Context();
+ }
+ if(g_debug_execution >= 3){
+ announce_call(__my_func__);
+ }
+ const struct cudaDeviceProp *prop;
+ _cuda_device_id *dev = ctx->GPGPUSim_Init();
+ if (device <= dev->num_devices() ) {
+ prop = dev->get_prop();
+ switch (attr) {
+ case 1:
+ *value= prop->maxThreadsDim[0] * prop->maxThreadsDim[1] * prop->maxThreadsDim[2] * prop->maxGridSize[0] * prop->maxGridSize[1] * prop->maxGridSize[2];
+ break;
+ case 2:
+ *value= prop->maxThreadsDim[0];
+ break;
+ case 3:
+ *value= prop->maxThreadsDim[1];
+ break;
+ case 4:
+ *value= prop->maxThreadsDim[2];
+ break;
+ case 5:
+ *value= prop->maxGridSize[0];
+ break;
+ case 6:
+ *value= prop->maxGridSize[1];
+ break;
+ case 7:
+ *value= prop->maxGridSize[2];
+ break;
+ case 8:
+ *value= prop->sharedMemPerBlock;
+ break;
+ case 9:
+ *value= prop->totalConstMem;
+ break;
+ case 10:
+ *value= prop->warpSize;
+ break;
+ case 11:
+ *value= 16;//dummy value
+ break;
+ case 12:
+ *value= prop->regsPerBlock;
+ break;
+ case 13:
+ *value= 1480000;//for 1080ti
+ break;
+ case 14:
+ *value= prop->textureAlignment ;
+ break;
+ case 15:
+ *value = 0;
+ break;
+ case 16:
+ *value= prop->multiProcessorCount ;
+ break;
+ case 17:
+ case 18:
+ case 19:
+ *value = 0;
+ break;
+ case 21:
+ case 22:
+ case 23:
+ case 24:
+ case 25:
+ case 26:
+ case 27:
+ case 28:
+ case 42:
+ case 45:
+ case 46:
+ case 47:
+ case 48:
+ case 49:
+ case 52:
+ case 53:
+ case 55:
+ case 56:
+ case 57:
+ case 58:
+ case 59:
+ case 60:
+ case 61:
+ case 62:
+ case 63:
+ case 64:
+ case 66:
+ case 67:
+ case 69:
+ case 70:
+ case 71:
+ case 73:
+ case 74:
+ case 77:
+ *value = 1000;//dummy value
+ break;
+ case 29:
+ case 43:
+ case 54:
+ case 65:
+ case 68:
+ case 72:
+ *value = 10;//dummy value
+ break;
+ case 30:
+ case 51:
+ *value = 128;//dummy value
+ break;
+ case 31:
+ *value = 1;
+ break;
+ case 32:
+ *value = 0;
+ break;
+ case 33:
+ case 50:
+ *value = 0;//dummy value
+ break;
+ case 34:
+ *value= 0;
+ break;
+ case 35:
+ *value = 0;
+ break;
+ case 36:
+ *value = 1250000;//CK value for 1080ti
+ break;
+ case 37:
+ *value = 352;//value for 1080ti
+ break;
+ case 38:
+ *value = 3000000;//value for 1080ti
+ break;
+ case 39:
+ *value= dev->get_gpgpu()->threads_per_core();
+ break;
+ case 40:
+ *value= 0;
+ break;
+ case 41:
+ *value= 0;
+ break;
+ case 75://cudaDevAttrComputeCapabilityMajor
+ *value= prop->major ;
+ break;
+ case 76://cudaDevAttrComputeCapabilityMinor
+ *value= prop->minor ;
+ break;
+ case 78:
+ *value= 0 ; //TODO: as of now, we dont support stream priorities.
+ break;
+ case 79:
+ *value= 0;
+ break;
+ case 80:
+ *value= 0;
+ break;
+ #if (CUDART_VERSION > 5050)
+ case 81:
+ *value= prop->sharedMemPerMultiprocessor;
+ break;
+ case 82:
+ *value= prop->regsPerMultiprocessor;
+ break;
+ #endif
+ case 83:
+ case 84:
+ case 85:
+ case 86:
+ *value= 0;
+ break;
+ case 87:
+ *value= 4;//dummy value
+ break;
+ case 88:
+ case 89:
+ case 90:
+ case 91:
+ case 95:
+ *value= 0;
+ break;
+ default:
+ printf("ERROR: Attribute number %d unimplemented \n",attr);
+ abort();
+ }
+ return g_last_cudaError = cudaSuccess;
+ } else {
+ return g_last_cudaError = cudaErrorInvalidDevice;
+ }
+}
+#endif
+
+__host__ cudaError_t CUDARTAPI cudaChooseDeviceInternal(int *device, const struct cudaDeviceProp *prop, gpgpu_context* gpgpu_ctx = NULL)
+{
+ gpgpu_context *ctx;
+ if (gpgpu_ctx){
+ ctx = gpgpu_ctx;
+ } else {
+ ctx = GPGPU_Context();
+ }
+ if(g_debug_execution >= 3){
+ announce_call(__my_func__);
+ }
+ _cuda_device_id *dev = ctx->GPGPUSim_Init();
+ *device = dev->get_id();
+ return g_last_cudaError = cudaSuccess;
+}
+
cudaError_t cudaSetupArgumentInternal(const void *arg, size_t size, size_t offset, gpgpu_context* gpgpu_ctx = NULL)
{
gpgpu_context *ctx;
@@ -1058,6 +1362,52 @@ cudaError_t cudaHostAllocInternal(void **pHost, size_t bytes, unsigned int flag
#endif
+size_t getMaxThreadsPerBlock(struct cudaFuncAttributes *attr, gpgpu_context *ctx) {
+ _cuda_device_id *dev = ctx->GPGPUSim_Init();
+ struct cudaDeviceProp prop;
+
+ prop = *dev->get_prop();
+
+ size_t max = prop.maxThreadsPerBlock;
+
+ if ((prop.regsPerBlock / attr->numRegs) < max)
+ max = prop.regsPerBlock / attr->numRegs;
+
+ return max;
+}
+
+cudaError_t CUDARTAPI cudaFuncGetAttributesInternal(struct cudaFuncAttributes *attr, const char *hostFun, gpgpu_context* gpgpu_ctx = NULL )
+{
+ gpgpu_context *ctx;
+ if (gpgpu_ctx){
+ ctx = gpgpu_ctx;
+ } else {
+ ctx = GPGPU_Context();
+ }
+ if(g_debug_execution >= 3){
+ announce_call(__my_func__);
+ }
+ CUctx_st *context = GPGPUSim_Context();
+ function_info *entry = context->get_kernel(hostFun);
+ if( entry ) {
+ const struct gpgpu_ptx_sim_info *kinfo = entry->get_kernel_info();
+ attr->sharedSizeBytes = kinfo->smem;
+ attr->constSizeBytes = kinfo->cmem;
+ attr->localSizeBytes = kinfo->lmem;
+ attr->numRegs = kinfo->regs;
+ if(kinfo->maxthreads > 0)
+ attr->maxThreadsPerBlock = kinfo->maxthreads;
+ else
+ attr->maxThreadsPerBlock = getMaxThreadsPerBlock(attr, ctx);
+#if CUDART_VERSION >= 3000
+ attr->ptxVersion = kinfo->ptx_version;
+ attr->binaryVersion = kinfo->sm_target;
+#endif
+ }
+ return g_last_cudaError = cudaSuccess;
+}
+
+
/*******************************************************************************
* *
* *
@@ -1503,235 +1853,24 @@ __host__ cudaError_t CUDARTAPI cudaGetSymbolSize(size_t *size, const char *symbo
*******************************************************************************/
__host__ cudaError_t CUDARTAPI cudaGetDeviceCount(int *count)
{
- if(g_debug_execution >= 3){
- announce_call(__my_func__);
- }
- _cuda_device_id *dev = GPGPUSim_Init();
- *count = dev->num_devices();
- return g_last_cudaError = cudaSuccess;
+ return cudaGetDeviceCountInternal(count);
}
__host__ cudaError_t CUDARTAPI cudaGetDeviceProperties(struct cudaDeviceProp *prop, int device)
{
- if(g_debug_execution >= 3){
- announce_call(__my_func__);
- }
- _cuda_device_id *dev = GPGPUSim_Init();
- if (device <= dev->num_devices() ) {
- *prop= *dev->get_prop();
- return g_last_cudaError = cudaSuccess;
- } else {
- return g_last_cudaError = cudaErrorInvalidDevice;
- }
+ return cudaGetDevicePropertiesInternal(prop, device);
}
#if (CUDART_VERSION > 5000)
__host__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device)
{
- if(g_debug_execution >= 3){
- announce_call(__my_func__);
- }
- const struct cudaDeviceProp *prop;
- _cuda_device_id *dev = GPGPUSim_Init();
- if (device <= dev->num_devices() ) {
- prop = dev->get_prop();
- switch (attr) {
- case 1:
- *value= prop->maxThreadsDim[0] * prop->maxThreadsDim[1] * prop->maxThreadsDim[2] * prop->maxGridSize[0] * prop->maxGridSize[1] * prop->maxGridSize[2];
- break;
- case 2:
- *value= prop->maxThreadsDim[0];
- break;
- case 3:
- *value= prop->maxThreadsDim[1];
- break;
- case 4:
- *value= prop->maxThreadsDim[2];
- break;
- case 5:
- *value= prop->maxGridSize[0];
- break;
- case 6:
- *value= prop->maxGridSize[1];
- break;
- case 7:
- *value= prop->maxGridSize[2];
- break;
- case 8:
- *value= prop->sharedMemPerBlock;
- break;
- case 9:
- *value= prop->totalConstMem;
- break;
- case 10:
- *value= prop->warpSize;
- break;
- case 11:
- *value= 16;//dummy value
- break;
- case 12:
- *value= prop->regsPerBlock;
- break;
- case 13:
- *value= 1480000;//for 1080ti
- break;
- case 14:
- *value= prop->textureAlignment ;
- break;
- case 15:
- *value = 0;
- break;
- case 16:
- *value= prop->multiProcessorCount ;
- break;
- case 17:
- case 18:
- case 19:
- *value = 0;
- break;
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
- case 28:
- case 42:
- case 45:
- case 46:
- case 47:
- case 48:
- case 49:
- case 52:
- case 53:
- case 55:
- case 56:
- case 57:
- case 58:
- case 59:
- case 60:
- case 61:
- case 62:
- case 63:
- case 64:
- case 66:
- case 67:
- case 69:
- case 70:
- case 71:
- case 73:
- case 74:
- case 77:
- *value = 1000;//dummy value
- break;
- case 29:
- case 43:
- case 54:
- case 65:
- case 68:
- case 72:
- *value = 10;//dummy value
- break;
- case 30:
- case 51:
- *value = 128;//dummy value
- break;
- case 31:
- *value = 1;
- break;
- case 32:
- *value = 0;
- break;
- case 33:
- case 50:
- *value = 0;//dummy value
- break;
- case 34:
- *value= 0;
- break;
- case 35:
- *value = 0;
- break;
- case 36:
- *value = 1250000;//CK value for 1080ti
- break;
- case 37:
- *value = 352;//value for 1080ti
- break;
- case 38:
- *value = 3000000;//value for 1080ti
- break;
- case 39:
- *value= dev->get_gpgpu()->threads_per_core();
- break;
- case 40:
- *value= 0;
- break;
- case 41:
- *value= 0;
- break;
- case 75://cudaDevAttrComputeCapabilityMajor
- *value= prop->major ;
- break;
- case 76://cudaDevAttrComputeCapabilityMinor
- *value= prop->minor ;
- break;
- case 78:
- *value= 0 ; //TODO: as of now, we dont support stream priorities.
- break;
- case 79:
- *value= 0;
- break;
- case 80:
- *value= 0;
- break;
- #if (CUDART_VERSION > 5050)
- case 81:
- *value= prop->sharedMemPerMultiprocessor;
- break;
- case 82:
- *value= prop->regsPerMultiprocessor;
- break;
- #endif
- case 83:
- case 84:
- case 85:
- case 86:
- *value= 0;
- break;
- case 87:
- *value= 4;//dummy value
- break;
- case 88:
- case 89:
- case 90:
- case 91:
- case 92:
- case 93:
- case 94:
- case 95:
- *value= 0;
- break;
- default:
- printf("ERROR: Attribute number %d unimplemented \n",attr);
- abort();
- }
- return g_last_cudaError = cudaSuccess;
- } else {
- return g_last_cudaError = cudaErrorInvalidDevice;
- }
+ return cudaDeviceGetAttributeInternal(value, attr, device);
}
#endif
__host__ cudaError_t CUDARTAPI cudaChooseDevice(int *device, const struct cudaDeviceProp *prop)
{
- if(g_debug_execution >= 3){
- announce_call(__my_func__);
- }
- _cuda_device_id *dev = GPGPUSim_Init();
- *device = dev->get_id();
- return g_last_cudaError = cudaSuccess;
+ return cudaChooseDeviceInternal(device, prop);
}
__host__ cudaError_t CUDARTAPI cudaSetDevice(int device)
@@ -1744,47 +1883,9 @@ __host__ cudaError_t CUDARTAPI cudaGetDevice(int *device)
return cudaGetDeviceInternal(device);
}
-__host__ cudaError_t CUDARTAPI cudaDeviceGetLimit ( size_t* pValue, cudaLimit limit )
+__host__ cudaError_t CUDARTAPI cudaDeviceGetLimit( size_t* pValue, cudaLimit limit )
{
- if(g_debug_execution >= 3){
- announce_call(__my_func__);
- }
- _cuda_device_id *dev = GPGPUSim_Init();
- const struct cudaDeviceProp *prop = dev->get_prop();
- const gpgpu_sim_config& config=dev->get_gpgpu()->get_config();
- switch(limit) {
- case 0: // cudaLimitStackSize
- *pValue=config.stack_limit();
- break;
- case 2: // cudaLimitMallocHeapSize
- *pValue=config.heap_limit();
- break;
-#if (CUDART_VERSION > 5050)
- case 3: // cudaLimitDevRuntimeSyncDepth
- if(prop->major > 2){
- *pValue=config.sync_depth_limit();
- break;
- }
- else{
- printf("ERROR:Limit %s is not supported on this architecture \n",limit);
- abort();
- }
- case 4: // cudaLimitDevRuntimePendingLaunchCount
- if(prop->major > 2){
- *pValue=config.pending_launch_count_limit();
- break;
- }
- else{
- printf("ERROR:Limit %s is not supported on this architecture \n",limit);
- abort();
- }
-#endif
- default:
- printf("ERROR:Limit %s unimplemented \n",limit);
- abort();
- }
- return g_last_cudaError = cudaSuccess;
-
+ return cudaDeviceGetLimitInternal( pValue, limit );
}
__host__ cudaError_t CUDARTAPI cudaStreamGetPriority ( cudaStream_t hStream, int* priority )
@@ -3167,58 +3268,9 @@ cudaError_t CUDARTAPI cudaSetDeviceFlags( int flags )
}
}
-size_t getMaxThreadsPerBlock(struct cudaFuncAttributes *attr) {
- _cuda_device_id *dev = GPGPUSim_Init();
- struct cudaDeviceProp prop;
-
- prop = *dev->get_prop();
-
- size_t max = prop.maxThreadsPerBlock;
-
- if ((prop.regsPerBlock / attr->numRegs) < max)
- max = prop.regsPerBlock / attr->numRegs;
-
- return max;
-}
-
cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *attr, const char *hostFun )
{
- if(g_debug_execution >= 3){
- announce_call(__my_func__);
- }
- CUctx_st *context = GPGPUSim_Context();
- function_info *entry = context->get_kernel(hostFun);
- if( entry ) {
- const struct gpgpu_ptx_sim_info *kinfo = entry->get_kernel_info();
- attr->sharedSizeBytes = kinfo->smem;
- attr->constSizeBytes = kinfo->cmem;
- attr->localSizeBytes = kinfo->lmem;
- attr->numRegs = kinfo->regs;
- if(kinfo->maxthreads > 0)
- attr->maxThreadsPerBlock = kinfo->maxthreads;
- else
- attr->maxThreadsPerBlock = getMaxThreadsPerBlock(attr);
-#if CUDART_VERSION >= 3000
- attr->ptxVersion = kinfo->ptx_version;
- attr->binaryVersion = kinfo->sm_target;
-#endif
- }
- return g_last_cudaError = cudaSuccess;
-}
-
-cudaError_t CUDARTAPI cudaEventCreateWithFlags(cudaEvent_t *event, int flags)
-{
- if(g_debug_execution >= 3){
- announce_call(__my_func__);
- }
- CUevent_st *e = new CUevent_st(flags==cudaEventBlockingSync);
- g_timer_events[e->get_uid()] = e;
-#if CUDART_VERSION >= 3000
- *event = e;
-#else
- *event = e->get_uid();
-#endif
- return g_last_cudaError = cudaSuccess;
+ return cudaFuncGetAttributesInternal(attr, hostFun );
}
cudaError_t CUDARTAPI cudaDriverGetVersion(int *driverVersion)
diff --git a/libcuda/gpgpu_context.h b/libcuda/gpgpu_context.h
index fa5d02b..dd8b51d 100644
--- a/libcuda/gpgpu_context.h
+++ b/libcuda/gpgpu_context.h
@@ -26,6 +26,8 @@ class gpgpu_context {
void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num, unsigned sm_version=20, int no_of_ptx=0 );
void print_ptx_file( const char *p, unsigned source_num, const char *filename );
class symbol_table* init_parser(const char*);
+ class gpgpu_sim *gpgpu_ptx_sim_init_perf();
+ struct _cuda_device_id *GPGPUSim_Init();
};
gpgpu_context* GPGPU_Context();
diff --git a/libopencl/opencl_runtime_api.cc b/libopencl/opencl_runtime_api.cc
index 50a02fa..e91e2e0 100644
--- a/libopencl/opencl_runtime_api.cc
+++ b/libopencl/opencl_runtime_api.cc
@@ -648,7 +648,9 @@ class _cl_device_id *GPGPUSim_Init()
{
static _cl_device_id *the_device = NULL;
if( !the_device ) {
- gpgpu_sim *the_gpu = gpgpu_ptx_sim_init_perf();
+ gpgpu_context *ctx;
+ ctx = GPGPU_Context();
+ gpgpu_sim *the_gpu = ctx->gpgpu_ptx_sim_init_perf();
the_device = new _cl_device_id(the_gpu);
}
start_sim_thread(2);
diff --git a/src/cuda-sim/ptx_parser.cc b/src/cuda-sim/ptx_parser.cc
index 2872b84..9094ec3 100644
--- a/src/cuda-sim/ptx_parser.cc
+++ b/src/cuda-sim/ptx_parser.cc
@@ -48,7 +48,6 @@ void set_ptx_warp_size(const struct core_config * warp_size)
g_shader_core_config=warp_size;
}
-static bool g_debug_ir_generation=false;
const char *g_filename;
// the program intermediate representation...
@@ -70,7 +69,7 @@ const char *decode_token( int type )
return g_ptx_token_decode[type].c_str();
}
-void read_parser_environment_variables()
+void ptx_recognizer::read_parser_environment_variables()
{
g_filename = getenv("PTX_SIM_KERNELFILE");
char *dbg_level = getenv("PTX_SIM_DEBUG");
diff --git a/src/cuda-sim/ptx_parser.h b/src/cuda-sim/ptx_parser.h
index 25c01fe..bc9a872 100644
--- a/src/cuda-sim/ptx_parser.h
+++ b/src/cuda-sim/ptx_parser.h
@@ -62,6 +62,7 @@ class ptx_recognizer {
g_error_detected = 0;
g_entry_func_param_index=0;
g_func_info = NULL;
+ g_debug_ir_generation=false;
}
// global list
yyscan_t scanner;
@@ -103,6 +104,7 @@ class ptx_recognizer {
unsigned g_entry_func_param_index;
function_info *g_func_info;
operand_info g_return_var;
+ bool g_debug_ir_generation;
// member function list
void init_directive_state();
@@ -169,6 +171,7 @@ class ptx_recognizer {
void start_inst_group();
void end_inst_group();
bool check_for_duplicates( const char *identifier );
+ void read_parser_environment_variables();
};
diff --git a/src/gpgpusim_entrypoint.cc b/src/gpgpusim_entrypoint.cc
index b09674a..476a9d4 100644
--- a/src/gpgpusim_entrypoint.cc
+++ b/src/gpgpusim_entrypoint.cc
@@ -35,6 +35,7 @@
#include "gpgpu-sim/gpu-sim.h"
#include "gpgpu-sim/icnt_wrapper.h"
#include "stream_manager.h"
+#include "../libcuda/gpgpu_context.h"
#define MAX(a,b) (((a)>(b))?(a):(b))
@@ -208,12 +209,12 @@ void exit_simulation()
extern bool g_cuda_launch_blocking;
-gpgpu_sim *gpgpu_ptx_sim_init_perf()
+gpgpu_sim *gpgpu_context::gpgpu_ptx_sim_init_perf()
{
srand(1);
print_splash();
read_sim_environment_variables();
- read_parser_environment_variables();
+ ptx_parser->read_parser_environment_variables();
option_parser_t opp = option_parser_create();
ptx_reg_options(opp);
diff --git a/src/gpgpusim_entrypoint.h b/src/gpgpusim_entrypoint.h
index 9ce7fef..a443151 100644
--- a/src/gpgpusim_entrypoint.h
+++ b/src/gpgpusim_entrypoint.h
@@ -74,7 +74,6 @@ struct GPGPUsim_ctx {
};
-class gpgpu_sim *gpgpu_ptx_sim_init_perf();
void start_sim_thread(int api);
class gpgpu_sim* g_the_gpu();