[clinfo] 127/148: Command-line processing

Andreas Beckmann anbe at moszumanska.debian.org
Mon Nov 17 14:09:55 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 3bcc4dee3261b4b484e557ac00b4a487767e4af3
Author: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Date:   Fri Nov 7 17:28:08 2014 +0100

    Command-line processing
---
 man/clinfo.1 | 24 +++++++++++++++++++++++-
 src/clinfo.c | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/man/clinfo.1 b/man/clinfo.1
index cf79ef1..8c55703 100644
--- a/man/clinfo.1
+++ b/man/clinfo.1
@@ -6,6 +6,7 @@ clinfo \- show OpenCL platforms and devices
 
 .SH SYNOPSIS
 .B clinfo
+.RI [ "options ..." ]
 
 .SH DESCRIPTION
 .B clinfo
@@ -13,7 +14,24 @@ prints all available information about all OpenCL platforms
 available on the system and the devices they expose.
 
 .SH OPTIONS
-This program accepts no options.
+.B clinfo
+accepts the following options:
+.TP 2
+.B --human
+produce human-friendly output; this is the default (except
+as noted below);
+.TP
+.B --raw
+produce machine-friendly output; this is the default if
+.B clinfo
+is invoked with a name that contains the string
+.RI \*(lq raw \*(rq;
+.TP
+.BR -h ", " -?
+show usage;
+.TP
+.BR --version ", " -v
+show program version.
 
 .SH CONFORMING TO
 
@@ -87,6 +105,10 @@ is only relevant for single precision in OpenCL 1.2 devices.
 .P
 Support for OpenCL 2.0 properties is not fully tested.
 
+.P
+Raw (machine-parseable) output is an experimental feature, the output
+format might undergo changes.
+
 .SH BUGS
 The results of the following undocumented properties might be
 interpreted incorrectly:
diff --git a/src/clinfo.c b/src/clinfo.c
index 0cd5387..48a9d4d 100644
--- a/src/clinfo.c
+++ b/src/clinfo.c
@@ -1820,14 +1820,51 @@ printDeviceInfo(cl_uint d)
 	extensions = NULL;
 }
 
+void version()
+{
+	puts("clinfo version 2.0.14.10.26");
+}
+
+void usage()
+{
+	version();
+	puts("Display properties of all available OpenCL platforms and devices");
+	puts("Usage: clinfo [options ...]\n");
+	puts("Options:");
+	puts("\t--human\t\thuman-friendly output (default)");
+	puts("\t--raw\t\traw output");
+	puts("\t-h, -?\t\tshow usage");
+	puts("\t--version, -v\tshow version\n");
+	puts("Defaults to raw mode if invoked with");
+	puts("a name that contains the string \"raw\"");
+}
+
 int main(int argc, char *argv[])
 {
 	cl_uint p, d;
+	int a = 0;
 
 	/* if there's a 'raw' in the program name, switch to raw output mode */
 	if (strstr(argv[0], "raw"))
 		output_mode = CLINFO_RAW;
 
+	/* process command-line arguments */
+	while (a < argc) {
+		++a;
+		if (!strcmp(argv[a], "--raw"))
+			output_mode = CLINFO_RAW;
+		else if (!strcmp(argv[a], "--human"))
+			output_mode = CLINFO_HUMAN;
+		else if (!strcmp(argv[a], "-?") || !strcmp(argv[a], "-h")) {
+			usage();
+			return 0;
+		} else if (!strcmp(argv[a], "--version") || !strcmp(argv[a], "-v")) {
+			version();
+			return 0;
+		}
+	}
+
+
 	ALLOC(strbuf, 1024, "general string buffer");
 	bufsz = 1024;
 

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