summaryrefslogtreecommitdiff
path: root/libcuda/cuda_runtime_api.cc
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 /libcuda/cuda_runtime_api.cc
parentbf144db8307cf7e992d2898a2a54d17f873411fe (diff)
enable CUBIN parsing on Mac OS X
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 14882]
Diffstat (limited to 'libcuda/cuda_runtime_api.cc')
-rw-r--r--libcuda/cuda_runtime_api.cc16
1 files changed, 13 insertions, 3 deletions
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;
}