summaryrefslogtreecommitdiffstats
path: root/parallel-libs/streamexecutor/lib/PlatformManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'parallel-libs/streamexecutor/lib/PlatformManager.cpp')
-rw-r--r--parallel-libs/streamexecutor/lib/PlatformManager.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/parallel-libs/streamexecutor/lib/PlatformManager.cpp b/parallel-libs/streamexecutor/lib/PlatformManager.cpp
new file mode 100644
index 00000000000..9cae5b1ea4b
--- /dev/null
+++ b/parallel-libs/streamexecutor/lib/PlatformManager.cpp
@@ -0,0 +1,36 @@
+//===-- PlatformManager.cpp - PlatformManager implementation --------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of PlatformManager class internals.
+///
+//===----------------------------------------------------------------------===//
+
+#include "streamexecutor/PlatformManager.h"
+
+namespace streamexecutor {
+
+PlatformManager::PlatformManager() {
+ // TODO(jhen): Register known platforms by name.
+ // We have a couple of options here:
+ // * Use build-system flags to set preprocessor macros that select the
+ // appropriate code to include here.
+ // * Use static initialization tricks to have platform libraries register
+ // themselves when they are loaded.
+}
+
+Expected<Platform *> PlatformManager::getPlatformByName(llvm::StringRef Name) {
+ static PlatformManager Instance;
+ auto Iterator = Instance.PlatformsByName.find(Name.lower());
+ if (Iterator != Instance.PlatformsByName.end())
+ return Iterator->second.get();
+ return make_error("no available platform with name " + Name);
+}
+
+} // namespace streamexecutor
OpenPOWER on IntegriCloud