summaryrefslogtreecommitdiffstats
path: root/parallel-libs/streamexecutor/lib/Kernel.cpp
blob: fa0992003a6f4c7e0df16bb53cf7015ade840b5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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/Device.h"
#include "streamexecutor/PlatformInterfaces.h"

#include "llvm/DebugInfo/Symbolize/Symbolize.h"

namespace streamexecutor {

KernelBase::KernelBase(Device *Dev, const std::string &Name,
                       const std::string &DemangledName,
                       std::unique_ptr<KernelInterface> Implementation)
    : TheDevice(Dev), Name(Name), DemangledName(DemangledName),
      Implementation(std::move(Implementation)) {}

KernelBase::~KernelBase() = default;

Expected<KernelBase> KernelBase::create(Device *Dev,
                                        const MultiKernelLoaderSpec &Spec) {
  auto MaybeImplementation = Dev->getKernelImplementation(Spec);
  if (!MaybeImplementation) {
    return MaybeImplementation.takeError();
  }
  std::string Name = Spec.getKernelName();
  std::string DemangledName =
      llvm::symbolize::LLVMSymbolizer::DemangleName(Name, nullptr);
  KernelBase Instance(Dev, Name, DemangledName,
                      std::move(*MaybeImplementation));
  return std::move(Instance);
}

} // namespace streamexecutor
OpenPOWER on IntegriCloud