2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-14 21:32:11 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "runtime/api/cl_types.h"
|
|
|
|
#include "runtime/device/device_vector.h"
|
|
|
|
#include "runtime/helpers/base_object.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
|
|
|
#include "platform_info.h"
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <condition_variable>
|
2020-01-14 21:32:11 +08:00
|
|
|
#include <unordered_map>
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class CompilerInterface;
|
2019-11-05 20:38:20 +08:00
|
|
|
class RootDevice;
|
2017-12-21 07:45:38 +08:00
|
|
|
class Device;
|
|
|
|
class AsyncEventsHandler;
|
2018-06-22 18:54:33 +08:00
|
|
|
class ExecutionEnvironment;
|
2019-12-04 19:36:16 +08:00
|
|
|
class GmmHelper;
|
|
|
|
class GmmClientContext;
|
2017-12-21 07:45:38 +08:00
|
|
|
struct HardwareInfo;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct OpenCLObjectMapper<_cl_platform_id> {
|
|
|
|
typedef class Platform DerivedType;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Platform : public BaseObject<_cl_platform_id> {
|
|
|
|
public:
|
|
|
|
static const cl_ulong objectMagic = 0x8873ACDEF2342133LL;
|
|
|
|
|
|
|
|
Platform();
|
|
|
|
~Platform() override;
|
|
|
|
|
2018-06-28 14:51:44 +08:00
|
|
|
Platform(const Platform &) = delete;
|
|
|
|
Platform &operator=(Platform const &) = delete;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
cl_int getInfo(cl_platform_info paramName,
|
|
|
|
size_t paramValueSize,
|
|
|
|
void *paramValue,
|
|
|
|
size_t *paramValueSizeRet);
|
|
|
|
|
2018-06-21 00:25:40 +08:00
|
|
|
bool initialize();
|
2017-12-21 07:45:38 +08:00
|
|
|
bool isInitialized();
|
|
|
|
|
|
|
|
size_t getNumDevices() const;
|
|
|
|
Device *getDevice(size_t deviceOrdinal);
|
2020-01-14 21:32:11 +08:00
|
|
|
ClDevice **getClDevices();
|
|
|
|
ClDevice *getClDevice(size_t deviceOrdinal);
|
|
|
|
std::unordered_map<const Device *, ClDevice *> clDeviceMap;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
const PlatformInfo &getPlatformInfo() const;
|
|
|
|
AsyncEventsHandler *getAsyncEventsHandler();
|
2018-02-21 23:31:53 +08:00
|
|
|
std::unique_ptr<AsyncEventsHandler> setAsyncEventsHandler(std::unique_ptr<AsyncEventsHandler> handler);
|
2019-12-04 19:36:16 +08:00
|
|
|
ExecutionEnvironment *peekExecutionEnvironment() const { return executionEnvironment; }
|
|
|
|
GmmHelper *peekGmmHelper() const;
|
|
|
|
GmmClientContext *peekGmmClientContext() const;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
enum {
|
|
|
|
StateNone,
|
|
|
|
StateIniting,
|
|
|
|
StateInited,
|
|
|
|
};
|
|
|
|
cl_uint state = StateNone;
|
|
|
|
void fillGlobalDispatchTable();
|
2018-08-14 19:54:33 +08:00
|
|
|
MOCKABLE_VIRTUAL void initializationLoopHelper(){};
|
2019-11-05 20:38:20 +08:00
|
|
|
MOCKABLE_VIRTUAL RootDevice *createRootDevice(uint32_t rootDeviceIndex) const;
|
2018-06-29 15:34:54 +08:00
|
|
|
std::unique_ptr<PlatformInfo> platformInfo;
|
2020-01-14 21:32:11 +08:00
|
|
|
ClDeviceVector clDevices;
|
2017-12-21 07:45:38 +08:00
|
|
|
std::unique_ptr<AsyncEventsHandler> asyncEventsHandler;
|
2018-06-22 18:54:33 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2018-06-26 22:15:48 +08:00
|
|
|
extern std::unique_ptr<Platform> platformImpl;
|
2017-12-21 07:45:38 +08:00
|
|
|
Platform *platform();
|
2018-06-26 22:15:48 +08:00
|
|
|
Platform *constructPlatform();
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|