Skip to content

Commit

Permalink
Added check for necessary OpenCL version
Browse files Browse the repository at this point in the history
  • Loading branch information
Beanavil committed Jul 5, 2024
1 parent 36e199c commit 934b1c3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
14 changes: 13 additions & 1 deletion samples/core/blur/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,19 @@ std::tuple<bool, bool, bool, std::string> BlurCppExample::query_capabilities()
bool use_subgroup_exchange_relative = cl::util::supports_extension(
device, "cl_khr_subgroup_shuffle_relative");

// 5) Query OpenCL version to compile for.
// 5) Check if device is apt for this sample.
if (opencl_version_contains(dev_version, "1."))
{
std::cout
<< "This sample requires OpenCL 2.0 or greater,"
"but the device chosen only supports OpenCL "
<< dev_version
<< ". Please try with a different device."
<< std::endl;
exit(EXIT_SUCCESS);
}

// 6) Query OpenCL version to compile for.
// If no -cl-std option is specified then the highest 1.x version
// supported by each device is used to compile the program. Therefore,
// it's necessary to add the -cl-std option for 2.0 and 3.0 OpenCL
Expand Down
20 changes: 15 additions & 5 deletions samples/core/blur/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,15 +1057,25 @@ int main(int argc, char *argv[])
free(name);
}

// 5) Query OpenCL version to compile for.
// If no -cl-std option is specified then the highest 1.x version
// supported by each device is used to compile the program. Therefore,
// it's necessary to add the -cl-std option for 2.0 and 3.0 OpenCL
// versions.
// 5) Check if device is apt for this sample.
char dev_version[64];
OCLERROR_RET(clGetDeviceInfo(s.device, CL_DEVICE_VERSION,
sizeof(dev_version), &dev_version, NULL),
error, end);
if (opencl_version_contains(dev_version, "1."))
{
fprintf(stdout,
"This sample requires OpenCL 2.0 or greater,"
"but the device chosen only supports OpenCL %s."
". Please try with a different device.", dev_version);
exit(EXIT_SUCCESS);
}

// 6) Query OpenCL version to compile for.
// If no -cl-std option is specified then the highest 1.x version
// supported by each device is used to compile the program. Therefore,
// it's only necessary to add the -cl-std option for 2.0 and 3.0 OpenCL
// versions.
char compiler_options[1023] = "";
if (opencl_version_contains(dev_version, "3."))
{
Expand Down

0 comments on commit 934b1c3

Please sign in to comment.