From e1dc8113aa2a51885541f96943bd8d90eaccd968 Mon Sep 17 00:00:00 2001 From: Amruth Date: Thu, 5 Apr 2018 16:31:44 -0700 Subject: fixing file pointer and attributes issues --- README | 1 + libcuda/cuda_runtime_api.cc | 34 ++++++++++++++++++++++++++++++++-- src/cuda-sim/cuda-sim.cc | 1 + src/cuda-sim/ptx_loader.cc | 5 ++--- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/README b/README index 4426cdd..543177c 100644 --- a/README +++ b/README @@ -349,6 +349,7 @@ process. ** Debugging failing GPGPU-Sim Regressions ** +Credits: Tor M Aamodt To debug failing GPGPU-Sim regression tests you need to run them locally. The fastest way to do this, assuming you are working with GPGPU-Sim versions more recent than the GPGPU-Sim dev branch circa March 28, 2018 (commit hash 2221d208a745a098a60b0d24c05007e92aaba092), is to install Docker. The instructions below were tested with Docker CE version 18.03 on Ubuntu and Mac OS. Docker will enable you to run the same set of regressions used by GPGPU-Sim when submitting a pull request to https://github.com/gpgpu-sim/gpgpu-sim_distribution and also allow you to log in and launch GPGPU-Sim in gdb so you can inspect failures. diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index c103244..3fd88dc 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -349,7 +349,15 @@ class _cuda_device_id *GPGPUSim_Init() prop->maxGridSize[2] = 0x40000000; prop->totalConstMem = 0x40000000; prop->textureAlignment = 0; - prop->sharedMemPerBlock = the_gpu->shared_mem_size(); + /* + * TODO: Update the .config and xml files of all GPU config files with new value of sharedMemPerBlock. + * Previously, this was thought as sharedMemPerMultiprocessor and is being used in many places. + * Check whether all the instances of shared_mem_size(), gpgpu_shmem_size or sharedMemPerBlock are meant to use sharedMemPerBlock or sharedMemPerMultiprocessor. + */ + prop->sharedMemPerBlock = 49152; +#if (CUDART_VERSION > 5000) + prop->sharedMemPerMultiprocessor = the_gpu->shared_mem_size(); +#endif prop->regsPerBlock = the_gpu->num_registers_per_core(); prop->warpSize = the_gpu->wrp_size(); prop->clockRate = the_gpu->shader_clock(); @@ -840,6 +848,15 @@ __host__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDevic if (device <= dev->num_devices() ) { prop = dev->get_prop(); switch (attr) { + 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; @@ -849,6 +866,12 @@ __host__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDevic 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; @@ -861,11 +884,14 @@ __host__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDevic case 16: *value= prop->multiProcessorCount ; break; + case 34: + *value= 0; + break; case 39: *value= dev->get_gpgpu()->threads_per_core(); break; case 75: - *value= 8 ; + *value= 9 ; break; case 76: *value= 3 ; @@ -873,6 +899,9 @@ __host__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDevic case 78: *value= 0 ; //TODO: as of now, we dont support stream priorities. break; + case 81: + *value= prop->sharedMemPerMultiprocessor; + break; default: printf("ERROR: implement the attribute numbered %d \n",attr); abort(); @@ -1882,6 +1911,7 @@ void cuobjdumpParseBinary(unsigned int handle){ if (capability > max_capability) max_capability = capability; } if (max_capability > 20) printf("WARNING: No guarantee that PTX will be parsed for SM version %u\n", max_capability); + max_capability=context->get_device()->get_gpgpu()->get_config().get_forced_max_capability(); cuobjdumpPTXSection* ptx = NULL; const char* pre_load = getenv("CUOBJDUMP_SIM_FILE"); diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc index dce35ca..b1eaf01 100644 --- a/src/cuda-sim/cuda-sim.cc +++ b/src/cuda-sim/cuda-sim.cc @@ -2155,3 +2155,4 @@ void functionalCoreSim::warp_exit( unsigned warp_id ) } } } + diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc index 4ddc6bf..33a4260 100644 --- a/src/cuda-sim/ptx_loader.cc +++ b/src/cuda-sim/ptx_loader.cc @@ -423,6 +423,7 @@ void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num snprintf(commandline,1024,"$CUDA_INSTALL_PATH/bin/ptxas %s -v %s --output-file /dev/null 2> %s", extra_flags, fname2, tempfile_ptxinfo); printf("GPGPU-Sim PTX: generating ptxinfo using \"%s\"\n", commandline); + fflush(stdout); result = system(commandline); if( result != 0 ) { printf("GPGPU-Sim PTX: ERROR ** while loading PTX (b) %d\n", result); @@ -443,14 +444,12 @@ void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num } } - ptxinfo_in = fopen(final_tempfile_ptxinfo,"r"); if(no_of_ptx>0) g_ptxinfo_filename = final_tempfile_ptxinfo; else g_ptxinfo_filename = tempfile_ptxinfo; + ptxinfo_in = fopen(g_ptxinfo_filename,"r"); - //The program might get stuck because the parser didnt receive a EOF. - printf("NOTE: If the program is stuck, please press ctrl+d for Ubuntu/Mac and ctrl+z for Windows users \n"); ptxinfo_parse(); snprintf(commandline,1024,"rm -f *info"); -- cgit v1.3 From 2f9cdd0ac0954bae8822d0cfdb68fa4173087c1b Mon Sep 17 00:00:00 2001 From: Amruth Date: Fri, 6 Apr 2018 11:22:48 -0700 Subject: fixing arch flags --- libcuda/cuda_runtime_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index 3fd88dc..184325c 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -1911,7 +1911,7 @@ void cuobjdumpParseBinary(unsigned int handle){ if (capability > max_capability) max_capability = capability; } if (max_capability > 20) printf("WARNING: No guarantee that PTX will be parsed for SM version %u\n", max_capability); - max_capability=context->get_device()->get_gpgpu()->get_config().get_forced_max_capability(); + //max_capability=context->get_device()->get_gpgpu()->get_config().get_forced_max_capability(); cuobjdumpPTXSection* ptx = NULL; const char* pre_load = getenv("CUOBJDUMP_SIM_FILE"); -- cgit v1.3 From c99a4ff88ecf7f69715939d96c1fa8152eee524c Mon Sep 17 00:00:00 2001 From: Amruth Date: Wed, 11 Apr 2018 11:05:12 -0700 Subject: PDOM analysis for child kernel in CDP --- src/cuda-sim/cuda_device_runtime.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/cuda-sim/cuda_device_runtime.cc b/src/cuda-sim/cuda_device_runtime.cc index 4a8ffe5..b399133 100644 --- a/src/cuda-sim/cuda_device_runtime.cc +++ b/src/cuda-sim/cuda_device_runtime.cc @@ -177,6 +177,20 @@ void gpgpusim_cuda_launchDeviceV2(const ptx_instruction * pI, ptx_thread_info * //device_grid = op.grid; device_kernel_entry = config.entry; DEV_RUNTIME_REPORT("find device kernel " << device_kernel_entry->get_name()); + + //PDOM analysis is done for Parent kernel but not for child kernel. + if (device_kernel_entry->is_pdom_set()) { + printf("GPGPU-Sim PTX: PDOM analysis already done for %s \n", device_kernel_entry->get_name().c_str() ); + } else { + printf("GPGPU-Sim PTX: finding reconvergence points for \'%s\'...\n", device_kernel_entry->get_name().c_str() ); + /* + * Some of the instructions like printf() gives the gpgpusim the wrong impression that it is a function call. + * As printf() doesnt have a body like functions do, doing pdom analysis for printf() causes a crash. + */ + if (device_kernel_entry->get_function_size() >0) + device_kernel_entry->do_pdom(); + device_kernel_entry->set_pdom(); + } //copy data in parameter_buffer to device kernel param memory unsigned device_kernel_arg_size = device_kernel_entry->get_args_aligned_size(); -- cgit v1.3 From f118b10cc49bf771755f2afdee04cde0359d745e Mon Sep 17 00:00:00 2001 From: Amruth Date: Wed, 11 Apr 2018 12:07:34 -0700 Subject: clean up --- libcuda/cuda_runtime_api.cc | 36 +++--------------------------------- src/cuda-sim/cuda-sim.cc | 1 - 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index 184325c..abdc345 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -349,15 +349,7 @@ class _cuda_device_id *GPGPUSim_Init() prop->maxGridSize[2] = 0x40000000; prop->totalConstMem = 0x40000000; prop->textureAlignment = 0; - /* - * TODO: Update the .config and xml files of all GPU config files with new value of sharedMemPerBlock. - * Previously, this was thought as sharedMemPerMultiprocessor and is being used in many places. - * Check whether all the instances of shared_mem_size(), gpgpu_shmem_size or sharedMemPerBlock are meant to use sharedMemPerBlock or sharedMemPerMultiprocessor. - */ - prop->sharedMemPerBlock = 49152; -#if (CUDART_VERSION > 5000) - prop->sharedMemPerMultiprocessor = the_gpu->shared_mem_size(); -#endif + prop->sharedMemPerBlock = the_gpu->shared_mem_size(); prop->regsPerBlock = the_gpu->num_registers_per_core(); prop->warpSize = the_gpu->wrp_size(); prop->clockRate = the_gpu->shader_clock(); @@ -848,17 +840,8 @@ __host__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDevic if (device <= dev->num_devices() ) { prop = dev->get_prop(); switch (attr) { - 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]; + *value= prop->maxGridSize[1]; break; case 6: *value= prop->maxGridSize[1]; @@ -866,12 +849,6 @@ __host__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDevic 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; @@ -884,14 +861,11 @@ __host__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDevic case 16: *value= prop->multiProcessorCount ; break; - case 34: - *value= 0; - break; case 39: *value= dev->get_gpgpu()->threads_per_core(); break; case 75: - *value= 9 ; + *value= 8 ; break; case 76: *value= 3 ; @@ -899,9 +873,6 @@ __host__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDevic case 78: *value= 0 ; //TODO: as of now, we dont support stream priorities. break; - case 81: - *value= prop->sharedMemPerMultiprocessor; - break; default: printf("ERROR: implement the attribute numbered %d \n",attr); abort(); @@ -1911,7 +1882,6 @@ void cuobjdumpParseBinary(unsigned int handle){ if (capability > max_capability) max_capability = capability; } if (max_capability > 20) printf("WARNING: No guarantee that PTX will be parsed for SM version %u\n", max_capability); - //max_capability=context->get_device()->get_gpgpu()->get_config().get_forced_max_capability(); cuobjdumpPTXSection* ptx = NULL; const char* pre_load = getenv("CUOBJDUMP_SIM_FILE"); diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc index b1eaf01..dce35ca 100644 --- a/src/cuda-sim/cuda-sim.cc +++ b/src/cuda-sim/cuda-sim.cc @@ -2155,4 +2155,3 @@ void functionalCoreSim::warp_exit( unsigned warp_id ) } } } - -- cgit v1.3 From f052807cd6acfaf3221fbfe40ab905fd3aeaf2ef Mon Sep 17 00:00:00 2001 From: Amruth Date: Wed, 11 Apr 2018 19:11:47 +0000 Subject: cuda_runtime_api.cc edited online with Bitbucket --- libcuda/cuda_runtime_api.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index abdc345..dd32654 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -5,7 +5,7 @@ /* * cuda_runtime_api.cc * - * Copyright © 2009 by Tor M. Aamodt, Wilson W. L. Fung, Ali Bakhoda, + * 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. * @@ -841,7 +841,7 @@ __host__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDevic prop = dev->get_prop(); switch (attr) { case 5: - *value= prop->maxGridSize[1]; + *value= prop->maxGridSize[0]; break; case 6: *value= prop->maxGridSize[1]; -- cgit v1.3 From 90a0a1e4093df69505d0ffc0b08eedc9d0355ac3 Mon Sep 17 00:00:00 2001 From: Amruth Date: Wed, 11 Apr 2018 19:55:24 +0000 Subject: Copyright symbol error --- libcuda/cuda_runtime_api.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index dd32654..c103244 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -5,7 +5,7 @@ /* * cuda_runtime_api.cc * - * Copyright © 2009 by Tor M. Aamodt, Wilson W. L. Fung, Ali Bakhoda, + * 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. * -- cgit v1.3