SWDEV-470698 - fix formatting, add format check workflow (#657)
This commit is contained in:
committed by
GitHub
parent
5840940caa
commit
f7338717ae
@@ -62,7 +62,7 @@
|
||||
* chkReadWrite: true: check the flag CL_MEM_KERNEL_READ_AND_WRITE
|
||||
* false: don't check the falg CL_MEM_KERNEL_READ_AND_WRITE
|
||||
* \return true of flags are valid, otherwise - false
|
||||
*/
|
||||
*/
|
||||
static bool validateFlags(cl_mem_flags flags, bool chkReadWrite = false) {
|
||||
// check flags for validity
|
||||
cl_bitfield temp = flags & (CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY);
|
||||
@@ -72,8 +72,9 @@ static bool validateFlags(cl_mem_flags flags, bool chkReadWrite = false) {
|
||||
|
||||
if (temp &&
|
||||
!(CL_MEM_READ_WRITE == temp || CL_MEM_WRITE_ONLY == temp ||
|
||||
(chkReadWrite && (CL_MEM_KERNEL_READ_AND_WRITE == temp ||
|
||||
(CL_MEM_KERNEL_READ_AND_WRITE | CL_MEM_READ_WRITE) == temp)) ||
|
||||
(chkReadWrite &&
|
||||
(CL_MEM_KERNEL_READ_AND_WRITE == temp ||
|
||||
(CL_MEM_KERNEL_READ_AND_WRITE | CL_MEM_READ_WRITE) == temp)) ||
|
||||
CL_MEM_READ_ONLY == temp)) {
|
||||
return false;
|
||||
}
|
||||
@@ -88,8 +89,9 @@ static bool validateFlags(cl_mem_flags flags, bool chkReadWrite = false) {
|
||||
}
|
||||
|
||||
if ((flags & CL_MEM_EXTERNAL_PHYSICAL_AMD) &&
|
||||
(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR | CL_MEM_ALLOC_HOST_PTR |
|
||||
CL_MEM_READ_WRITE | CL_MEM_READ_ONLY))) {
|
||||
(flags &
|
||||
(CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE |
|
||||
CL_MEM_READ_ONLY))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -231,8 +233,8 @@ static bool validateImageDescriptor(const std::vector<amd::Device*>& devices,
|
||||
}
|
||||
if (imageRowPitch == 0) {
|
||||
if (desc->mem_object != nullptr) {
|
||||
imageRowPitch = amd::alignUp(desc->image_width,
|
||||
devices[0]->info().imagePitchAlignment_) * elemSize;
|
||||
imageRowPitch =
|
||||
amd::alignUp(desc->image_width, devices[0]->info().imagePitchAlignment_) * elemSize;
|
||||
} else {
|
||||
imageRowPitch = desc->image_width * elemSize;
|
||||
}
|
||||
@@ -331,8 +333,9 @@ class ImageViewRef : public amd::EmbeddedObject {
|
||||
*
|
||||
* \version 1.0r33
|
||||
*/
|
||||
RUNTIME_ENTRY_RET(cl_mem, clCreateBuffer, (cl_context context, cl_mem_flags flags, size_t size,
|
||||
void* host_ptr, cl_int* errcode_ret)) {
|
||||
RUNTIME_ENTRY_RET(cl_mem, clCreateBuffer,
|
||||
(cl_context context, cl_mem_flags flags, size_t size, void* host_ptr,
|
||||
cl_int* errcode_ret)) {
|
||||
if (!is_valid(context)) {
|
||||
*not_null(errcode_ret) = CL_INVALID_CONTEXT;
|
||||
return NULL;
|
||||
@@ -411,8 +414,9 @@ RUNTIME_ENTRY_RET(cl_mem, clCreateBuffer, (cl_context context, cl_mem_flags flag
|
||||
|
||||
// check extensions flag consistency
|
||||
if ((flags & CL_MEM_USE_PERSISTENT_MEM_AMD) &&
|
||||
(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_EXTERNAL_PHYSICAL_AMD |
|
||||
CL_MEM_BUS_ADDRESSABLE_AMD))) {
|
||||
(flags &
|
||||
(CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_EXTERNAL_PHYSICAL_AMD |
|
||||
CL_MEM_BUS_ADDRESSABLE_AMD))) {
|
||||
*not_null(errcode_ret) = CL_INVALID_VALUE;
|
||||
LogWarning("conflicting flags CL_MEM_USE_PERSISTENT_MEM_AMD and host memory specific flags");
|
||||
return (cl_mem)0;
|
||||
@@ -630,16 +634,16 @@ RUNTIME_ENTRY(cl_int, clEnqueueReadBuffer,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
|
||||
amd::CopyMetadata copyMetadata(!blocking_read, amd::CopyMetadata::CopyEnginePreference::SDMA);
|
||||
amd::ReadMemoryCommand* command = new amd::ReadMemoryCommand(
|
||||
hostQueue, CL_COMMAND_READ_BUFFER, eventWaitList, *srcBuffer, srcOffset, srcSize,
|
||||
ptr, 0, 0, copyMetadata);
|
||||
amd::ReadMemoryCommand* command =
|
||||
new amd::ReadMemoryCommand(hostQueue, CL_COMMAND_READ_BUFFER, eventWaitList, *srcBuffer,
|
||||
srcOffset, srcSize, ptr, 0, 0, copyMetadata);
|
||||
|
||||
if (command == NULL) {
|
||||
return CL_OUT_OF_HOST_MEMORY;
|
||||
@@ -772,16 +776,16 @@ RUNTIME_ENTRY(cl_int, clEnqueueWriteBuffer,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
|
||||
amd::CopyMetadata copyMetadata(!blocking_write, amd::CopyMetadata::CopyEnginePreference::SDMA);
|
||||
amd::WriteMemoryCommand* command = new amd::WriteMemoryCommand(
|
||||
hostQueue, CL_COMMAND_WRITE_BUFFER, eventWaitList, *dstBuffer, dstOffset, dstSize,
|
||||
ptr, 0, 0, copyMetadata);
|
||||
amd::WriteMemoryCommand* command =
|
||||
new amd::WriteMemoryCommand(hostQueue, CL_COMMAND_WRITE_BUFFER, eventWaitList, *dstBuffer,
|
||||
dstOffset, dstSize, ptr, 0, 0, copyMetadata);
|
||||
|
||||
if (command == NULL) {
|
||||
return CL_OUT_OF_HOST_MEMORY;
|
||||
@@ -897,14 +901,15 @@ RUNTIME_ENTRY(cl_int, clEnqueueCopyBuffer,
|
||||
return CL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (srcBuffer == dstBuffer && ((src_offset <= dst_offset && dst_offset < src_offset + cb) ||
|
||||
(dst_offset <= src_offset && src_offset < dst_offset + cb))) {
|
||||
if (srcBuffer == dstBuffer &&
|
||||
((src_offset <= dst_offset && dst_offset < src_offset + cb) ||
|
||||
(dst_offset <= src_offset && src_offset < dst_offset + cb))) {
|
||||
return CL_MEM_COPY_OVERLAP;
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -1086,8 +1091,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueReadBufferRect,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -1271,8 +1276,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueWriteBufferRect,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -1453,8 +1458,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueCopyBufferRect,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -2223,8 +2228,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueReadImage,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -2410,17 +2415,16 @@ RUNTIME_ENTRY(cl_int, clEnqueueWriteImage,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
|
||||
amd::CopyMetadata copyMetadata(!blocking_write, amd::CopyMetadata::CopyEnginePreference::SDMA);
|
||||
amd::WriteMemoryCommand* command =
|
||||
new amd::WriteMemoryCommand(hostQueue, CL_COMMAND_WRITE_IMAGE, eventWaitList, *dstImage,
|
||||
dstOrigin, dstRegion, ptr, input_row_pitch, input_slice_pitch,
|
||||
copyMetadata);
|
||||
amd::WriteMemoryCommand* command = new amd::WriteMemoryCommand(
|
||||
hostQueue, CL_COMMAND_WRITE_IMAGE, eventWaitList, *dstImage, dstOrigin, dstRegion, ptr,
|
||||
input_row_pitch, input_slice_pitch, copyMetadata);
|
||||
|
||||
if (command == NULL) {
|
||||
return CL_OUT_OF_HOST_MEMORY;
|
||||
@@ -2591,8 +2595,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueCopyImage,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -2765,8 +2769,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueCopyImageToBuffer,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -2919,8 +2923,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueCopyBufferToImage,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -3095,8 +3099,8 @@ RUNTIME_ENTRY_RET(void*, clEnqueueMapBuffer,
|
||||
|
||||
// Wait for possible pending operations
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
*not_null(errcode_ret) = err;
|
||||
return (void*)0;
|
||||
@@ -3367,8 +3371,8 @@ RUNTIME_ENTRY_RET(void*, clEnqueueMapImage,
|
||||
|
||||
// Wait for possible pending operations
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
*not_null(errcode_ret) = err;
|
||||
return (void*)0;
|
||||
@@ -3382,8 +3386,8 @@ RUNTIME_ENTRY_RET(void*, clEnqueueMapImage,
|
||||
return NULL;
|
||||
}
|
||||
// Attempt to allocate the map target now (whether blocking or non-blocking)
|
||||
void* mapPtr = mem->allocMapTarget(srcOrigin, srcRegion, map_flags,
|
||||
image_row_pitch, image_slice_pitch);
|
||||
void* mapPtr =
|
||||
mem->allocMapTarget(srcOrigin, srcRegion, map_flags, image_row_pitch, image_slice_pitch);
|
||||
if (NULL == mapPtr) {
|
||||
*not_null(errcode_ret) = CL_MAP_FAILURE;
|
||||
return NULL;
|
||||
@@ -3513,8 +3517,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueUnmapMemObject,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -4035,8 +4039,7 @@ RUNTIME_ENTRY_RET(cl_mem, clCreateImage,
|
||||
size_t maxDim = std::max(image_desc->image_width, image_desc->image_height);
|
||||
maxDim = std::max(maxDim, image_desc->image_depth);
|
||||
uint mipLevels;
|
||||
for (mipLevels = 0; maxDim > 0; maxDim >>= 1, mipLevels++)
|
||||
;
|
||||
for (mipLevels = 0; maxDim > 0; maxDim >>= 1, mipLevels++);
|
||||
if (mipLevels < image_desc->num_mip_levels) {
|
||||
*not_null(errcode_ret) = CL_INVALID_MIP_LEVEL;
|
||||
LogWarning("Invalid mip level");
|
||||
@@ -4116,10 +4119,10 @@ RUNTIME_ENTRY_RET(cl_mem, clCreateImage,
|
||||
return (cl_mem)0;
|
||||
}
|
||||
|
||||
image = new (amdContext) amd::Image(
|
||||
buffer, CL_MEM_OBJECT_IMAGE1D_BUFFER, (flags != 0) ? flags : buffer.getMemFlags(),
|
||||
imageFormat, image_desc->image_width, 1, 1, imageRowPitch, imageSlicePitch,
|
||||
image_desc->num_mip_levels);
|
||||
image = new (amdContext) amd::Image(buffer, CL_MEM_OBJECT_IMAGE1D_BUFFER,
|
||||
(flags != 0) ? flags : buffer.getMemFlags(), imageFormat,
|
||||
image_desc->image_width, 1, 1, imageRowPitch,
|
||||
imageSlicePitch, image_desc->num_mip_levels);
|
||||
} break;
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
image =
|
||||
@@ -4273,8 +4276,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueFillBuffer,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -4450,8 +4453,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueFillImage,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
@@ -4601,8 +4604,8 @@ RUNTIME_ENTRY(cl_int, clEnqueueMigrateMemObjects,
|
||||
}
|
||||
|
||||
amd::Command::EventWaitList eventWaitList;
|
||||
cl_int err = amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list,
|
||||
event_wait_list);
|
||||
cl_int err =
|
||||
amd::clSetEventWaitList(eventWaitList, hostQueue, num_events_in_wait_list, event_wait_list);
|
||||
if (err != CL_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user