Files
llvm/parallel-libs/streamexecutor/lib/Kernel.cpp
Jason Henline 68b97c7dc9 [StreamExecutor] Add basic Stream operations
Summary: Add the Stream class and a few of the operations it supports.

Reviewers: jlebar, tra

Subscribers: jprice, parallel_libs-commits

Differential Revision: https://reviews.llvm.org/D23333

llvm-svn: 278829
2016-08-16 17:58:31 +00:00

46 lines
1.7 KiB
C++

//===-- 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/PlatformInterfaces.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