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

Refactor buffer ReadWrite and Copy tests #2259

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

Conversation

MichaelRizkalla-arm
Copy link
Contributor

This change refactors the following tests to use RAII to clean-up allocated resources on exit, and adds additional changes as mentioned below:

  • test_arrayreadwrite
    • Allow different cl_mem_flags to be passed to the test.
  • test_bufferreadwriterect:
    • Allow different cl_mem_flags to be passed to the test.
    • Customisable copy, read and write functions.
  • test_buffer_copy
    • Fill the destination buffer with invalid_ptr instead of out_ptr if created with CL_MEM_(USE/COPY)_HOST_PTR.
  • test_buffer_partial_copy
    • Fill the destination buffer with invalid_ptr instead of out_ptr if created with CL_MEM_(USE/COPY)_HOST_PTR.

memset(invalid_ptr.get(), 0xdeaddead,
num_elements); // seed with incorrect data
memset(out_ptr.get(), 0xdeadbeef,
num_elements); // seed with incorrect data
Copy link
Contributor

Choose a reason for hiding this comment

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

This code only sets a quarter of the buffer, because memset only writes 1 byte, so the first quarter of invalid_ptr will be filled with 0xad and the rest will be unknown values.

So this would be better included in the for loop that is next:

for (int i = 0; i < num_elements; i++)
{
invalid_ptr[i] = (int)0xdeaddead;
out_ptr[i] = (int)0xdeadbeef;
reference_ptr[i] = (int)genrand_int32(d);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching it.
I have updated the commit.

Allow bufferreadwriterect test to use a customisable read, write and
copy test functions.

Signed-off-by: Michael Rizkalla <[email protected]>
This change uses RAII to manage object lifetimes to ensure objects'
destruction if an error occurred in the test.
Additionally, modify `test_arrayreadwrite` to pass a custom memory flag
to the test function.

Signed-off-by: Michael Rizkalla <[email protected]>
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.

3 participants