• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2021 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // CLDeviceImpl.h: Defines the abstract rx::CLDeviceImpl class.
7 
8 #ifndef LIBANGLE_RENDERER_CLDEVICEIMPL_H_
9 #define LIBANGLE_RENDERER_CLDEVICEIMPL_H_
10 
11 #include "libANGLE/renderer/CLExtensions.h"
12 
13 namespace rx
14 {
15 
16 class CLDeviceImpl : angle::NonCopyable
17 {
18   public:
19     using Ptr         = std::unique_ptr<CLDeviceImpl>;
20     using CreateFunc  = std::function<Ptr(const cl::Device &)>;
21     using CreateFuncs = std::list<CreateFunc>;
22     using CreateData  = std::pair<cl::DeviceType, CreateFunc>;
23     using CreateDatas = std::list<CreateData>;
24 
25     struct Info : public CLExtensions
26     {
27         Info();
28         explicit Info(cl::DeviceType deviceType);
29         ~Info();
30 
31         Info(const Info &) = delete;
32         Info &operator=(const Info &) = delete;
33 
34         Info(Info &&);
35         Info &operator=(Info &&);
36 
isValidInfo37         bool isValid() const { return version != 0u; }
38 
39         // In the order as they appear in the OpenCL specification V3.0.7, table 5
40         cl::DeviceType type;
41         std::vector<size_t> maxWorkItemSizes;
42         cl_ulong maxMemAllocSize = 0u;
43         cl_bool imageSupport     = CL_FALSE;
44         std::string IL_Version;
45         NameVersionVector ILsWithVersion;
46         size_t image2D_MaxWidth           = 0u;
47         size_t image2D_MaxHeight          = 0u;
48         size_t image3D_MaxWidth           = 0u;
49         size_t image3D_MaxHeight          = 0u;
50         size_t image3D_MaxDepth           = 0u;
51         size_t imageMaxBufferSize         = 0u;
52         size_t imageMaxArraySize          = 0u;
53         cl_uint imagePitchAlignment       = 0u;
54         cl_uint imageBaseAddressAlignment = 0u;
55         cl_uint memBaseAddrAlign          = 0u;
56         cl::DeviceExecCapabilities execCapabilities;
57         cl_uint queueOnDeviceMaxSize = 0u;
58         std::string builtInKernels;
59         NameVersionVector builtInKernelsWithVersion;
60         NameVersionVector OpenCL_C_AllVersions;
61         NameVersionVector OpenCL_C_Features;
62         std::vector<cl_device_partition_property> partitionProperties;
63         std::vector<cl_device_partition_property> partitionType;
64     };
65 
66     CLDeviceImpl(const cl::Device &device);
67     virtual ~CLDeviceImpl();
68 
69     virtual Info createInfo(cl::DeviceType type) const = 0;
70 
71     virtual cl_int getInfoUInt(cl::DeviceInfo name, cl_uint *value) const             = 0;
72     virtual cl_int getInfoULong(cl::DeviceInfo name, cl_ulong *value) const           = 0;
73     virtual cl_int getInfoSizeT(cl::DeviceInfo name, size_t *value) const             = 0;
74     virtual cl_int getInfoStringLength(cl::DeviceInfo name, size_t *value) const      = 0;
75     virtual cl_int getInfoString(cl::DeviceInfo name, size_t size, char *value) const = 0;
76 
77     virtual cl_int createSubDevices(const cl_device_partition_property *properties,
78                                     cl_uint numDevices,
79                                     CreateFuncs &createFuncs,
80                                     cl_uint *numDevicesRet) = 0;
81 
82   protected:
83     const cl::Device &mDevice;
84 };
85 
86 }  // namespace rx
87 
88 #endif  // LIBANGLE_RENDERER_CLDEVICEIMPL_H_
89