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

Added fp16 and fp64 api consistency tests #2058

Merged
merged 5 commits into from
Oct 1, 2024

Conversation

kamil-goras-mobica
Copy link
Contributor

Copy link
Member

@svenvh svenvh left a comment

Choose a reason for hiding this comment

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

The latest fixes LGTM; left a question for other reviewers.

test_conformance/api/test_api_consistency.cpp Show resolved Hide resolved
Comment on lines +1200 to +1206
error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE,
sizeof(value), &value, nullptr);
test_error(error,
"Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE");
test_assert_error(
value > 0,
"CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE must return nonzero value");
Copy link
Contributor

@bashbaug bashbaug Sep 26, 2024

Choose a reason for hiding this comment

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

So we go in with eyes open: this change requires CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE to be non-zero when fp64 is supported. This is true even if there is no "native" double precision support, say when CL_DEVICE_DOUBLE_FP_CONFIG includes CL_FP_SOFT_FLOAT.

No action required, but if we did want to "fix" this, some options might be:

  1. Remove the check entirely - the spec doesn't have any requirements for a value for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE when fp64 is supported. Note, there is a requirement when fp64 is NOT supported, so this check should not change.
  2. Have the check only when CL_DEVICE_DOUBLE_FP_CONFIG does not include CL_FP_SOFT_FLOAT, since there should be some "native" support in this case.

Same comments also apply to fp16.

Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed in the October 1st teleconference. We are going to leave this as-is for now. We will revisit in the future, if needed, if a vendor wants to return zero for CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE and still support fp64 for some reason.

@bashbaug
Copy link
Contributor

bashbaug commented Oct 1, 2024

Merging as discussed in the October 1st teleconference.

@bashbaug bashbaug merged commit bcd5478 into KhronosGroup:main Oct 1, 2024
7 checks passed
{
error = clGetDeviceInfo(deviceID, CL_DEVICE_HALF_FP_CONFIG,
sizeof(value), &value, nullptr);
test_error(error, "Unable to get device CL_DEVICE_HALF_FP_CONFIG");
Copy link
Contributor

Choose a reason for hiding this comment

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

This requires implementations without the cl_khr_fp16 extension to recognise CL_DEVICE_HALF_FP_CONFIG, but support for CL_DEVICE_HALF_FP_CONFIG is only required if that extension is available, is it not? https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#CL_DEVICE_HALF_FP_CONFIG says "provided by the cl_khr_fp16 extension". Our implementation, when FP16 support is disabled, returns CL_INVALID_VALUE here rather than setting value to 0, and I think that is correct, since the spec also says it returns:

CL_INVALID_VALUE if param_name is not one of the supported values or if size in bytes specified by param_value_size is < size of return type as specified in the Device Queries table and param_value is not a NULL value or if param_name is a value that is available as an extension and the corresponding extension is not supported by the device.

Copy link
Member

Choose a reason for hiding this comment

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

@hvdijk I agree with your analysis. CL_DEVICE_HALF_FP_CONFIG is provided by the cl_khr_fp16 extension, so if that extension is not supported the query should return CL_INVALID_VALUE indeed.

(the half query seems different from CL_DEVICE_DOUBLE_FP_CONFIG, which does not have a "provided by" clause)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, created #2108 to change that.

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