diff options
| author | deval281shah <[email protected]> | 2019-03-24 15:00:12 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-03-24 15:00:12 -0700 |
| commit | 7f20abbf5c4493bd7dd345abc89b21556f6389cf (patch) | |
| tree | 2907326278701749f1b79fbed9998d8d0b6bf958 /libcuda/cuda_runtime_api.cc | |
| parent | 431381ece357b1bfae7171743e56ab9361b749f4 (diff) | |
| parent | 551da3e81376de7cc35b6ac0fd6eb3b85b32746a (diff) | |
Merge pull request #4 from gpgpu-sim/dev
Dev
Diffstat (limited to 'libcuda/cuda_runtime_api.cc')
| -rw-r--r-- | libcuda/cuda_runtime_api.cc | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index e6b53c3..cf16d9b 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -1499,42 +1499,26 @@ __host__ cudaError_t CUDARTAPI cudaLaunch( const char *hostFun ) return g_last_cudaError = cudaSuccess; } - __host__ cudaError_t CUDARTAPI cudaLaunchKernel ( const char* hostFun, dim3 gridDim, dim3 blockDim, const void** args, size_t sharedMem, cudaStream_t stream ) { - struct CUstream_st *s = (struct CUstream_st *)stream; - g_cuda_launch_stack.push_back( kernel_config(gridDim,blockDim,sharedMem,s) ); - //printf("cudaLaunchKernel:sizeof(Arg[0])=%d)\n ",sizeof(args[0])); - kernel_config &config = g_cuda_launch_stack.back(); - config.set_arg(args[0],432,0);//standard interface for cutlass library #TODO Implementing a generalized kernel - - CUctx_st* context = GPGPUSim_Context(); - char *mode = getenv("PTX_SIM_MODE_FUNC"); - if( mode ) - sscanf(mode,"%u", &g_ptx_sim_mode); - gpgpusim_ptx_assert( !g_cuda_launch_stack.empty(), "empty launch stack" ); - kernel_config config1 = g_cuda_launch_stack.back(); - struct CUstream_st *stream1 = config1.get_stream(); - printf("\nGPGPU-Sim PTX: cudaLaunch for 0x%p (mode=%s) on stream %u\n", hostFun, - g_ptx_sim_mode?"functional simulation":"performance simulation", stream1?stream1->get_uid():0 ); - kernel_info_t *grid = gpgpu_cuda_ptx_sim_init_grid(hostFun,config1.get_args(),config1.grid_dim(),config1.block_dim(),context); - std::string kname = grid->name(); - dim3 gridDim1 = config1.grid_dim(); - dim3 blockDim1 = config1.block_dim(); - printf("GPGPU-Sim PTX: pushing kernel \'%s\' to stream %u, gridDim= (%u,%u,%u) blockDim = (%u,%u,%u) \n", - kname.c_str(), stream1?stream1->get_uid():0, gridDim1.x,gridDim1.y,gridDim1.z,blockDim1.x,blockDim1.y,blockDim1.z ); - - /*Kernel is hardcoded to enable the cutlass library*/ - std::string cutlass("cutlass"); - assert(kname.find(cutlass) != std::string::npos); + if(g_debug_execution >= 3){ + announce_call(__my_func__); + } + CUctx_st *context = GPGPUSim_Context(); + function_info *entry = context->get_kernel(hostFun); + + cudaConfigureCall(gridDim, blockDim, sharedMem, stream); + for(unsigned i = 0; i < entry->num_args(); i++){ + std::pair<size_t, unsigned> p = entry->get_param_config(i); + cudaSetupArgument(args[i], p.first, p.second); + } - stream_operation op(grid,g_ptx_sim_mode,stream1); - g_stream_manager->push(op); - g_cuda_launch_stack.pop_back(); + cudaLaunch(hostFun); return g_last_cudaError = cudaSuccess; } + /******************************************************************************* * * * * @@ -1585,6 +1569,9 @@ __host__ cudaError_t CUDARTAPI cudaStreamDestroy(cudaStream_t stream) announce_call(__my_func__); } #if (CUDART_VERSION >= 3000) + //synchronization required for application using external libraries without explicit synchronization in the code to + //avoid the stream_manager from spinning forever to destroy non-empty streams without making any forward progress. + synchronize(); g_stream_manager->destroy_stream(stream); #endif return g_last_cudaError = cudaSuccess; |
