summaryrefslogtreecommitdiff
path: root/libcuda/cuda_runtime_api.cc
diff options
context:
space:
mode:
authorWilson Fung <[email protected]>2012-08-26 01:41:15 -0800
committerAndrew Boktor <[email protected]>2014-08-14 13:48:54 -0700
commitded1542c5d71a60673f30a593415bae3c46150ce (patch)
treea22ce8ab40e9832e1a5be55c6153c225cd86542a /libcuda/cuda_runtime_api.cc
parent97beb988d6e1dd520d0eca8c42b639796a0aa3ac (diff)
Allowing cuobjdump on the executable to return error when experimental library support is enabled. This fixes the crash for applications that exclusively use kernels from CUDA libraries and do not contain kernels in their own executables.
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 13867]
Diffstat (limited to 'libcuda/cuda_runtime_api.cc')
-rw-r--r--libcuda/cuda_runtime_api.cc62
1 files changed, 53 insertions, 9 deletions
diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc
index 011fef3..29fc873 100644
--- a/libcuda/cuda_runtime_api.cc
+++ b/libcuda/cuda_runtime_api.cc
@@ -1098,6 +1098,31 @@ int CUDARTAPI __cudaSynchronizeThreads(void**, void*)
+/*******************************************************************************
+ * *
+ * *
+ * *
+ *******************************************************************************/
+
+typedef struct CUuuid_st { /**< CUDA definition of UUID */
+ char bytes[16];
+} CUuuid;
+
+/**
+ * CUDA UUID types
+ */
+// typedef __device_builtin__ struct CUuuid_st cudaUUID_t;
+
+__host__ cudaError_t CUDARTAPI cudaGetExportTable(const void **ppExportTable, const cudaUUID_t *pExportTableId)
+{
+ printf("cudaGetExportTable: UUID = ");
+ for (int s = 0; s < 16; s++) {
+ printf("%#2x ", (unsigned char) (pExportTableId->bytes[s]));
+ }
+ printf("\n");
+ return g_last_cudaError = cudaSuccess;
+}
+
/*******************************************************************************
@@ -1238,24 +1263,43 @@ void extract_code_using_cuobjdump(){
CUctx_st *context = GPGPUSim_Context();
char command[1000];
+ std::stringstream pid;
+ pid << getpid();
+
char fname[1024];
snprintf(fname,1024,"_cuobjdump_complete_output_XXXXXX");
int fd=mkstemp(fname);
close(fd);
- std::stringstream pid;
- pid << getpid();
// Running cuobjdump using dynamic link to current process
snprintf(command,1000,"$CUDA_INSTALL_PATH/bin/cuobjdump -ptx -elf -sass /proc/%s/exe > %s",pid.str().c_str(),fname);
printf("Running cuobjdump using \"%s\"\n", command);
+ bool parse_output = true;
int result = system(command);
- if(result) {printf("ERROR: Failed to execute: %s\n", command); exit(1);}
+ if(result) {
+ if (context->get_device()->get_gpgpu()->get_config().experimental_lib_support() && (result == 65280)) {
+ // Some CUDA application may exclusively use kernels provided by CUDA
+ // libraries (e.g. CUBLAS). Skipping cuobjdump extraction from the
+ // executable for this case.
+ // 65280 is the return code from cuobjdump denoting the specific error (tested on CUDA 4.0/4.1/4.2)
+ printf("WARNING: Failed to execute: %s\n", command);
+ printf(" Executable binary does not contain any GPU kernel.\n");
+ parse_output = false;
+ } else {
+ printf("ERROR: Failed to execute: %s\n", command);
+ exit(1);
+ }
+ }
- printf("Parsing file %s\n", fname);
- cuobjdump_in = fopen(fname, "r");
+ if (parse_output) {
+ printf("Parsing file %s\n", fname);
+ cuobjdump_in = fopen(fname, "r");
- cuobjdump_parse();
- fclose(cuobjdump_in);
- printf("Done parsing!!!\n");
+ cuobjdump_parse();
+ fclose(cuobjdump_in);
+ printf("Done parsing!!!\n");
+ } else {
+ printf("Parsing skipped for %s\n", fname);
+ }
if (context->get_device()->get_gpgpu()->get_config().experimental_lib_support()){
//Experimental library support
@@ -1263,7 +1307,7 @@ void extract_code_using_cuobjdump(){
std::stringstream cmd;
cmd << "ldd /proc/" << pid.str() << "/exe | grep $CUDA_INSTALL_PATH | awk \'{print $3}\' > _tempfile_.txt";
- result = system(cmd.str().c_str());
+ int result = system(cmd.str().c_str());
if(result){
std::cout << "Failed to execute: " << cmd << std::endl;
exit(1);