CodePlexProject Hosting for Open Source Software
Home Declarative command line parser sample
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Text.RegularExpressions; using System.ComponentModel; using System.Reflection; using System.Globalization; using System.IO; namespace ConsoleApplication1 { public static class Cl { public enum DeviceType { Cpu, Gpu, Default } } // platformname=*Intel* device=Gpu rows=1024 cols=1024 localWorkSize=16 iterations=3000 class Program { static void Main(string[] args) { var platformName = "*"; var deviceType = Cl.DeviceType.Default; var rows = 512; var columns = 512; var localWorkSize = 32; var iterations = 1000; args.Process(usage => Console.WriteLine(usage), new CommandLine.Switch("platform", v => platformName = v.First()) { Description = "Platform name with wildcards", DefaultValue = platformName }, new CommandLine.Switch<Cl.DeviceType>("device", v => deviceType = v.First()) { Description = "Device type Cpu/Gpu/Default", DefaultValue = deviceType }, new CommandLine.Switch<int>("rows", v => rows = rows = v.First()) { Description = "Number of rows in the matrix", DefaultValue = rows }, new CommandLine.Switch<int>("cols", v => columns = columns = v.First()) { Description = "Number of columns in the matrix", DefaultValue = columns }, new CommandLine.Switch<int>("localWorkSize", v => localWorkSize = v.First()) { Description = "Local work size (should be a multiple of rows and cols)", DefaultValue = localWorkSize }, new CommandLine.Switch<int>("iterations", v => iterations = iterations = v.First()) { Description = "Number of iterations to run for benchmarking", DefaultValue = iterations }); } } }
Last edited Jan 9 at 8:57 PM by ananth, version 2
There is no recommended release for this project.