summaryrefslogtreecommitdiff
path: root/libcuda/cuda_runtime_api.cc
diff options
context:
space:
mode:
authorspeverel <[email protected]>2017-08-17 16:08:03 -0700
committerspeverel <[email protected]>2017-08-17 16:08:03 -0700
commite247912d9e8fc3ab779b58eb99721b6f536a6b35 (patch)
tree964f6b1fe349723a4c70241ce84e8e32d30a2563 /libcuda/cuda_runtime_api.cc
parent45f95f05a11e916933480422b9075767a4cfdf90 (diff)
parent21ad40b4918f08bf8508487b9aab700948fe8c84 (diff)
Merged all work on the dev branch since the divergence point into the dnn branch, incorporating Dynamic Parallelism and many bug fixes.
Diffstat (limited to 'libcuda/cuda_runtime_api.cc')
-rw-r--r--libcuda/cuda_runtime_api.cc48
1 files changed, 40 insertions, 8 deletions
diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc
index e8a0e91..cbe8a11 100644
--- a/libcuda/cuda_runtime_api.cc
+++ b/libcuda/cuda_runtime_api.cc
@@ -126,7 +126,9 @@
#include "host_defines.h"
#include "builtin_types.h"
#include "driver_types.h"
+#if (CUDART_VERSION < 8000)
#include "__cudaFatFormat.h"
+#endif
#include "../src/gpgpu-sim/gpu-sim.h"
#include "../src/cuda-sim/ptx_loader.h"
#include "../src/cuda-sim/cuda-sim.h"
@@ -262,10 +264,19 @@ struct CUctx_st {
{
if( m_code.find(fat_cubin_handle) != m_code.end() ) {
symbol *s = m_code[fat_cubin_handle]->lookup(deviceFun);
- assert( s != NULL );
- function_info *f = s->get_pc();
- assert( f != NULL );
- m_kernel_lookup[hostFun] = f;
+ if(s != NULL) {
+ function_info *f = s->get_pc();
+ assert( f != NULL );
+ m_kernel_lookup[hostFun] = f;
+ }
+ else {
+ printf("Warning: cannot find deviceFun %s\n", deviceFun);
+ m_kernel_lookup[hostFun] = NULL;
+ }
+ // assert( s != NULL );
+ // function_info *f = s->get_pc();
+ // assert( f != NULL );
+ // m_kernel_lookup[hostFun] = f;
} else {
m_kernel_lookup[hostFun] = NULL;
}
@@ -1353,7 +1364,12 @@ void extract_code_using_cuobjdump(){
printf("Running md5sum using \"%s\"\n", command);
system(command);
// Running cuobjdump using dynamic link to current process
- snprintf(command,1000,"$CUDA_INSTALL_PATH/bin/cuobjdump -ptx -elf -sass %s > %s", app_binary.c_str(), fname);
+ // Needs the option '-all' to extract PTX from CDP-enabled binary
+ extern bool g_cdp_enabled;
+ if(!g_cdp_enabled)
+ snprintf(command,1000,"$CUDA_INSTALL_PATH/bin/cuobjdump -ptx -elf -sass %s > %s", app_binary.c_str(), fname);
+ else
+ snprintf(command,1000,"$CUDA_INSTALL_PATH/bin/cuobjdump -ptx -elf -sass -all %s > %s", app_binary.c_str(), fname);
bool parse_output = true;
int result = system(command);
if(result) {
@@ -1618,7 +1634,7 @@ cuobjdumpELFSection* findELFSection(const std::string identifier){
if (sec!=NULL)return sec;
sec = findELFSectionInList(libSectionList, identifier);
if (sec!=NULL)return sec;
- std::cout << "Cound not find " << identifier << std::endl;
+ std::cout << "Could not find " << identifier << std::endl;
assert(0 && "Could not find the required ELF section");
return NULL;
}
@@ -1634,6 +1650,14 @@ cuobjdumpPTXSection* findPTXSectionInList(std::list<cuobjdumpSection*> sectionli
if((ptxsection=dynamic_cast<cuobjdumpPTXSection*>(*iter)) != NULL){
if(ptxsection->getIdentifier() == identifier)
return ptxsection;
+ else {
+ extern bool g_cdp_enabled;
+ if(g_cdp_enabled) {
+ printf("Warning: __cudaRegisterFatBinary needs %s, but find PTX section with %s\n",
+ identifier.c_str(), ptxsection->getIdentifier().c_str());
+ return ptxsection;
+ }
+ }
}
}
return NULL;
@@ -1645,7 +1669,7 @@ cuobjdumpPTXSection* findPTXSection(const std::string identifier){
if (sec!=NULL)return sec;
sec = findPTXSectionInList(libSectionList, identifier);
if (sec!=NULL)return sec;
- std::cout << "Cound not find " << identifier << std::endl;
+ std::cout << "Could not find " << identifier << std::endl;
assert(0 && "Could not find the required PTX section");
return NULL;
}
@@ -1773,7 +1797,9 @@ void** CUDARTAPI __cudaRegisterFatBinary( void *fatCubin )
cuobjdumpRegisterFatBinary(fat_cubin_handle, filename);
return (void**)fat_cubin_handle;
- } else {
+ }
+ #if (CUDART_VERSION < 8000)
+ else {
static unsigned source_num=1;
unsigned long long fat_cubin_handle = next_fat_bin_handle++;
__cudaFatCudaBinary *info = (__cudaFatCudaBinary *)fatCubin;
@@ -1830,6 +1856,7 @@ void** CUDARTAPI __cudaRegisterFatBinary( void *fatCubin )
}
return (void**)fat_cubin_handle;
}
+ #endif
}
void __cudaUnregisterFatBinary(void **fatCubinHandle)
@@ -2119,6 +2146,11 @@ __host__ cudaError_t CUDARTAPI cudaFuncSetCacheConfig(const char *func, enum cud
context->get_device()->get_gpgpu()->set_cache_config(context->get_kernel(func)->get_name(), (FuncCache)cacheConfig);
return g_last_cudaError = cudaSuccess;
}
+
+//Jin: hack for cdp
+__host__ cudaError_t CUDARTAPI cudaDeviceSetLimit(enum cudaLimit limit, size_t value) {
+ return g_last_cudaError = cudaSuccess;
+}
#endif
#endif