Hash :
8dae26c6
        
        Author :
  
        
        Date :
2024-06-26T11:35:24
        
      
CL: Add missing validation checks -1- Check on device enqueue support Add a check for the device enqueue support before proceeding with the device enqueue info queries. -2- Validate the non uniform work groups The spec requires reporting CL_INVALID_WORK_GROUP_SIZE when non-uniform workgroups are not supported and supplied work sizes dont evenly distribute the work items. Adding a check in the validation. -3- Check for alignment on sub-buffer creation The spec requires the sub-buffer origin to be aligned to CL_DEVICE_MEM_BASE_ADDR_ALIGN value. Check for this in validation layer. Bug: angleproject:42267011 Change-Id: I9dc086fea16b200cc05c0fca29e3608403099a2c Signed-off-by: Gowtham Tammana <g.tammana@samsung.com> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5975419 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
//
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// CLDevice.h: Defines the cl::Device class, which provides information about OpenCL device
// configurations.
#ifndef LIBANGLE_CLDEVICE_H_
#define LIBANGLE_CLDEVICE_H_
#include "libANGLE/CLObject.h"
#include "libANGLE/renderer/CLDeviceImpl.h"
#include "common/SynchronizedValue.h"
#include <functional>
namespace cl
{
class Device final : public _cl_device_id, public Object
{
  public:
    // Front end entry functions, only called from OpenCL entry points
    angle::Result getInfo(DeviceInfo name,
                          size_t valueSize,
                          void *value,
                          size_t *valueSizeRet) const;
    angle::Result createSubDevices(const cl_device_partition_property *properties,
                                   cl_uint numDevices,
                                   cl_device_id *subDevices,
                                   cl_uint *numDevicesRet);
  public:
    ~Device() override;
    Platform &getPlatform() noexcept;
    const Platform &getPlatform() const noexcept;
    bool isRoot() const noexcept;
    const rx::CLDeviceImpl::Info &getInfo() const;
    cl_version getVersion() const;
    bool isVersionOrNewer(cl_uint major, cl_uint minor) const;
    template <typename T = rx::CLDeviceImpl>
    T &getImpl() const;
    bool supportsBuiltInKernel(const std::string &name) const;
    bool supportsNativeImageDimensions(const cl_image_desc &desc) const;
    bool supportsImageDimensions(const ImageDescriptor &desc) const;
    bool hasDeviceEnqueueCaps() const;
    bool supportsNonUniformWorkGroups() const;
    static bool IsValidType(DeviceType type);
  private:
    Device(Platform &platform,
           Device *parent,
           DeviceType type,
           const rx::CLDeviceImpl::CreateFunc &createFunc);
    Platform &mPlatform;
    const DevicePtr mParent;
    const rx::CLDeviceImpl::Ptr mImpl;
    const rx::CLDeviceImpl::Info mInfo;
    angle::SynchronizedValue<CommandQueue *> mDefaultCommandQueue = nullptr;
    friend class CommandQueue;
    friend class Platform;
};
inline Platform &Device::getPlatform() noexcept
{
    return mPlatform;
}
inline const Platform &Device::getPlatform() const noexcept
{
    return mPlatform;
}
inline bool Device::isRoot() const noexcept
{
    return mParent == nullptr;
}
inline const rx::CLDeviceImpl::Info &Device::getInfo() const
{
    return mInfo;
}
inline cl_version Device::getVersion() const
{
    return mInfo.version;
}
inline bool Device::isVersionOrNewer(cl_uint major, cl_uint minor) const
{
    return mInfo.version >= CL_MAKE_VERSION(major, minor, 0u);
}
template <typename T>
inline T &Device::getImpl() const
{
    return static_cast<T &>(*mImpl);
}
inline bool Device::IsValidType(DeviceType type)
{
    return type.get() <= CL_DEVICE_TYPE_CUSTOM || type == CL_DEVICE_TYPE_ALL;
}
}  // namespace cl
#endif  // LIBANGLE_CLDEVICE_H_