mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 11:35:51 -04:00

Summary: Basic CUDA platform implementation and cmake infrastructure to control whether it's used. A few important TODOs will be handled in later patches: * Log some error messages that can't easily be returned as Errors. * Cache modules and kernels to prevent reloading them if someone tries to reload a kernel that's already loaded. * Tolerate shared memory arguments for kernel launches. Reviewers: jlebar Subscribers: beanz, mgorny, jprice, jlebar, parallel_libs-commits Differential Revision: https://reviews.llvm.org/D24538 llvm-svn: 281524
50 lines
1.7 KiB
C++
50 lines
1.7 KiB
C++
//===-- 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"
|
|
|
|
#include "streamexecutor/PlatformOptions.h"
|
|
#include "streamexecutor/platforms/host/HostPlatform.h"
|
|
|
|
#ifdef STREAM_EXECUTOR_ENABLE_CUDA_PLATFORM
|
|
#include "streamexecutor/platforms/cuda/CUDAPlatform.h"
|
|
#endif
|
|
|
|
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.
|
|
|
|
PlatformsByName.emplace("host", llvm::make_unique<host::HostPlatform>());
|
|
|
|
#ifdef STREAM_EXECUTOR_ENABLE_CUDA_PLATFORM
|
|
PlatformsByName.emplace("cuda", llvm::make_unique<cuda::CUDAPlatform>());
|
|
#endif
|
|
}
|
|
|
|
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
|