[clinfo] 48/148: Refactor MEM_PARAM parenthetical print
Andreas Beckmann
anbe at moszumanska.debian.org
Mon Nov 17 14:09:44 UTC 2014
This is an automated email from the git hooks/post-receive script.
anbe pushed a commit to branch clinfo
in repository clinfo.
commit 312de6caa1e97687bce687b8de9523fe1b91ef3c
Author: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Date: Tue Apr 29 23:08:17 2014 +0200
Refactor MEM_PARAM parenthetical print
So it can be used for the AMD Free global memory extension
without code duplication.
---
src/clinfo.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/src/clinfo.c b/src/clinfo.c
index 40e4a65..f7d278c 100644
--- a/src/clinfo.c
+++ b/src/clinfo.c
@@ -246,17 +246,19 @@ printDeviceInfo(cl_uint d)
GET_PARAM(param, szval); \
printf(I1_STR "%zu" sfx "\n", name, szval); \
} while (0)
-#define MEM_PARAM(param, name) do { \
- GET_PARAM(param, ulongval); \
- doubleval = ulongval; \
- if (ulongval > KB) { \
+#define MEM_PARAM_STR(var, fmt, name) do { \
+ doubleval = var; \
+ if (var > KB) { \
snprintf(strbuf, bufsz, " (%6.4lg%s)", \
MEM_SIZE(doubleval), \
MEM_PFX(doubleval)); \
strbuf[bufsz-1] = '\0'; \
} else strbuf[0] = '\0'; \
- printf(I1_STR "%" PRIu64 "%s\n", \
- name, ulongval, strbuf); \
+ printf(I1_STR fmt "%s\n", name, var, strbuf); \
+} while (0)
+#define MEM_PARAM(param, name) do { \
+ GET_PARAM(param, ulongval); \
+ MEM_PARAM_STR(ulongval, "%" PRIu64, name); \
} while (0)
#define BOOL_PARAM(param, name) do { \
GET_PARAM(param, boolval); \
@@ -536,14 +538,7 @@ printDeviceInfo(cl_uint d)
GET_PARAM_ARRAY(GLOBAL_FREE_MEMORY_AMD, szvals, szval);
szels = szval/sizeof(*szvals);
for (cursor = 0; cursor < szels; ++cursor) {
- doubleval = szvals[cursor];
- if (szvals[cursor] > KB) {
- snprintf(strbuf, bufsz, " (%6.4lg%s)",
- MEM_SIZE(doubleval),
- MEM_PFX(doubleval));
- strbuf[bufsz-1] = '\0';
- } else strbuf[0] = '\0';
- printf(I1_STR "%zu%s\n", "Free global memory (AMD)", szvals[cursor], strbuf);
+ MEM_PARAM_STR(szvals[cursor], "%zu", "Free global memory (AMD)");
}
INT_PARAM(GLOBAL_MEM_CHANNELS_AMD, "Global memory channels (AMD)",);
--
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