Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enabling narrowing errors #1144

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ellnor01
Copy link
Contributor

@ellnor01 ellnor01 commented Feb 3, 2021

Fixes narrowing conversion build errors in test_common

Removing disable of narrowing errors in main CMakeLists.txt
and moving it down to specific test_conformance suite's
CMakeLists.txt where there are many more build errors revealed
from this fix.

Fixes a few simple issues under test_conformance in the process.

Contributes #787

Signed-off-by: Ellen Norris-Thompson ellen.norris-thompson@arm.com

@ellnor01
Copy link
Contributor Author

Any comments on here?

@kpet
Copy link
Contributor

kpet commented Jul 3, 2024

@ahesham-arm This is failing the CI. It may require a rebase and/or fixes.

@ahesham-arm ahesham-arm force-pushed the narrowing_conversion_1 branch 3 times, most recently from 08da74d to 2b418b0 Compare July 7, 2024 14:15
@ahesham-arm
Copy link
Contributor

@kpet Rebased and all CI checks are now passing.

@@ -274,7 +274,7 @@ struct CommandBufferPrintfTest : public BasicCommandBufferTest
&pattern[0], 0, nullptr, nullptr);
test_error(error, "clEnqueueWriteBuffer failed");

cl_int offset[] = { 0, pattern.size() - 1 };
size_t offset[] = { 0, pattern.size() - 1 };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please check that this change is correct? I'm nervous that going from a 32-bit type (cl_int) to a possibly 64-bit type (size_t) may require some additional changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

offset is used in 3 locations in this function, two are trivial loop comparisons against another size_t, so those are fine. The other, main one, is a call to clEnqueueWriteBuffer which expects a void* and the size in bytes. The call is already using sizeof so I don't see why this would fail regardless of the data type and/or architecture.

Comment on lines 1295 to 1296
TestFns set = { (int)0xffffffff,
(long long)0xffffffffffffffffLL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to cast these to the types used in the structure, which are guaranteed to have a fixed size, rather than int and long long that could be different sizes for different compilers.

Suggested change
TestFns set = { (int)0xffffffff,
(long long)0xffffffffffffffffLL,
TestFns set = { (cl_int)0xffffffff,
(cl_long)0xffffffffffffffffLL,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -274,7 +274,7 @@ struct CommandBufferPrintfTest : public BasicCommandBufferTest
&pattern[0], 0, nullptr, nullptr);
test_error(error, "clEnqueueWriteBuffer failed");

cl_int offset[] = { 0, pattern.size() - 1 };
size_t offset[] = { 0, pattern.size() - 1 };
error = clEnqueueWriteBuffer(queue, off_mem, CL_TRUE, 0, sizeof(offset),
offset, 0, nullptr, nullptr);
test_error(error, "clEnqueueWriteBuffer failed");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

off_mem is created for sizeof(cl_int) size so I think the enqueuewritebuffer to it using sizeof(size_t) can cause issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now using cl_uint for the type of the array and an assert is added to ensure the casting is safe.

@@ -115,7 +115,8 @@ struct CreateCommandBufferRepeatedProperties : public BasicCommandBufferTest
TEST_FAIL);

cl_command_buffer_properties_khr invalid_properties[3] = {
CL_COMMAND_BUFFER_FLAGS_KHR, CL_INVALID_PROPERTY, 0
CL_COMMAND_BUFFER_FLAGS_KHR,
(cl_command_buffer_properties_khr)CL_INVALID_PROPERTY, 0
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure CL_INVALID_PROPERTY can be used in a property list like this. The spec only specifies its usage as a return value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used -1 instead.

Copy link
Contributor

@lakshmih lakshmih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments

Fixes narrowing conversion build errors in test_common

Removing disable of narrowing errors in main CMakeLists.txt
and moving it down to test_conformance CMakeLists.txt where
there are many more build errors revealed from this fix

Contributes KhronosGroup#787

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
Moves -Wno-narrowing down to only run on suites with
many narrowing errors.

Includes some quick fixes for one-off errors this caused.

Contributes KhronosGroup#787

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
Includes fix for MacOS build error

Contributes KhronosGroup#787

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
Contributes KhronosGroup#787

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants