summaryrefslogtreecommitdiffstats
path: root/parallel-libs/streamexecutor/lib/Kernel.cpp
diff options
context:
space:
mode:
authorJason Henline <jhen@google.com>2016-08-05 16:05:44 +0000
committerJason Henline <jhen@google.com>2016-08-05 16:05:44 +0000
commit7b1fbead89a8a9998e088af0706b6bf63167ebe8 (patch)
tree45175d8de9a0985791eff03ff776b0eca0871961 /parallel-libs/streamexecutor/lib/Kernel.cpp
parent2a06f48bb5bf484bdc4b25ab459e3ba960d6368b (diff)
downloadbcm5719-llvm-7b1fbead89a8a9998e088af0706b6bf63167ebe8.tar.gz
bcm5719-llvm-7b1fbead89a8a9998e088af0706b6bf63167ebe8.zip
[StreamExecutor] Add kernel types
Summary: Add StreamExecutor kernel types. Reviewers: jlebar, tra Subscribers: parallel_libs-commits Differential Revision: https://reviews.llvm.org/D23138 llvm-svn: 277827
Diffstat (limited to 'parallel-libs/streamexecutor/lib/Kernel.cpp')
-rw-r--r--parallel-libs/streamexecutor/lib/Kernel.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/parallel-libs/streamexecutor/lib/Kernel.cpp b/parallel-libs/streamexecutor/lib/Kernel.cpp
new file mode 100644
index 00000000000..af95bbe820d
--- /dev/null
+++ b/parallel-libs/streamexecutor/lib/Kernel.cpp
@@ -0,0 +1,45 @@
+//===-- Kernel.cpp - General kernel implementation ------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation details for kernel types.
+///
+//===----------------------------------------------------------------------===//
+
+#include "streamexecutor/Kernel.h"
+#include "streamexecutor/Interfaces.h"
+#include "streamexecutor/StreamExecutor.h"
+
+#include "llvm/DebugInfo/Symbolize/Symbolize.h"
+
+namespace streamexecutor {
+
+KernelBase::KernelBase(StreamExecutor *ParentExecutor, const std::string &Name,
+ const std::string &DemangledName,
+ std::unique_ptr<KernelInterface> Implementation)
+ : ParentExecutor(ParentExecutor), Name(Name), DemangledName(DemangledName),
+ Implementation(std::move(Implementation)) {}
+
+KernelBase::~KernelBase() = default;
+
+Expected<KernelBase> KernelBase::create(StreamExecutor *ParentExecutor,
+ const MultiKernelLoaderSpec &Spec) {
+ auto MaybeImplementation = ParentExecutor->getKernelImplementation(Spec);
+ if (!MaybeImplementation) {
+ return MaybeImplementation.takeError();
+ }
+ std::string Name = Spec.getKernelName();
+ std::string DemangledName =
+ llvm::symbolize::LLVMSymbolizer::DemangleName(Name, nullptr);
+ KernelBase Instance(ParentExecutor, Name, DemangledName,
+ std::move(*MaybeImplementation));
+ return std::move(Instance);
+}
+
+} // namespace streamexecutor
OpenPOWER on IntegriCloud