Hash :
8ba71e66
Author :
Date :
2024-06-26T13:37:42
CL/Vulkan: Update few device caps based on VK caps
-1- Device fence caps flags
The spec requires below fence capabilities to be preset
- CL_DEVICE_ATOMIC_ORDER_RELAXED
- CL_DEVICE_ATOMIC_ORDER_ACQ_REL
- CL_DEVICE_ATOMIC_SCOPE_WORK_GROUP
-2- Add missing param names in program query
The params CL_PROGRAM_SCOPE_GLOBAL_{CTORS,DTORS}_PRESENT are missing
from program query. Adding them.
-3- Set max sampler and image buffer to spec min
Set the max samplers and image buffer size to minimum for now. These
will be changed once the image support is complete.
Bug: angleproject:366412386
Change-Id: Iee2c11319c6c5b2f3a1565e06f1f09c5f770a07c
Signed-off-by: Gowtham Tammana <g.tammana@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6004685
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Austin Annestrand <a.annestrand@samsung.com>
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
//
// 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.
//
// CLDeviceVk.cpp: Implements the class methods for CLDeviceVk.
#include "libANGLE/renderer/vulkan/CLDeviceVk.h"
#include "libANGLE/renderer/vulkan/CLPlatformVk.h"
#include "libANGLE/renderer/vulkan/vk_renderer.h"
#include "libANGLE/renderer/cl_types.h"
#include "libANGLE/Display.h"
#include "libANGLE/cl_utils.h"
namespace rx
{
CLDeviceVk::CLDeviceVk(const cl::Device &device, vk::Renderer *renderer)
: CLDeviceImpl(device), mRenderer(renderer)
{
const VkPhysicalDeviceProperties &props = mRenderer->getPhysicalDeviceProperties();
// Setup initial device mInfo fields
// TODO(aannestrand) Create cl::Caps and use for device creation
// http://anglebug.com/42266954
mInfoString = {
{cl::DeviceInfo::Name, std::string(props.deviceName)},
{cl::DeviceInfo::Vendor, mRenderer->getVendorString()},
{cl::DeviceInfo::DriverVersion, mRenderer->getVersionString(true)},
{cl::DeviceInfo::Version, std::string("OpenCL 3.0 " + mRenderer->getVersionString(true))},
{cl::DeviceInfo::Profile, std::string("FULL_PROFILE")},
{cl::DeviceInfo::OpenCL_C_Version, std::string("OpenCL C 1.2 ")},
{cl::DeviceInfo::LatestConformanceVersionPassed, std::string("FIXME")}};
mInfoSizeT = {
{cl::DeviceInfo::MaxWorkGroupSize, props.limits.maxComputeWorkGroupInvocations},
{cl::DeviceInfo::MaxGlobalVariableSize, 0},
{cl::DeviceInfo::GlobalVariablePreferredTotalSize, 0},
// TODO(aannestrand) Update these hardcoded platform/device queries
// http://anglebug.com/42266935
{cl::DeviceInfo::MaxParameterSize, 1024},
{cl::DeviceInfo::ProfilingTimerResolution, 1},
{cl::DeviceInfo::PrintfBufferSize, 1024 * 1024},
{cl::DeviceInfo::PreferredWorkGroupSizeMultiple, 16},
};
mInfoULong = {
{cl::DeviceInfo::LocalMemSize, props.limits.maxComputeSharedMemorySize},
{cl::DeviceInfo::SVM_Capabilities, 0},
{cl::DeviceInfo::QueueOnDeviceProperties, 0},
{cl::DeviceInfo::PartitionAffinityDomain, 0},
{cl::DeviceInfo::DeviceEnqueueCapabilities, 0},
{cl::DeviceInfo::QueueOnHostProperties, CL_QUEUE_PROFILING_ENABLE},
// TODO(aannestrand) Update these hardcoded platform/device queries
// http://anglebug.com/42266935
{cl::DeviceInfo::HalfFpConfig, 0},
{cl::DeviceInfo::DoubleFpConfig, 0},
{cl::DeviceInfo::GlobalMemCacheSize, 0},
{cl::DeviceInfo::GlobalMemSize, 1024 * 1024 * 1024},
{cl::DeviceInfo::MaxConstantBufferSize, 64 * 1024},
{cl::DeviceInfo::SingleFpConfig, CL_FP_ROUND_TO_NEAREST | CL_FP_INF_NAN | CL_FP_FMA},
{cl::DeviceInfo::AtomicMemoryCapabilities,
CL_DEVICE_ATOMIC_ORDER_RELAXED | CL_DEVICE_ATOMIC_SCOPE_WORK_GROUP},
// TODO (http://anglebug.com/379669750) Add these based on the Vulkan features query
{cl::DeviceInfo::AtomicFenceCapabilities, CL_DEVICE_ATOMIC_ORDER_RELAXED |
CL_DEVICE_ATOMIC_ORDER_ACQ_REL |
CL_DEVICE_ATOMIC_SCOPE_WORK_GROUP |
// non-mandatory
CL_DEVICE_ATOMIC_SCOPE_WORK_ITEM},
};
mInfoUInt = {
{cl::DeviceInfo::VendorID, props.vendorID},
{cl::DeviceInfo::MaxReadImageArgs, props.limits.maxPerStageDescriptorSampledImages},
{cl::DeviceInfo::MaxWriteImageArgs, props.limits.maxPerStageDescriptorStorageImages},
{cl::DeviceInfo::MaxReadWriteImageArgs, props.limits.maxPerStageDescriptorStorageImages},
{cl::DeviceInfo::GlobalMemCachelineSize,
static_cast<cl_uint>(props.limits.nonCoherentAtomSize)},
{cl::DeviceInfo::Available, CL_TRUE},
{cl::DeviceInfo::LinkerAvailable, CL_TRUE},
{cl::DeviceInfo::CompilerAvailable, CL_TRUE},
{cl::DeviceInfo::MaxOnDeviceQueues, 0},
{cl::DeviceInfo::MaxOnDeviceEvents, 0},
{cl::DeviceInfo::QueueOnDeviceMaxSize, 0},
{cl::DeviceInfo::QueueOnDevicePreferredSize, 0},
{cl::DeviceInfo::MaxPipeArgs, 0},
{cl::DeviceInfo::PipeMaxPacketSize, 0},
{cl::DeviceInfo::PipeSupport, CL_FALSE},
{cl::DeviceInfo::PipeMaxActiveReservations, 0},
{cl::DeviceInfo::ErrorCorrectionSupport, CL_FALSE},
{cl::DeviceInfo::PreferredInteropUserSync, CL_TRUE},
{cl::DeviceInfo::ExecutionCapabilities, CL_EXEC_KERNEL},
// TODO(aannestrand) Update these hardcoded platform/device queries
// http://anglebug.com/42266935
{cl::DeviceInfo::AddressBits, 32},
{cl::DeviceInfo::EndianLittle, CL_TRUE},
{cl::DeviceInfo::LocalMemType, CL_LOCAL},
// TODO (http://anglebug.com/379669750) Vulkan reports a big sampler count number, we dont
// need that many and set it to minimum req for now.
{cl::DeviceInfo::MaxSamplers, 16u},
{cl::DeviceInfo::MaxConstantArgs, 8},
{cl::DeviceInfo::MaxNumSubGroups, 0},
{cl::DeviceInfo::MaxComputeUnits, 4},
{cl::DeviceInfo::MaxClockFrequency, 555},
{cl::DeviceInfo::MaxWorkItemDimensions, 3},
{cl::DeviceInfo::MinDataTypeAlignSize, 128},
{cl::DeviceInfo::GlobalMemCacheType, CL_NONE},
{cl::DeviceInfo::HostUnifiedMemory, CL_TRUE},
{cl::DeviceInfo::NativeVectorWidthChar, 4},
{cl::DeviceInfo::NativeVectorWidthShort, 2},
{cl::DeviceInfo::NativeVectorWidthInt, 1},
{cl::DeviceInfo::NativeVectorWidthLong, 1},
{cl::DeviceInfo::NativeVectorWidthFloat, 1},
{cl::DeviceInfo::NativeVectorWidthDouble, 1},
{cl::DeviceInfo::NativeVectorWidthHalf, 0},
{cl::DeviceInfo::PartitionMaxSubDevices, 0},
{cl::DeviceInfo::PreferredVectorWidthInt, 1},
{cl::DeviceInfo::PreferredVectorWidthLong, 1},
{cl::DeviceInfo::PreferredVectorWidthChar, 4},
{cl::DeviceInfo::PreferredVectorWidthHalf, 0},
{cl::DeviceInfo::PreferredVectorWidthShort, 2},
{cl::DeviceInfo::PreferredVectorWidthFloat, 1},
{cl::DeviceInfo::PreferredVectorWidthDouble, 0},
{cl::DeviceInfo::PreferredLocalAtomicAlignment, 0},
{cl::DeviceInfo::PreferredGlobalAtomicAlignment, 0},
{cl::DeviceInfo::PreferredPlatformAtomicAlignment, 0},
{cl::DeviceInfo::NonUniformWorkGroupSupport, CL_FALSE},
{cl::DeviceInfo::GenericAddressSpaceSupport, CL_FALSE},
{cl::DeviceInfo::SubGroupIndependentForwardProgress, CL_FALSE},
{cl::DeviceInfo::WorkGroupCollectiveFunctionsSupport, CL_FALSE},
};
}
CLDeviceVk::~CLDeviceVk() = default;
CLDeviceImpl::Info CLDeviceVk::createInfo(cl::DeviceType type) const
{
Info info(type);
const VkPhysicalDeviceProperties &properties = mRenderer->getPhysicalDeviceProperties();
info.maxWorkItemSizes.push_back(properties.limits.maxComputeWorkGroupSize[0]);
info.maxWorkItemSizes.push_back(properties.limits.maxComputeWorkGroupSize[1]);
info.maxWorkItemSizes.push_back(properties.limits.maxComputeWorkGroupSize[2]);
// TODO(aannestrand) Update these hardcoded platform/device queries
// http://anglebug.com/42266935
info.maxMemAllocSize = 1 << 30;
info.memBaseAddrAlign = 1024;
info.imageSupport = CL_TRUE;
info.image2D_MaxWidth = properties.limits.maxImageDimension2D;
info.image2D_MaxHeight = properties.limits.maxImageDimension2D;
info.image3D_MaxWidth = properties.limits.maxImageDimension3D;
info.image3D_MaxHeight = properties.limits.maxImageDimension3D;
info.image3D_MaxDepth = properties.limits.maxImageDimension3D;
// TODO (http://anglebug.com/379669750) For now set it minimum requirement.
info.imageMaxBufferSize = 65536;
info.imageMaxArraySize = properties.limits.maxImageArrayLayers;
info.imagePitchAlignment = 0u;
info.imageBaseAddressAlignment = 0u;
info.execCapabilities = CL_EXEC_KERNEL;
info.queueOnDeviceMaxSize = 0u;
info.builtInKernels = "";
info.version = CL_MAKE_VERSION(3, 0, 0);
info.versionStr = "OpenCL 3.0 " + mRenderer->getVersionString(true);
info.OpenCL_C_AllVersions = {{CL_MAKE_VERSION(1, 0, 0), "OpenCL C"},
{CL_MAKE_VERSION(1, 1, 0), "OpenCL C"},
{CL_MAKE_VERSION(1, 2, 0), "OpenCL C"},
{CL_MAKE_VERSION(3, 0, 0), "OpenCL C"}};
info.OpenCL_C_Features = {};
info.ILsWithVersion = {};
info.builtInKernelsWithVersion = {};
info.partitionProperties = {};
info.partitionType = {};
info.IL_Version = "";
// Below extensions are required as of OpenCL 1.1, add their versioned strings
NameVersionVector versionedExtensionList = {
// Below extensions are required as of OpenCL 1.1
cl_name_version{.version = CL_MAKE_VERSION(1, 0, 0),
.name = "cl_khr_byte_addressable_store"},
cl_name_version{.version = CL_MAKE_VERSION(1, 0, 0),
.name = "cl_khr_global_int32_base_atomics"},
cl_name_version{.version = CL_MAKE_VERSION(1, 0, 0),
.name = "cl_khr_global_int32_extended_atomics"},
cl_name_version{.version = CL_MAKE_VERSION(1, 0, 0),
.name = "cl_khr_local_int32_base_atomics"},
cl_name_version{.version = CL_MAKE_VERSION(1, 0, 0),
.name = "cl_khr_local_int32_extended_atomics"},
};
info.initializeVersionedExtensions(std::move(versionedExtensionList));
return info;
}
angle::Result CLDeviceVk::getInfoUInt(cl::DeviceInfo name, cl_uint *value) const
{
if (mInfoUInt.count(name))
{
*value = mInfoUInt.at(name);
return angle::Result::Continue;
}
ANGLE_CL_RETURN_ERROR(CL_INVALID_VALUE);
}
angle::Result CLDeviceVk::getInfoULong(cl::DeviceInfo name, cl_ulong *value) const
{
if (mInfoULong.count(name))
{
*value = mInfoULong.at(name);
return angle::Result::Continue;
}
ANGLE_CL_RETURN_ERROR(CL_INVALID_VALUE);
}
angle::Result CLDeviceVk::getInfoSizeT(cl::DeviceInfo name, size_t *value) const
{
if (mInfoSizeT.count(name))
{
*value = mInfoSizeT.at(name);
return angle::Result::Continue;
}
ANGLE_CL_RETURN_ERROR(CL_INVALID_VALUE);
}
angle::Result CLDeviceVk::getInfoStringLength(cl::DeviceInfo name, size_t *value) const
{
if (mInfoString.count(name))
{
*value = mInfoString.at(name).length() + 1;
return angle::Result::Continue;
}
ANGLE_CL_RETURN_ERROR(CL_INVALID_VALUE);
}
angle::Result CLDeviceVk::getInfoString(cl::DeviceInfo name, size_t size, char *value) const
{
if (mInfoString.count(name))
{
std::strcpy(value, mInfoString.at(name).c_str());
return angle::Result::Continue;
}
ANGLE_CL_RETURN_ERROR(CL_INVALID_VALUE);
}
angle::Result CLDeviceVk::createSubDevices(const cl_device_partition_property *properties,
cl_uint numDevices,
CreateFuncs &subDevices,
cl_uint *numDevicesRet)
{
UNIMPLEMENTED();
ANGLE_CL_RETURN_ERROR(CL_OUT_OF_RESOURCES);
}
cl::WorkgroupSize CLDeviceVk::selectWorkGroupSize(const cl::NDRange &ndrange) const
{
// Limit total work-group size to the Vulkan device's limit
const VkPhysicalDeviceProperties &props = mRenderer->getPhysicalDeviceProperties();
uint32_t maxSize = static_cast<uint32_t>(mInfoSizeT.at(cl::DeviceInfo::MaxWorkGroupSize));
maxSize = std::min(maxSize, 64u);
bool keepIncreasing = false;
cl::WorkgroupSize localSize = {1, 1, 1};
do
{
keepIncreasing = false;
for (cl_uint i = 0; i < ndrange.workDimensions; i++)
{
cl::WorkgroupSize newLocalSize = localSize;
newLocalSize[i] *= 2;
// TODO: Add support for non-uniform WGS
// http://anglebug.com/42267067
if (ndrange.globalWorkSize[i] % newLocalSize[i] == 0 &&
newLocalSize[i] <= props.limits.maxComputeWorkGroupCount[i] &&
newLocalSize[0] * newLocalSize[1] * newLocalSize[2] <= maxSize)
{
localSize = newLocalSize;
keepIncreasing = true;
}
}
} while (keepIncreasing);
return localSize;
}
} // namespace rx