summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcuda/cuda_api_object.h1
-rw-r--r--libcuda/cuda_runtime_api.cc42
-rw-r--r--libcuda/gpgpu_context.h3
-rw-r--r--libopencl/opencl_runtime_api.cc5
-rw-r--r--src/cuda-sim/ptx_loader.cc5
-rw-r--r--src/cuda-sim/ptx_loader.h2
6 files changed, 31 insertions, 27 deletions
diff --git a/libcuda/cuda_api_object.h b/libcuda/cuda_api_object.h
index f9a4fde..0054697 100644
--- a/libcuda/cuda_api_object.h
+++ b/libcuda/cuda_api_object.h
@@ -191,7 +191,6 @@ class cuda_runtime_api {
void cuobjdumpInit();
void extract_code_using_cuobjdump();
void extract_ptx_files_using_cuobjdump(CUctx_st *context);
- void cuobjdumpParseBinary(unsigned int handle);
std::list<cuobjdumpSection*> pruneSectionList(CUctx_st *context);
std::list<cuobjdumpSection*> mergeMatchingSections(std::string identifier);
std::list<cuobjdumpSection*> mergeSections();
diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc
index 09a13a7..25642a7 100644
--- a/libcuda/cuda_runtime_api.cc
+++ b/libcuda/cuda_runtime_api.cc
@@ -685,7 +685,7 @@ void cudaRegisterFunctionInternal(
printf("GPGPU-Sim PTX: __cudaRegisterFunction %s : hostFun 0x%p, fat_cubin_handle = %u\n",
deviceFun, hostFun, fat_cubin_handle);
if(context->get_device()->get_gpgpu()->get_config().use_cuobjdump())
- ctx->api->cuobjdumpParseBinary(fat_cubin_handle);
+ ctx->cuobjdumpParseBinary(fat_cubin_handle);
context->register_function( fat_cubin_handle, hostFun, deviceFun );
}
@@ -712,7 +712,7 @@ void cudaRegisterVarInternal(
printf("GPGPU-Sim PTX: __cudaRegisterVar: hostVar = %p; deviceAddress = %s; deviceName = %s\n", hostVar, deviceAddress, deviceName);
printf("GPGPU-Sim PTX: __cudaRegisterVar: Registering const memory space of %d bytes\n", size);
if(GPGPUSim_Context()->get_device()->get_gpgpu()->get_config().use_cuobjdump())
- ctx->api->cuobjdumpParseBinary((unsigned)(unsigned long long)fatCubinHandle);
+ ctx->cuobjdumpParseBinary((unsigned)(unsigned long long)fatCubinHandle);
fflush(stdout);
if ( constant && !global && !ext ) {
gpgpu_ptx_sim_register_const_variable(hostVar,deviceName,size);
@@ -1009,7 +1009,7 @@ cuLinkAddFileInternal(CUlinkState state, CUjitInputType type, const char *path,
}
strcat(file,"/");
strcat(file,path);
- symbol_table *symtab = gpgpu_ptx_sim_load_ptx_from_filename( file );
+ symbol_table *symtab = ctx->gpgpu_ptx_sim_load_ptx_from_filename( file );
std::string fname(path);
ctx->api->name_symtab[fname] = symtab;
context->add_binary(symtab, 1);
@@ -2750,15 +2750,15 @@ void cuda_runtime_api::cuobjdumpInit(){
//! Either submit PTX for simulation or convert SASS to PTXPlus and submit it
-void cuda_runtime_api::cuobjdumpParseBinary(unsigned int handle){
+void gpgpu_context::cuobjdumpParseBinary(unsigned int handle){
CUctx_st *context = GPGPUSim_Context();
- if(fatbin_registered[handle]) return;
- fatbin_registered[handle] = true;
- std::string fname = fatbinmap[handle];
+ if(api->fatbin_registered[handle]) return;
+ api->fatbin_registered[handle] = true;
+ std::string fname = api->fatbinmap[handle];
- if (name_symtab.find(fname) != name_symtab.end()) {
- symbol_table *symtab = name_symtab[fname];
+ if (api->name_symtab.find(fname) != api->name_symtab.end()) {
+ symbol_table *symtab = api->name_symtab[fname];
context->add_binary(symtab, handle);
return;
}
@@ -2767,7 +2767,7 @@ void cuda_runtime_api::cuobjdumpParseBinary(unsigned int handle){
#if (CUDART_VERSION >= 6000)
//loops through all ptx files from smallest sm version to largest
std::map<unsigned,std::set<std::string> >::iterator itr_m;
- for (itr_m = version_filename.begin(); itr_m!=version_filename.end(); itr_m++){
+ for (itr_m = api->version_filename.begin(); itr_m!=api->version_filename.end(); itr_m++){
std::set<std::string>::iterator itr_s;
for (itr_s = itr_m->second.begin(); itr_s!=itr_m->second.end(); itr_s++){
std::string ptx_filename = *itr_s;
@@ -2775,11 +2775,11 @@ void cuda_runtime_api::cuobjdumpParseBinary(unsigned int handle){
symtab = gpgpu_ptx_sim_load_ptx_from_filename( ptx_filename.c_str() );
}
}
- name_symtab[fname] = symtab;
+ api->name_symtab[fname] = symtab;
context->add_binary(symtab, handle);
- load_static_globals(symtab,STATIC_ALLOC_LIMIT,0xFFFFFFFF,context->get_device()->get_gpgpu());
- load_constants(symtab,STATIC_ALLOC_LIMIT,context->get_device()->get_gpgpu());
- for (itr_m = version_filename.begin(); itr_m!=version_filename.end(); itr_m++){
+ api->load_static_globals(symtab,STATIC_ALLOC_LIMIT,0xFFFFFFFF,context->get_device()->get_gpgpu());
+ api->load_constants(symtab,STATIC_ALLOC_LIMIT,context->get_device()->get_gpgpu());
+ for (itr_m = api->version_filename.begin(); itr_m!=api->version_filename.end(); itr_m++){
std::set<std::string>::iterator itr_s;
for (itr_s = itr_m->second.begin(); itr_s!=itr_m->second.end(); itr_s++){
std::string ptx_filename = *itr_s;
@@ -2791,8 +2791,8 @@ void cuda_runtime_api::cuobjdumpParseBinary(unsigned int handle){
#endif
unsigned max_capability = 0;
- for ( std::list<cuobjdumpSection*>::iterator iter = cuobjdumpSectionList.begin();
- iter != cuobjdumpSectionList.end();
+ for ( std::list<cuobjdumpSection*>::iterator iter = api->cuobjdumpSectionList.begin();
+ iter != api->cuobjdumpSectionList.end();
iter++){
unsigned capability = (*iter)->getArch();
if (capability > max_capability) max_capability = capability;
@@ -2803,7 +2803,7 @@ void cuda_runtime_api::cuobjdumpParseBinary(unsigned int handle){
cuobjdumpPTXSection* ptx = NULL;
const char* pre_load = getenv("CUOBJDUMP_SIM_FILE");
if(pre_load==NULL || strlen(pre_load)==0)
- ptx = findPTXSection(fname);
+ ptx = api->findPTXSection(fname);
char *ptxcode;
const char *override_ptx_name = getenv("PTX_SIM_KERNELFILE");
if (override_ptx_name == NULL or getenv("PTX_SIM_USE_PTX_FILE") == NULL or strlen(getenv("PTX_SIM_USE_PTX_FILE"))==0) {
@@ -2813,7 +2813,7 @@ void cuda_runtime_api::cuobjdumpParseBinary(unsigned int handle){
ptxcode = readfile(override_ptx_name);
}
if(context->get_device()->get_gpgpu()->get_config().convert_to_ptxplus() ) {
- cuobjdumpELFSection* elfsection = findELFSection(ptx->getIdentifier());
+ cuobjdumpELFSection* elfsection = api->findELFSection(ptx->getIdentifier());
assert (elfsection!= NULL);
char *ptxplus_str = gpgpu_ptx_sim_convert_ptx_and_sass_to_ptxplus(
ptx->getPTXfilename(),
@@ -2831,9 +2831,9 @@ void cuda_runtime_api::cuobjdumpParseBinary(unsigned int handle){
context->add_binary(symtab, handle);
gpgpu_ptxinfo_load_from_string( ptxcode, handle, max_capability, context->no_of_ptx );
}
- load_static_globals(symtab,STATIC_ALLOC_LIMIT,0xFFFFFFFF,context->get_device()->get_gpgpu());
- load_constants(symtab,STATIC_ALLOC_LIMIT,context->get_device()->get_gpgpu());
- name_symtab[fname] = symtab;
+ api->load_static_globals(symtab,STATIC_ALLOC_LIMIT,0xFFFFFFFF,context->get_device()->get_gpgpu());
+ api->load_constants(symtab,STATIC_ALLOC_LIMIT,context->get_device()->get_gpgpu());
+ api->name_symtab[fname] = symtab;
//TODO: Remove temporarily files as per configurations
}
diff --git a/libcuda/gpgpu_context.h b/libcuda/gpgpu_context.h
index 6c8a293..16626eb 100644
--- a/libcuda/gpgpu_context.h
+++ b/libcuda/gpgpu_context.h
@@ -11,6 +11,9 @@ class gpgpu_context {
// objects pointers for each file
cuda_runtime_api* api;
// member function list
+ void cuobjdumpParseBinary(unsigned int handle);
+ class symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source_num );
+ class symbol_table *gpgpu_ptx_sim_load_ptx_from_filename( const char *filename );
};
gpgpu_context* GPGPU_Context();
diff --git a/libopencl/opencl_runtime_api.cc b/libopencl/opencl_runtime_api.cc
index 97a54d8..0ec635e 100644
--- a/libopencl/opencl_runtime_api.cc
+++ b/libopencl/opencl_runtime_api.cc
@@ -84,6 +84,7 @@
#include "../src/gpgpusim_entrypoint.h"
#include "../src/gpgpu-sim/gpu-sim.h"
#include "../src/gpgpu-sim/shader.h"
+#include "../libcuda/gpgpu_context.h"
//# define __my_func__ __PRETTY_FUNCTION__
# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
@@ -424,6 +425,8 @@ void register_ptx_function( const char *name, function_info *impl )
void _cl_program::Build(const char *options)
{
+ gpgpu_context *ctx;
+ ctx = GPGPU_Context();
printf("GPGPU-Sim OpenCL API: compiling OpenCL kernels...\n");
std::map<cl_uint,pgm_info>::iterator i;
for( i = m_pgm.begin(); i!= m_pgm.end(); i++ ) {
@@ -576,7 +579,7 @@ void _cl_program::Build(const char *options)
}
}
info.m_asm = tmp;
- info.m_symtab = gpgpu_ptx_sim_load_ptx_from_string( tmp, source_num );
+ info.m_symtab = ctx->gpgpu_ptx_sim_load_ptx_from_string( tmp, source_num );
gpgpu_ptxinfo_load_from_string( tmp, source_num );
free(tmp);
}
diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc
index f037c34..d7e9b71 100644
--- a/src/cuda-sim/ptx_loader.cc
+++ b/src/cuda-sim/ptx_loader.cc
@@ -33,6 +33,7 @@
#include <dirent.h>
#include <fstream>
#include <sstream>
+#include "../../libcuda/gpgpu_context.h"
/// globals
@@ -165,7 +166,7 @@ char* gpgpu_ptx_sim_convert_ptx_and_sass_to_ptxplus(const std::string ptxfilenam
}
-symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source_num )
+symbol_table *gpgpu_context::gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source_num )
{
char buf[1024];
snprintf(buf,1024,"_%u.ptx", source_num );
@@ -200,7 +201,7 @@ symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source
return symtab;
}
-symbol_table *gpgpu_ptx_sim_load_ptx_from_filename( const char *filename )
+symbol_table *gpgpu_context::gpgpu_ptx_sim_load_ptx_from_filename( const char *filename )
{
symbol_table *symtab=init_parser(filename);
printf("GPGPU-Sim PTX: finished parsing EMBEDDED .ptx file %s\n",filename);
diff --git a/src/cuda-sim/ptx_loader.h b/src/cuda-sim/ptx_loader.h
index c4d8292..2af611a 100644
--- a/src/cuda-sim/ptx_loader.h
+++ b/src/cuda-sim/ptx_loader.h
@@ -42,8 +42,6 @@ class ptxinfo_data{
extern bool g_override_embedded_ptx;
extern int no_of_ptx; //counter to track number of ptx files to be extracted in an application.
-class symbol_table *gpgpu_ptx_sim_load_ptx_from_string( const char *p, unsigned source_num );
-class symbol_table *gpgpu_ptx_sim_load_ptx_from_filename( const char *filename );
void gpgpu_ptxinfo_load_from_string( const char *p_for_info, unsigned source_num, unsigned sm_version=20, int no_of_ptx=0 );
void gpgpu_ptx_info_load_from_filename( const char *filename, unsigned sm_version );
char* gpgpu_ptx_sim_convert_ptx_and_sass_to_ptxplus(const std::string ptx_str, const std::string sass_str, const std::string elf_str);