aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/stream_executor/cuda/cuda_platform.h
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/cuda/cuda_platform.h
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/cuda/cuda_platform.h')
-rw-r--r--tensorflow/stream_executor/cuda/cuda_platform.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/tensorflow/stream_executor/cuda/cuda_platform.h b/tensorflow/stream_executor/cuda/cuda_platform.h
new file mode 100644
index 0000000000..966d7343f7
--- /dev/null
+++ b/tensorflow/stream_executor/cuda/cuda_platform.h
@@ -0,0 +1,98 @@
+#ifndef TENSORFLOW_STREAM_EXECUTOR_CUDA_CUDA_PLATFORM_H_
+#define TENSORFLOW_STREAM_EXECUTOR_CUDA_CUDA_PLATFORM_H_
+
+#include <memory>
+#include "tensorflow/stream_executor/platform/port.h"
+#include <vector>
+
+#include "tensorflow/stream_executor/executor_cache.h"
+#include "tensorflow/stream_executor/lib/statusor.h"
+#include "tensorflow/stream_executor/multi_platform_manager.h"
+#include "tensorflow/stream_executor/platform.h"
+#include "tensorflow/stream_executor/platform/mutex.h"
+#include "tensorflow/stream_executor/platform/port.h"
+#include "tensorflow/stream_executor/platform/thread_annotations.h"
+#include "tensorflow/stream_executor/stream_executor_internal.h"
+#include "tensorflow/stream_executor/stream_executor_pimpl.h"
+#include "tensorflow/stream_executor/trace_listener.h"
+
+namespace perftools {
+namespace gputools {
+namespace cuda {
+
+// Opaque and unique identifier for the CUDA platform plugin.
+// This is needed so that plugins can refer to/identify this platform without
+// instantiating a CudaPlatform object.
+extern const Platform::Id kCudaPlatformId;
+
+// Cuda-specific platform plugin, registered as a singleton value via module
+// initializer.
+class CudaPlatform : public Platform {
+ public:
+ CudaPlatform();
+ ~CudaPlatform() override;
+
+ // CudaPlatform-specific functionality
+ // Returns the number of distinct buses / NUMA nodes on the machine.
+ int BusCount();
+
+ // Returns the bus/NUMA node for the specified device ordinal.
+ int DeviceToBus(int device_ordinal);
+
+ // Returns the lowest-ordinal-number StreamExecutor on the specified bus.
+ port::StatusOr<StreamExecutor*> FirstExecutorForBus(int bus_ordinal);
+
+ // Platform interface implementation:
+ // Returns the same value as kCudaPlatform above.
+ Platform::Id id() const override;
+
+ // Returns -1 as a sentinel on internal failure (and logs the error).
+ int VisibleDeviceCount() const override;
+
+ const string& Name() const override;
+
+ port::StatusOr<StreamExecutor*> ExecutorForDevice(int ordinal) override;
+
+ port::StatusOr<StreamExecutor*> ExecutorForDeviceWithPluginConfig(
+ int ordinal, const PluginConfig& config) override;
+
+ port::StatusOr<StreamExecutor*> GetExecutor(
+ const StreamExecutorConfig& config) override;
+
+ port::StatusOr<std::unique_ptr<StreamExecutor>> GetUncachedExecutor(
+ const StreamExecutorConfig& config) override;
+
+ void RegisterTraceListener(std::unique_ptr<TraceListener> listener) override;
+
+ void UnregisterTraceListener(TraceListener* listener) override;
+
+ private:
+ // Determines the number of NUMA nodes and the assignment of executor to each.
+ void InspectNumaNodes();
+
+ // This platform's name.
+ string name_;
+
+ // mutex that guards internal state.
+ mutable mutex mu_;
+
+ // Cache of created executors.
+ ExecutorCache executor_cache_;
+
+ // The smallest NUMA node value for any device managed by this machine
+ // manager. Used, along with limit_numa_node_, to convert NUMA nodes into bus
+ // ordinals. The NUMA node space occupied by GPUs is assumed to be dense./
+ int min_numa_node_;
+
+ // Larger than the NUMA node value for any device managed by this machine
+ // manager.
+ int limit_numa_node_;
+
+ SE_DISALLOW_COPY_AND_ASSIGN(CudaPlatform);
+};
+
+} // namespace cuda
+} // namespace gputools
+} // namespace perftools
+
+#endif // TENSORFLOW_STREAM_EXECUTOR_CUDA_CUDA_PLATFORM_H_