aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/stream_executor/lib/process_state.cc
diff options
context:
space:
mode:
authorGravatar Manjunath Kudlur <keveman@gmail.com>2015-11-06 16:27:58 -0800
committerGravatar Manjunath Kudlur <keveman@gmail.com>2015-11-06 16:27:58 -0800
commitf41959ccb2d9d4c722fe8fc3351401d53bcf4900 (patch)
treeef0ca22cb2a5ac4bdec9d080d8e0788a53ed496d /tensorflow/stream_executor/lib/process_state.cc
TensorFlow: Initial commit of TensorFlow library.
TensorFlow is an open source software library for numerical computation using data flow graphs. Base CL: 107276108
Diffstat (limited to 'tensorflow/stream_executor/lib/process_state.cc')
-rw-r--r--tensorflow/stream_executor/lib/process_state.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/tensorflow/stream_executor/lib/process_state.cc b/tensorflow/stream_executor/lib/process_state.cc
new file mode 100644
index 0000000000..c20493b263
--- /dev/null
+++ b/tensorflow/stream_executor/lib/process_state.cc
@@ -0,0 +1,37 @@
+#include "tensorflow/stream_executor/lib/process_state.h"
+
+#include <unistd.h>
+
+#include <memory>
+
+namespace perftools {
+namespace gputools {
+namespace port {
+
+string Hostname() {
+ char hostname[1024];
+ gethostname(hostname, sizeof hostname);
+ hostname[sizeof hostname - 1] = 0;
+ return hostname;
+}
+
+bool GetCurrentDirectory(string* dir) {
+ size_t len = 128;
+ std::unique_ptr<char[]> a(new char[len]);
+ for (;;) {
+ char* p = getcwd(a.get(), len);
+ if (p != NULL) {
+ *dir = p;
+ return true;
+ } else if (errno == ERANGE) {
+ len += len;
+ a.reset(new char[len]);
+ } else {
+ return false;
+ }
+ }
+}
+
+} // namespace port
+} // namespace gputools
+} // namespace perftools