OpenCL-Docs icon indicating copy to clipboard operation
OpenCL-Docs copied to clipboard

clCreateContextFromType with properties != NULL and unspecified or invalid platform

Open s-barannikov opened this issue 1 year ago • 2 comments

  1. The documentation does not specify what error code should be returned by clCreateContextFromType if all of the following conditions are met:
  • properties != NULL;
  • properties didn't specify a platform;
  • no platform could be selected.

I guess it should specify that CL_INVALID_PLATFORM is returned in this case (the same as if properties == NULL).

  1. The documentation is ambigous on which error code should be returned by clCreateContextFromType if properties specify an invalid platform:
  • CL_INVALID_PLATFORM ... if platform value specified in properties is not a valid platform.
  • CL_INVALID_PROPERTY ..., if the value specified for a supported property name is not valid ...

s-barannikov avatar Feb 16 '24 13:02 s-barannikov

For (1) we could modify the error description to cover this scenario if you'd like. I agree CL_INVALID_PLATFORM makes the most sense. Maybe something like:

CL_INVALID_PLATFORM if ~~properties is NULL~~ no platform value is specified and no platform could be selected or if the platform value specified in properties is not a valid platform.

For (2), I think either error code would be valid, and I don't believe we currently test for this case. If it's helpful though, I recommend chosing the more descriptive error, so CL_INVALID_PLATFORM.

Note, if you are implementing an ICD then this checking will happen in the OpenCL ICD loader: link.

bashbaug avatar Feb 16 '24 19:02 bashbaug

@bashbaug Thank you for your reply.

For (1) we could modify the error description to cover this scenario if you'd like. I agree CL_INVALID_PLATFORM makes the most sense. Maybe something like:

This is exactly what I had in mind.

I recommend chosing the more descriptive error, so CL_INVALID_PLATFORM.

Thanks, I'll follow your suggestion. This would also be closer to how other interfaces handle invalid platforms.

Note, if you are implementing an ICD then this checking will happen in the OpenCL ICD loader:

Ah, right, I always forget about this. Thanks for reminding. I'm implementing both ICD and non-ICD modes (controlled by a preprocessor define), so I would need to handle it myself in the non-ICD mode anyway. I'll use the link as a reference.

s-barannikov avatar Feb 16 '24 19:02 s-barannikov

I think this issue was fixed by #1063 so I'm going to close this issue. If anything more is needed please feel free to re-open it or file another issue - thanks!

bashbaug avatar May 20 '24 17:05 bashbaug