summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Aamodt <[email protected]>2012-12-24 10:13:40 -0800
committerAndrew Boktor <[email protected]>2014-08-14 13:49:24 -0700
commitf2d7b79e26f8766a220ab07f8de3df603de9263c (patch)
treeef386cca0816fa7695b2511d2a97acd43008ab2f
parentbf144db8307cf7e992d2898a2a54d17f873411fe (diff)
enable CUBIN parsing on Mac OS X
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 14882]
-rw-r--r--CHANGES2
-rw-r--r--libcuda/cuda_runtime_api.cc16
-rw-r--r--setup_environment5
3 files changed, 18 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index 042330c..d7f103b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
LOG:
Version 3.1.2+edits (development branch) versus 3.1.2
- Added GPUWattch GPGPU power model based on McPAT 0.8beta.
+- Bug Fixes:
+ - fix CUBIN parsing on Mac OS X
Version 3.1.2 versus 3.1.1
- Added support for CUDA 4.1 and 4.2 (PTX 3.0).
diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc
index 4739f64..7535fa3 100644
--- a/libcuda/cuda_runtime_api.cc
+++ b/libcuda/cuda_runtime_api.cc
@@ -137,6 +137,10 @@
#include <pthread.h>
#include <semaphore.h>
+#ifdef __APPLE__
+#include <mach-o/dyld.h>
+#endif
+
extern void synchronize();
extern void exit_simulation();
@@ -1260,17 +1264,23 @@ extern "C" FILE *cuobjdump_in;
//! executable instead of the application binary.
//!
std::string get_app_binary(){
+ char self_exe_path[1025];
+#ifdef __APPLE__
+ uint32_t size = sizeof(self_exe_path);
+ if( _NSGetExecutablePath(self_exe_path,&size) != 0 ) {
+ printf("GPGPU-Sim ** ERROR: _NSGetExecutablePath input buffer too small\n");
+ exit(1);
+ }
+#else
std::stringstream exec_link;
- // exec_link << "/proc/" << getpid() << "/exe";
exec_link << "/proc/self/exe";
- char self_exe_path[1025];
ssize_t path_length = readlink(exec_link.str().c_str(), self_exe_path, 1024);
assert(path_length != -1);
self_exe_path[path_length] = '\0';
+#endif
printf("self exe links to: %s\n", self_exe_path);
-
return self_exe_path;
}
diff --git a/setup_environment b/setup_environment
index 8298965..99441e1 100644
--- a/setup_environment
+++ b/setup_environment
@@ -72,11 +72,12 @@ fi
# against instead of the CUDA toolkit. This replaces this cumbersome
# static link setup in prior GPGPU-Sim releases.
if [ `uname` = "Darwin" ]; then
- export LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH | sed -Ee 's/.*gpgpu_sim.*(release|debug)://'`
+ export DYLD_LIBRARY_PATH=`echo $DYLD_LIBRARY_PATH | sed -Ee 's/.*gpgpu_sim.*(release|debug)://'`
+ export DYLD_LIBRARY_PATH=$GPGPUSIM_ROOT/lib/$GPGPUSIM_CONFIG:$DYLD_LIBRARY_PATH
else
export LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH | sed -re 's/.*gpgpu_sim.*(release|debug)://'`
+ export LD_LIBRARY_PATH=$GPGPUSIM_ROOT/lib/$GPGPUSIM_CONFIG:$LD_LIBRARY_PATH
fi
-export LD_LIBRARY_PATH=$GPGPUSIM_ROOT/lib/$GPGPUSIM_CONFIG:$LD_LIBRARY_PATH
# The following sets OPENCL_REMOTE_GPU_HOST which is used by GPGPU-Sim to