[clinfo] 16/55: Memory suffix tuning

Andreas Beckmann anbe at moszumanska.debian.org
Sat Jan 13 14:39:59 UTC 2018


This is an automated email from the git hooks/post-receive script.

anbe pushed a commit to branch master
in repository clinfo.

commit 5a12b5883c58bbae7909f8f21e199d2c9f7ec5f8
Author: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Date:   Thu Feb 9 15:48:35 2017 +0100

    Memory suffix tuning
    
    A cl_ulong can represent up to 16EiB, so let's extend the suffix table
    up to that, and in fact beyond, down the YiB.
    
    It is now technically impossible for strbuf_mem to move beyond the end
    of the array (cf. Debian Bug #848177) since no memory amount that can be
    represented will trigger the off-by-one, but let's fix the logic anyway.
---
 src/clinfo.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/clinfo.c b/src/clinfo.c
index cf1b7ae..2e2b0c1 100644
--- a/src/clinfo.c
+++ b/src/clinfo.c
@@ -198,11 +198,15 @@ static const char* svm_cap_raw_str[] = {
 
 const size_t svm_cap_count = ARRAY_SIZE(svm_cap_str);
 
+/* SI suffixes for memory sizes. Note that in OpenCL most of them are
+ * passed via a cl_ulong, which at most can mode 16 EiB, but hey,
+ * let's be forward-thinking ;-)
+ */
 static const char* memsfx[] = {
-	"B", "KiB", "MiB", "GiB", "TiB"
+	"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"
 };
 
-const size_t memsfx_count = ARRAY_SIZE(memsfx);
+const size_t memsfx_end = ARRAY_SIZE(memsfx) + 1;
 
 static const char* lmem_type_str[] = { none, "Local", "Global" };
 static const char* lmem_type_raw_str[] = { none_raw, "CL_LOCAL", "CL_GLOBAL" };
@@ -822,7 +826,7 @@ size_t strbuf_mem(cl_ulong val, size_t szval)
 {
 	double dbl = val;
 	size_t sfx = 0;
-	while (dbl > 1024 && sfx < memsfx_count) {
+	while (dbl > 1024 && sfx < memsfx_end) {
 		dbl /= 1024;
 		++sfx;
 	}

-- 
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