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

Add testing for CL_KERNEL_LOCAL_MEM_SIZE #1235 #2089

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

Conversation

kamil-goras-mobica
Copy link
Contributor


size_t elements = 100;
size_t sizeToAllocate = elements * sizeof(cl_int);
int* localData = (cl_int*)malloc(sizeToAllocate);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use a smart pointer here rather than malloc (e.g. make_unique) so that if the function returns early before the free(localData) we don't leak.

Copy link
Contributor

Choose a reason for hiding this comment

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

localData is unused. We may as well remove it entirely.

Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

Note: it seems odd to put this test into test_api_consistency.cpp, since it has nothing to do with API consistency checks. I'd recommend putting it into its own new file test_kernel_local_memory_size.cpp, similar to the existing test_kernel_private_memory_size.cpp.

test_conformance/api/test_api_consistency.cpp Outdated Show resolved Hide resolved
test_conformance/api/test_api_consistency.cpp Outdated Show resolved Hide resolved
Comment on lines 1191 to 1196
if (create_single_kernel_helper(context, &program, &kernel, 1, empty_kernel,
"empty_kernel")
!= 0)
{
return -1;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We really ought to return TEST_FAIL here rather than the magic number -1. Or, even better, something like:

Suggested change
if (create_single_kernel_helper(context, &program, &kernel, 1, empty_kernel,
"empty_kernel")
!= 0)
{
return -1;
}
error = create_single_kernel_helper(context, &program, &kernel, 1, empty_kernel,
"empty_kernel");
test_error(error, "Unable to create empty_kernel");

test_conformance/api/test_api_consistency.cpp Outdated Show resolved Hide resolved
test_conformance/api/main.cpp Outdated Show resolved Hide resolved
@kamil-goras-mobica
Copy link
Contributor Author

@bashbaug I have added some corrections, tested under Intel, Nvidia, POCL and SimpleOpenCLSamples Layers. There were discrepancies in results, I wanted to check all scenarios that get into my mind. Please review and tell me which does not make sense.

Copy link
Contributor

@EwanC EwanC left a comment

Choose a reason for hiding this comment

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

Looking good but noticed that we don't verify the param_value_size_ret output parameter to clGetKernelWorkGroupInfo, but a conformant implementation should set that to sizeof(cl_ulong). Can we check that too.

EwanC
EwanC previously approved these changes Oct 15, 2024
@bashbaug
Copy link
Contributor

Discussed in the October 15th teleconference. We will wait one more week for a few more reviews.

test_conformance/api/test_kernel_local_memory_size.cpp Outdated Show resolved Hide resolved
test_conformance/api/test_kernel_local_memory_size.cpp Outdated Show resolved Hide resolved
test_conformance/api/test_kernel_local_memory_size.cpp Outdated Show resolved Hide resolved
Comment on lines +183 to +184
test_assert_error(kernel_local_usage >= memory,
"kernel local mem size failed");
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, this check is failing for me for POCL because the queried value is coming back as zero. I'm not sure if this is a POCL issue or if POCL is being clever and optimizing away the local memory array - maybe @pjaaskel can check?

Copy link
Contributor

Choose a reason for hiding this comment

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

It shouldn't optimize this case away. I opened a PoCL issue. We'll check what's going on.

Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

Gah, my previous review should have been "request changes", sorry about that.

Here is one more nitpick - there are several misspellings of "verification".

Comment on lines 180 to 181
test_assert_error(local_memory_kernel_verify(),
"local_memory_kernel data verificaion failed");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
test_assert_error(local_memory_kernel_verify(),
"local_memory_kernel data verificaion failed");
test_assert_error(local_memory_kernel_verify(),
"local_memory_kernel data verification failed");

Copy link
Contributor

Choose a reason for hiding this comment

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

There are still two additional places with the same misspelling.


return true;
};
test_assert_error(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be changed to:

auto local_param_local_memory_kernel_verify = & {
constexpr size_t size = 10;
int testData[size];

for (size_t i = 0; i < size; i++)
{
    testData[i] = i * 2;
}

int temp = testData[9];
for (size_t i = 0; i < size; i++)
{
    if (i == 9)
        testData[9] += temp;
    else
        testData[9] += testData[i];
}
testData[9] += 666;

for (size_t i = 0; i < size; i++)
{
    if (data[i] != testData[i]) return false;
}

return true;

};

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.

Looks good in present form, suggested a modification.

Copy link
Contributor

@bashbaug bashbaug left a comment

Choose a reason for hiding this comment

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

LGTM, I'm OK with this going in as-is.

The POCL failure still exists with the latest code, though this may be a legitimate POCL failure.

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.

5 participants