[clinfo] 10/36: Introduce preliminary version checks
Andreas Beckmann
anbe at moszumanska.debian.org
Wed Feb 17 18:32:36 UTC 2016
This is an automated email from the git hooks/post-receive script.
anbe pushed a commit to branch master
in repository clinfo.
commit 236abd6e634e3b879314fedacd48b079cd594624
Author: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Date: Tue Dec 8 21:02:48 2015 +0100
Introduce preliminary version checks
If the highest platform version is lower than the OpenCL version
supported by the ICD loader, print a warning note at the end.
Currently we only check the version supported by ICD loader only for
ocl-icd, which exposes it via an extension.
---
src/clinfo.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/src/clinfo.c b/src/clinfo.c
index 7ff6217..913076a 100644
--- a/src/clinfo.c
+++ b/src/clinfo.c
@@ -37,6 +37,12 @@ struct platform_info_checks {
cl_uint num_platforms;
cl_platform_id *platform;
+/* highest version exposed by any platform: if the OpenCL library (the ICD loader)
+ * has a lower version, problems may arise (such as API calls causing segfaults
+ * or any other unexpected behavior
+ */
+cl_uint max_plat_version;
+cl_uint icd_loader_ocl_version;
struct platform_data *pdata;
/* maximum length of a platform's sname */
@@ -428,6 +434,9 @@ printPlatformInfo(cl_uint p)
}
+ if (pinfo_checks.plat_version > max_plat_version)
+ max_plat_version = pinfo_checks.plat_version;
+
/* if no CL_PLATFORM_ICD_SUFFIX_KHR, use P### as short/symbolic name */
if (!pdata[p].sname) {
ALLOC(pdata[p].sname, 32, "platform symbolic name");
@@ -2523,8 +2532,23 @@ void oclIcdProps()
had_error = icdl_info_str(traits->param,
output_mode == CLINFO_HUMAN ?
traits->pname : traits->sname);
+
+ if (!had_error && traits->param == CL_ICDL_OCL_VERSION) {
+ icd_loader_ocl_version = getOpenCLVersion(strbuf + 7);
+ }
}
}
+
+ if (output_mode == CLINFO_HUMAN && icd_loader_ocl_version &&
+ icd_loader_ocl_version < max_plat_version) {
+ printf( "\tNOTE:\tyour OpenCL library only supports OpenCL %u.%u,\n"
+ "\t\tbut some installed platforms support OpenCL %u.%u.\n"
+ "\t\tPrograms using %u.%u features may crash\n"
+ "\t\tor behave unexepectedly\n",
+ icd_loader_ocl_version / 10, icd_loader_ocl_version % 10,
+ max_plat_version / 10, max_plat_version % 10,
+ max_plat_version / 10, max_plat_version % 10);
+ }
}
#if defined __GNUC__ && ((__GNUC__*10 + __GNUC_MINOR__) < 46)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/clinfo.git
More information about the Pkg-opencl-commits
mailing list