2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2018-2021 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
|
2021-07-09 21:06:20 +08:00
|
|
|
#include "shared/source/helpers/common_types.h"
|
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/api/cl_types.h"
|
2020-03-20 18:15:25 +08:00
|
|
|
#include "opencl/source/cl_device/cl_device_vector.h"
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/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;
|
|
|
|
class Device;
|
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;
|
|
|
|
|
2020-02-07 19:15:46 +08:00
|
|
|
Platform(ExecutionEnvironment &executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
~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);
|
|
|
|
|
2020-02-15 00:36:30 +08:00
|
|
|
MOCKABLE_VIRTUAL bool initialize(std::vector<std::unique_ptr<Device>> devices);
|
2017-12-21 07:45:38 +08:00
|
|
|
bool isInitialized();
|
|
|
|
|
|
|
|
size_t getNumDevices() const;
|
2020-01-14 21:32:11 +08:00
|
|
|
ClDevice **getClDevices();
|
|
|
|
ClDevice *getClDevice(size_t deviceOrdinal);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
const PlatformInfo &getPlatformInfo() const;
|
2020-02-07 19:15:46 +08:00
|
|
|
ExecutionEnvironment *peekExecutionEnvironment() const { return &executionEnvironment; }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-02-11 18:39:25 +08:00
|
|
|
static std::unique_ptr<Platform> (*createFunc)(ExecutionEnvironment &executionEnvironment);
|
2020-02-18 23:02:26 +08:00
|
|
|
static std::vector<DeviceVector> groupDevices(DeviceVector devices);
|
2020-02-11 18:39:25 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
|
|
|
enum {
|
|
|
|
StateNone,
|
|
|
|
StateIniting,
|
|
|
|
StateInited,
|
|
|
|
};
|
|
|
|
cl_uint state = StateNone;
|
|
|
|
void fillGlobalDispatchTable();
|
2018-06-29 15:34:54 +08:00
|
|
|
std::unique_ptr<PlatformInfo> platformInfo;
|
2020-01-14 21:32:11 +08:00
|
|
|
ClDeviceVector clDevices;
|
2020-02-07 19:15:46 +08:00
|
|
|
ExecutionEnvironment &executionEnvironment;
|
2020-06-09 20:17:19 +08:00
|
|
|
std::once_flag initializeExtensionsWithVersionOnce;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2020-09-01 18:38:50 +08:00
|
|
|
extern std::vector<std::unique_ptr<Platform>> *platformsImpl;
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|