blob: 7d0de12528d5c470c2d7bbc0fb08ec2141725cb0 [file] [log] [blame]
//===-- PlatformManager.h - The PlatformManager class -----------*- C++ -*-===//
// The LLVM Compiler Infrastructure
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
/// \file
/// PlatformManager is the entry point into the StreamExecutor API. A user
/// begins be calling PlatformManager::getPlatformByName("cuda") where "cuda"
/// can be replaced by any supported platform name. This gives the user a
/// Platform object that can be used to create Device objects for that platform,
/// etc.
#include <map>
#include "streamexecutor/Error.h"
#include "streamexecutor/Platform.h"
namespace streamexecutor {
/// A singleton that holds a reference to a Platform object for each
/// supported StreamExecutor platform.
class PlatformManager {
/// Gets a reference to the Platform with the given name.
/// The name parameter is not case-sensitive, so the following arguments are
/// all equivalent: "cuda", "CUDA", "Cuda", "cUdA".
/// Returns an error if no platform is present for the name.
/// Ownership of the platform is NOT transferred to the caller.
static Expected<Platform *> getPlatformByName(llvm::StringRef Name);
PlatformManager(const PlatformManager &) = delete;
PlatformManager operator=(const PlatformManager &) = delete;
std::map<std::string, std::unique_ptr<Platform>> PlatformsByName;
} // namespace streamexecutor