<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ananth&#039;s very own website &#187; Blog</title>
	<atom:link href="http://ananthonline.net/category/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://ananthonline.net</link>
	<description>Nemo vir est qui mundum non reddat meliorem</description>
	<lastBuildDate>Sun, 29 Jan 2012 05:04:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Quenya &#8211; Beyond syntax</title>
		<link>http://ananthonline.net/2011/08/04/quenya-beyond-syntax/</link>
		<comments>http://ananthonline.net/2011/08/04/quenya-beyond-syntax/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 22:02:53 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Quenya]]></category>

		<guid isPermaLink="false">http://ananthonline.net/?p=294</guid>
		<description><![CDATA[ Tweet <p>Edit &#8211; I have been looking at other alternatives to writing my own parser/language, although I did learn a lot when trying to write my own. Nemerle seems like the most likely candidate to me, given how extensible and C#-like it is. Among mainstream languages, I am also beginning to favor F#. Thanks [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2011%2F08%2F04%2Fquenya-beyond-syntax%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2011/08/04/quenya-beyond-syntax/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2011/08/04/quenya-beyond-syntax/"  data-text="Quenya &#8211; Beyond syntax" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2011/08/04/quenya-beyond-syntax/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p><em><strong>Edit</strong> &#8211; I have been looking at other alternatives to writing my own parser/language, although I did learn a lot when trying to write my own. <a title="Nemerle" href="http://nemerle.org/About/" target="_blank">Nemerle</a> seems like the most likely candidate to me, given how extensible and C#-like it is. Among mainstream languages, I am also beginning to favor <a title="F#" href="http://msdn.microsoft.com/en-us/vstudio/hh388569.aspx" target="_blank">F#</a>. Thanks to everyone in the comments section who pointed out various options to me.</em></p>
<p>I guess it&#8217;s finally time to let people know what I&#8217;ve been working on (and thinking about) for the past six months or so.</p>
<p>The driving force behind this new project is my increasing frustration with existing languages. While most of them have been crafted masterfully, there&#8217;s always something in each that isn&#8217;t available and prevents me from writing the most elegant or readable code for that compiler. With C#, my list of gripes is long and would eat up a whole post. Let&#8217;s just say that while I love C#, there are many features I wish it had. And most of the time, it&#8217;s not something that can&#8217;t be added, it&#8217;s just not in the compiler because</p>
<ul>
<li>The feature probably wasn&#8217;t considered or was cut because it wasn&#8217;t an important use-case</li>
<li>The development team couldn&#8217;t add it in due to time constraints (that&#8217;s fair)</li>
<li>Or they believe it&#8217;s not something that the language needs (these are far more frustrating, because you know they&#8217;re never going to be in the language)</li>
</ul>
<p>Again, I state these without mentioning what it is I want, which is indeed the point of this post. <img src='http://ananthonline.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Without further ado, I present a proposed implementation for my (.NET) compiler which I have dubbed <a title="Quenya" href="http://en.wikipedia.org/wiki/Quenya" target="_blank">Quenya</a> for the time-being. I intended this compiler to be syntax agnostic (or at the very least, <em>extremely extensible</em>) and therefore the bulk of the idea revolves around a way for users to re-define source code and for the compiler to be able to parse it.</p>
<p>Before we begin, I would like to point you to <a title="this" href="http://blogs.msdn.com/b/lukeh/archive/2007/08/19/monadic-parser-combinators-using-c-3-0.aspx" target="_blank">this</a> awesome post by Luke Hoban, who is one of my favorite blog authors ever. I have used the source code for his monadic parser to build Quenya&#8217;s parsing logic.</p>
<p>To allow Quenya to parse something, it is not enough to provide it with source code. Quenya needs a grammar/parser (or a reference to one) and the source to parse. The parser is then expected to return a set of known AST nodes when called upon to parse the source code (linked to that grammar/parser). The rest of the compiler phases then proceed as usual and the compiler spits out IL. The figure below shows an overview of the parsing process in Quenya.</p>
<div id="attachment_295" class="wp-caption alignnone" style="width: 392px"><a href="http://ananthonline.net/wp-content/uploads/2011/08/image001.png"><img class="size-full wp-image-295" title="quenya-parsing.png" src="http://ananthonline.net/wp-content/uploads/2011/08/image001.png" alt="quenya parsing overview" width="382" height="241" /></a><p class="wp-caption-text">Quenya parsing overview</p></div>
<p>But it&#8217;s probably more cumbersome to write an entire parser each time you want to add or modify a single feature of the base grammar you&#8217;re using right? That&#8217;s where the monadic parser written in C# comes in. To illustrate, let&#8217;s take a simple example. We&#8217;ll write a simple parser that can parse words (alphabets) given a string and then extend it to have more features without rewriting the entire parser.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="csharp"><pre class="de1"><span class="co1">// A simpleton parser, one that doesn't understand the . (period) and that will fail if it encounters one.</span>
<span class="kw1">public</span> abstract <span class="kw4">class</span> SimpleSentenceParser<span class="sy0">:</span> CharParsers
<span class="br0">&#123;</span>
    <span class="co1">// Defines the set of all whitespace characters</span>
	<span class="kw1">private</span> Parser _whitespaceChars<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser WhitespaceChars
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _whitespaceChars <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_whitespaceChars <span class="sy0">=</span> <span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">' '</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="me1">OR</span><span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">'<span class="es0">\t</span>'</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="me1">OR</span><span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">'<span class="es0">\n</span>'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="me1">OR</span><span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">'<span class="es0">\r</span>'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// A whitespace is 0 or more repetitions of a valid Whitespace character</span>
	<span class="kw1">private</span> Parser _whitespace<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser Whitespace
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _whitespace <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_whitespace <span class="sy0">=</span> Rep<span class="br0">&#40;</span>WhitespaceChars<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// A word is multiple (alphabetic) characters that are not whitespaces</span>
	<span class="kw1">private</span> Parser _word<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser Word
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _word <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_word <span class="sy0">=</span> <span class="kw1">from</span> w <span class="kw1">in</span> Whitespace
                            <span class="kw1">from</span> c <span class="kw1">in</span> <span class="kw4">Char</span><span class="br0">&#40;</span><span class="kw4">char</span><span class="sy0">.</span><span class="me1">IsLetter</span><span class="br0">&#41;</span>
                            <span class="kw1">from</span> word <span class="kw1">in</span> Rep<span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="kw4">char</span><span class="sy0">.</span><span class="me1">IsLetter</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
                            <span class="kw1">select</span> <span class="kw3">new</span> WordTerm<span class="br0">&#40;</span>word<span class="sy0">.</span><span class="me1">Aggregate</span><span class="br0">&#40;</span><span class="kw3">new</span> <span class="kw4">string</span><span class="br0">&#40;</span><span class="kw3">new</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="br0">&#123;</span>c<span class="br0">&#125;</span><span class="br0">&#41;</span>, <span class="br0">&#40;</span>acc, ch<span class="br0">&#41;</span> <span class="sy0">=&amp;</span>gt<span class="sy0">;</span> acc <span class="sy0">+</span> ch<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// A sentence is a set of words - simplistic, but will work for single sentences</span>
	<span class="kw1">private</span> Parser _sentence<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser Sentence
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _sentence <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_sentence <span class="sy0">=</span> <span class="kw1">from</span> words <span class="kw1">in</span> Rep<span class="br0">&#40;</span>Word<span class="br0">&#41;</span>
                                <span class="kw1">select</span> <span class="kw3">new</span> SentenceTerm<span class="br0">&#40;</span>words<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// Set of all sentences in the input (start symbol for this grammar)</span>
	<span class="kw1">private</span> Parser _all<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser All
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _all <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_all <span class="sy0">=</span> <span class="kw1">from</span> sentence <span class="kw1">in</span> Sentence
                           <span class="kw1">select</span> <span class="br0">&#40;</span>Term<span class="br0">&#41;</span> sentence<span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="co1">// A concrete implementation of the above parser that can accept string input</span>
<span class="kw1">public</span> <span class="kw4">class</span> SimpleSentenceParser<span class="sy0">:</span> SimpleSentenceParser
<span class="br0">&#123;</span>
    <span class="kw1">public</span> <span class="kw1">override</span> Parser AnyChar <span class="co1">// Pick one character at a time</span>
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> input <span class="sy0">=&amp;</span>gt<span class="sy0">;</span> input<span class="sy0">.</span><span class="me1">Length</span> <span class="sy0">&amp;</span>gt<span class="sy0">;</span> <span class="nu0">0</span> <span class="sy0">?</span> 
				<span class="kw3">new</span> Result<span class="br0">&#40;</span>input<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>, input<span class="sy0">.</span><span class="me1">Substring</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">:</span> 
				<span class="kw1">null</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Note that the code above is quite readable (as a grammar) due to the use of C# query expressions. Now let&#8217;s look at a parser that &#8220;extends&#8221; the capabilities of this parser.</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="csharp"><pre class="de1"><span class="co1">// A slightly more intelligent parser, it can identify sentences properly</span>
<span class="co1">// Note that this parser does NOT redefine what a word means. It only redefines a sentence.</span>
<span class="kw1">public</span> abstract <span class="kw4">class</span> BetterSentenceParser<span class="sy0">:</span> SimpleSentenceParser
<span class="br0">&#123;</span>
    <span class="kw1">private</span> Parser _whitespaceChars<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">override</span> Parser WhitespaceChars <span class="co1">// Adds to existing whitespace characters</span>
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _whitespaceChars <span class="sy0">??</span>
                <span class="br0">&#40;</span>_whitespaceChars <span class="sy0">=</span> <span class="kw1">base</span><span class="sy0">.</span><span class="me1">WhitespaceChars</span><span class="sy0">.</span><span class="me1">OR</span><span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">','</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="me1">OR</span><span class="br0">&#40;</span><span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">';'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// New, defines sentence terminators to allow this parser to understand them</span>
	<span class="kw1">private</span> Parser _sentenceTerminators<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">virtual</span> Parser SentenceTerminators
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _sentenceTerminators <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_sentenceTerminators <span class="sy0">=</span> <span class="kw4">Char</span><span class="br0">&#40;</span><span class="st0">'.'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// Redefines what a sentence means and takes sentence terminators</span>
	<span class="co1">// into account</span>
	<span class="kw1">private</span> Parser _sentence<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">override</span> Parser Sentence
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _sentence <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_sentence <span class="sy0">=</span> <span class="kw1">from</span> words <span class="kw1">in</span> Rep<span class="br0">&#40;</span>Word<span class="br0">&#41;</span>
                                <span class="kw1">from</span> terminator <span class="kw1">in</span> SentenceTerminators
                                <span class="kw1">select</span> <span class="kw3">new</span> SentenceTerm<span class="br0">&#40;</span>words<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// This now returns multiple sentences</span>
	<span class="kw1">private</span> Parser _all<span class="sy0">;</span>
    <span class="kw1">public</span> <span class="kw1">override</span> Parser All <span class="co1">// Actually selects multiple sentences</span>
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> _all <span class="sy0">??</span>
                   <span class="br0">&#40;</span>_all <span class="sy0">=</span> <span class="kw1">from</span> sentences <span class="kw1">in</span> Rep<span class="br0">&#40;</span>Sentence<span class="br0">&#41;</span>
                           <span class="kw1">select</span> <span class="br0">&#40;</span>Term<span class="br0">&#41;</span><span class="kw3">new</span> ParagraphTerm<span class="br0">&#40;</span>sentences<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="co1">// A concrete implementation of a parser that can accept string input</span>
<span class="kw1">public</span> <span class="kw4">class</span> BetterSentenceParser <span class="sy0">:</span> BetterSentenceParser
<span class="br0">&#123;</span>
    <span class="kw1">public</span> <span class="kw1">override</span> Parser AnyChar
    <span class="br0">&#123;</span>
        get
        <span class="br0">&#123;</span>
            <span class="kw1">return</span> input <span class="sy0">=&amp;</span>gt<span class="sy0">;</span> input<span class="sy0">.</span><span class="me1">Length</span> <span class="sy0">&amp;</span>gt<span class="sy0">;</span> <span class="nu0">0</span> <span class="sy0">?</span> <span class="kw3">new</span> Result<span class="br0">&#40;</span>input<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>, input<span class="sy0">.</span><span class="me1">Substring</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">:</span> <span class="kw1">null</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Ah, that looks fairly simple! The observant among you no doubt noticed that this parser extends (Sentence) and modifies existing behavior (WhitespaceChars) without having to do all the work by itself. Using the concrete version of these two parsers, we can now parse stuff!</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="csharp"><pre class="de1"><span class="kw1">internal</span> <span class="kw4">class</span> Program
<span class="br0">&#123;</span>
    <span class="kw1">private</span> <span class="kw1">const</span> <span class="kw4">string</span> SimpleText <span class="sy0">=</span> <span class="st_h">@&quot;Lorem ipsum dolor sit amet&quot;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw1">private</span> <span class="kw1">const</span> <span class="kw4">string</span> ComplexText <span class="sy0">=</span>
        <span class="st_h">@&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus enim lorem,&quot;</span> <span class="sy0">+</span>
        <span class="st_h">@&quot; tincidunt ac sollicitudin fringilla, vulputate a dolor. Sed eu viverra ligula.&quot;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw1">private</span> <span class="kw1">static</span> <span class="kw4">void</span> Main<span class="br0">&#40;</span><span class="kw4">string</span><span class="br0">&#91;</span><span class="br0">&#93;</span> args<span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="co1">// Will parse SimpleText into multiple words and one sentence</span>
		<span class="br0">&#123;</span>
			var parser <span class="sy0">=</span> <span class="kw3">new</span> SimpleSentenceParser<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
			var result <span class="sy0">=</span> parser<span class="sy0">.</span><span class="me1">All</span> <span class="br0">&#40;</span>SimpleText<span class="br0">&#41;</span><span class="sy0">;</span>
		<span class="br0">&#125;</span>
&nbsp;
        <span class="co1">// Will parse ComplexText partially, fail when it encounters the '.'</span>
		<span class="br0">&#123;</span>
			var parser <span class="sy0">=</span> <span class="kw3">new</span> SimpleSentenceParser<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
			var result <span class="sy0">=</span> parser<span class="sy0">.</span><span class="me1">All</span> <span class="br0">&#40;</span>ComplexText<span class="br0">&#41;</span><span class="sy0">;</span>
		<span class="br0">&#125;</span>
&nbsp;
        <span class="co1">// Will parse ComplexText into multiple words and multiple sentences</span>
		<span class="br0">&#123;</span>
			var parser <span class="sy0">=</span> <span class="kw3">new</span> ComplexSentenceParser<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
			var result <span class="sy0">=</span> parser<span class="sy0">.</span><span class="me1">All</span> <span class="br0">&#40;</span>ComplexText<span class="br0">&#41;</span><span class="sy0">;</span>
		<span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Let&#8217;s now extend this concept given a fully functional C# parser definition. The user will now be able to &#8220;modify&#8221; the syntax of the language by defining his own parser that changes certain productions and/or terminals in the grammar. Add in a mechanism to link a given source file to a given grammar/parser (attribute on the parser = file extension of source) and you have Quenya, a language that encourages people to define and modify it.</p>
<p>Granted, this is probably tougher than just learning one language, but considering that the code you write using your DSL or modified base language will be much, much more suited to your purposes (if you use it wisely) and that most of your code will be written in the straight-up base grammar for your language makes this worth it (to me, at least &#8211; I&#8217;d be happy to hear your thought/comments). Also, people who don&#8217;t care about language extensibility can just use a vanilla grammar for the language of their choice and continue doing what they&#8217;ve been doing.</p>
<p>The next post on Quenya will deal with the implications of a language like this and how it can be used (or abused) in a real context.</p>
<p>Download the source code here: <a href="http://ananthonline.net/wp-content/uploads/2011/08/QuenyaParsing.zip">QuenyaParsing</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2011/08/04/quenya-beyond-syntax/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Downloads page is working again</title>
		<link>http://ananthonline.net/2010/11/06/downloads-page-is-working-again/</link>
		<comments>http://ananthonline.net/2010/11/06/downloads-page-is-working-again/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 20:05:40 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/blog/general/downloads-page-is-working-again</guid>
		<description><![CDATA[ Tweet <p>I have fixed the Brahma &#124; Downloads page, and it is back up. Thanks to everyone who pointed that out, and sorry it took so long for me to get around to it!</p> ]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F11%2F06%2Fdownloads-page-is-working-again%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/11/06/downloads-page-is-working-again/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/11/06/downloads-page-is-working-again/"  data-text="Downloads page is working again" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/11/06/downloads-page-is-working-again/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>I have fixed the Brahma | Downloads page, and it is back up. Thanks to everyone who pointed that out, and sorry it took so long for me to get around to it!</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/11/06/downloads-page-is-working-again/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Brahma.OpenCL works and is available to check out!</title>
		<link>http://ananthonline.net/2010/10/18/brahma-opencl-works-and-is-available-to-check-out/</link>
		<comments>http://ananthonline.net/2010/10/18/brahma-opencl-works-and-is-available-to-check-out/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 02:55:13 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/blog/general/brahma-opencl-works-and-is-available-to-check-out</guid>
		<description><![CDATA[ Tweet <p>Ok, I finally got around to cleaning up the Brahma code (just a little, mind you – there’s loads more to do!) and checking it in! Yes, that means you can try it out now! Because there are no releases, you’re going to have to check out the code with the instructions from [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F10%2F18%2Fbrahma-opencl-works-and-is-available-to-check-out%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/10/18/brahma-opencl-works-and-is-available-to-check-out/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/10/18/brahma-opencl-works-and-is-available-to-check-out/"  data-text="Brahma.OpenCL works and is available to check out!" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/10/18/brahma-opencl-works-and-is-available-to-check-out/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Ok, I finally got around to cleaning up the Brahma code (just a little, mind you – there’s loads more to do!) and checking it in! Yes, that means you can try it out now! Because there are no releases, you’re going to have to check out the code with the instructions from <a href="http://sourceforge.net/projects/brahma-fx/develop">here</a>. The source contains a few samples I showed off at the <a href="http://www.twincitiescodecamp.com/TCCC/Default.aspx">Twin Cities Code Camp</a> last weekend, so that’s the place to start poking around. I would love to see questions, suggestions and offers for help with samples <img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://www.ananthonline.net/wp-content/uploads/2010/10/wlEmoticonsmile.png" />.</p>
<p>&#160;</p>
<p>I’m hoping to be able to put in more work on Brahma in a week or so, so stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/10/18/brahma-opencl-works-and-is-available-to-check-out/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>New Brahma syntax/usage</title>
		<link>http://ananthonline.net/2010/09/29/new-brahma-syntaxusage/</link>
		<comments>http://ananthonline.net/2010/09/29/new-brahma-syntaxusage/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 05:36:22 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/?p=265</guid>
		<description><![CDATA[ Tweet <p>Earlier versions of Brahma used a LINQ statement exactly like a query. You could “transform” data, but weren’t allowed any control over where it went in the output. You could also just “select” one value, no more and no less. Another limitation was; when operating on two differently sized data-parallel arrays (Phew! That’s [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F09%2F29%2Fnew-brahma-syntaxusage%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/09/29/new-brahma-syntaxusage/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/09/29/new-brahma-syntaxusage/"  data-text="New Brahma syntax/usage" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/09/29/new-brahma-syntaxusage/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Earlier versions of Brahma used a LINQ statement exactly like a query. You could “transform” data, but weren’t allowed any control over where it went in the output. You could also just “select” one value, no more and no less. Another limitation was; when operating on two differently sized data-parallel arrays (Phew! That’s a mouthful!) you had to make a choice about the size of the output, the “kernel” would be called for all elements in the output array. It was also hard to loop, do conditionals and other kinds of logic that are almost indispensable in complex algorithms.</p>
<p>With OpenCL, kernel code has finally become expressive enough to truly perform general purpose computations. Brahma allows you (albeit in a limited fashion due to current language restrictions – of course, if we could write multiline lambdas and the compiler would give me expression trees of those, I wouldn’t have any of these “workarounds”. Oh, well.) to do this:</p>
<pre class="csharp" style="font-family: consolas,; font-size: small;">
<ol>
<li>
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">provider<span style="color: #008000;">.</span><span style="color: #0000ff;">CompileKernel</span><span style="color: #008000;">&lt;</span>Buffer<span style="color: #008000;">&lt;</span>int32<span style="color: #008000;">&gt;</span>, Buffer<span style="color: #008000;">&lt;</span>int32<span style="color: #008000;">&gt;&gt;</span><span style="color: #008000;">(</span><span style="color: #008000;">(</span>d1, d2<span style="color: #008000;">)</span> <span style="color: #008000;">=&gt;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    <span style="color: #0600ff; font-weight: bold;">from</span> x <span style="color: #0600ff; font-weight: bold;">in</span> Loop<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">For</span><span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">=&gt;</span> <span style="color: #ff0000;">0</span>, i <span style="color: #008000;">=&gt;</span> i <span style="color: #008000;">&lt;</span> _width, i <span style="color: #008000;">=&gt;</span> i <span style="color: #008000;">+</span> <span style="color: #ff0000;">1</span><span style="color: #008000;">)</span></div>
</li>
<li>
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    <span style="color: #0600ff; font-weight: bold;">from</span> y <span style="color: #0600ff; font-weight: bold;">in</span> Loop<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">For</span><span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">=&gt;</span> <span style="color: #ff0000;">0</span>, i <span style="color: #008000;">=&gt;</span> i <span style="color: #008000;">&lt;</span> _height, i <span style="color: #008000;">=&gt;</span> i <span style="color: #008000;">+</span> <span style="color: #ff0000;">1</span><span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    let idx <span style="color: #008000;">=</span> y <span style="color: #008000;">*</span> _width <span style="color: #008000;">+</span> x</div>
</li>
<li>
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    <span style="color: #0600ff; font-weight: bold;">select</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a><span style="color: #008000;">[</span><span style="color: #008000;">]</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    <span style="color: #008000;">{</span></div>
</li>
<li>
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">        result1<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span> <span style="color: #008000;">&lt;=</span> <span style="color: #008000;">(</span>d1<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span> <span style="color: #008000;">+</span> d2<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">        result2<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span> <span style="color: #008000;">&lt;=</span> <span style="color: #008000;">(</span>d1<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span> <span style="color: #008000;">-</span> d2<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span><span style="color: #008000;">)</span></div>
</li>
<li>
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    <span style="color: #008000;">}</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
</ol>
</pre>
<p>Note that DataParallelArray&lt;T&gt; is now called Buffer&lt;T&gt; – isn’t that a lot easier? The kernel above is two nested loops that calculate something off two 2D images and write the results to 2 output buffers called result1 and result2. (I know the example doesn’t make sense, it’s just there to show usage!)</p>
<p>The observant among you probably noticed a few things</p>
<ul>
<li>I AM selecting one output item for each inner loop iteration (= _width * _height items) – Well, yes. But I’m writing two results each time (I can write none if I don’t want to).</li>
<li>Why am I comparing result[idx] and (d1[idx]….)? Nope. Brahma overloads the &lt;= operator and in this case you read it as “is assigned”. So in Brahma parlance, you’re saying: result[idx] “is assigned” d1[idx]….</li>
<li>result1 and result2 are NOT lambda parameters. While Brahma will allow you to use only “side-effects”, you can also use other overloads to provide parameters that you assign to. This comes in handy when you want to use different output buffers but compile the query only once.</li>
</ul>
<p>And in that sense, you are also free to pass non-buffer arguments to the kernel (and write to them from one &#8211; depending on your compute device you may have memory restrictions, though). For example, a structure containing control values can now be “passed” in per run!</p>
<p>Here’s one more (idiotic) sample that uses the current thread id instead of running nested loops per kernel launch. Ok, so I’m still thinking about the DeviceMethods name.</p>
<pre class="csharp" style="font-family: consolas,; font-size: small;">
<ol>
<li>
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">provider<span style="color: #008000;">.</span><span style="color: #0000ff;">CompileKernel</span><span style="color: #008000;">&lt;</span>Buffer<span style="color: #008000;">&lt;</span>int32<span style="color: #008000;">&gt;</span>, Buffer<span style="color: #008000;">&lt;</span>int32<span style="color: #008000;">&gt;&gt;</span><span style="color: #008000;">(</span><span style="color: #008000;">(</span>d1, d2<span style="color: #008000;">)</span> <span style="color: #008000;">=&gt;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    <span style="color: #0600ff; font-weight: bold;">from</span> x <span style="color: #0600ff; font-weight: bold;">in</span> DeviceMethods<span style="color: #008000;">.</span><span style="color: #0000ff;">GlobalID</span><span style="color: #008000;">(</span><span style="color: #ff0000;">0</span><span style="color: #008000;">)</span> <span style="font-style: italic; color: #008080;">// ID (and coordinates) of the thread</span></div>
</li>
<li>
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    <span style="color: #0600ff; font-weight: bold;">from</span> y <span style="color: #0600ff; font-weight: bold;">in</span> DeviceMethods<span style="color: #008000;">.</span><span style="color: #0000ff;">GlobalID</span><span style="color: #008000;">(</span><span style="color: #ff0000;">1</span><span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    let idx <span style="color: #008000;">=</span> y <span style="color: #008000;">*</span> _width <span style="color: #008000;">+</span> x</div>
</li>
<li>
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    <span style="color: #0600ff; font-weight: bold;">select</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a><span style="color: #008000;">[</span><span style="color: #008000;">]</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    <span style="color: #008000;">{</span></div>
</li>
<li>
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">        result1<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span> <span style="color: #008000;">&lt;=</span> <span style="color: #008000;">(</span>d1<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span> <span style="color: #008000;">+</span> d2<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">        result2<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span> <span style="color: #008000;">&lt;=</span> <span style="color: #008000;">(</span>d1<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span> <span style="color: #008000;">-</span> d2<span style="color: #008000;">[</span>idx<span style="color: #008000;">]</span><span style="color: #008000;">)</span></div>
</li>
<li>
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">    <span style="color: #008000;">}</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
</ol>
</pre>
<p>I think the new kernel syntax/usage is neat, functional and compact. What do you think? I’m still working on several bits of this design … so this is when you can be heard! Please tell me what you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/09/29/new-brahma-syntaxusage/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>TidePowerd</title>
		<link>http://ananthonline.net/2010/09/21/tidepowerd/</link>
		<comments>http://ananthonline.net/2010/09/21/tidepowerd/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 21:51:26 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/?p=257</guid>
		<description><![CDATA[ Tweet <p>I&#8217;m at the nVidia GPU conference and I just learned of (and met) a company called TidePowerd, who seem to have taken the IL decompilation idea (that Brahma 1.0 was based on) into a commercial product. This, to me is good because</p> It looks like someone thought many-core/GPGPU developer tools for .NET was [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F09%2F21%2Ftidepowerd%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/09/21/tidepowerd/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/09/21/tidepowerd/"  data-text="TidePowerd" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/09/21/tidepowerd/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>I&#8217;m at the nVidia GPU conference and I just learned of (and met) a company called <a title="TidePowerd" href="http://www.tidepowerd.com/" target="_blank">TidePowerd</a>, who seem to have taken the IL decompilation idea (that Brahma 1.0 was based on) into a commercial product. This, to me is good because</p>
<ol>
<li>It looks like someone thought many-core/GPGPU developer tools for .NET was an idea worthy of commercialization (a drum I&#8217;ve been banging for many years now)</li>
<li>It&#8217;s nice to see the seed of the idea that IL can be effectively transformed to SIMD/SIMT type code be realized in a fuller fashion.</li>
</ol>
<p>Personally, I&#8217;d be REALLY interested in seeing what TidePowerd does and how the industry responds to their offerings.</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/09/21/tidepowerd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenCL.Net published!</title>
		<link>http://ananthonline.net/2010/07/20/opencl-net-published/</link>
		<comments>http://ananthonline.net/2010/07/20/opencl-net-published/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 13:20:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[OpenCL]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/blog/general/opencl-net-published</guid>
		<description><![CDATA[ Tweet <p>I just published my version of .NET bindings for OpenCL over on Codeplex last night. Why another, you ask? There’s already so many out there … Cloo, OpenCL.NET from hoopoe and another OpenCL.Net over at Sourceforge (and more?). Well, …</p> Every API out there has an object-oriented version of the API that’s easily [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F07%2F20%2Fopencl-net-published%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/07/20/opencl-net-published/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/07/20/opencl-net-published/"  data-text="OpenCL.Net published!" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/07/20/opencl-net-published/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>I just published my version of <a href="http://openclnet.codeplex.com/">.NET bindings for OpenCL</a> over on Codeplex last night. Why another, you ask? There’s already so many out there … <a href="http://www.opentk.com/project/cloo">Cloo</a>, <a href="http://www.hoopoe-cloud.com/Solutions/OpenCL.NET/Default.aspx">OpenCL.NET from hoopoe</a> and another <a href="http://sourceforge.net/projects/openclnet/">OpenCL.Net over at Sourceforge</a> (and more?). Well, …</p>
<ul>
<li>Every API out there has an object-oriented version of the API that’s easily usable from .NET. Sure, it’s easy … but looks very different from the raw OpenCL API if I wanted to use it, right? There’s reason #1 right there. I wanted a set of .NET bindings that look, feel and act like the C-style API so I (read: the users) could port existing samples or read books/tutorials and understand what’s going on.</li>
<li>Which brings us to our second question: Don’t all of the mentioned bindings also have the C-style API exposed? Sure, they do. But some of them mark the exposed API as unsafe, use of which would force users to mark their own projects as unsafe too. Secondly, every set of bindings I saw had raw translations of the API transliterating &lt;anything&gt;* to IntPtr (and others along those lines) meaning we have to use their OO abstractions to get anything done easily. I wanted something more .NET friendly at the API level, however.</li>
</ul>
<p>So I guess the reason I wrote my own bindings is: I wanted to strike the middle ground between OO + .NET friendly and raw API translation. You can find this over at <a href="http://openclnet.codeplex.com/">Codeplex</a>. The API isn’t complete yet, but some things I’m particularly happy about are:</p>
<ol>
<li>No unsafe code (yet).</li>
<li>Everything is .NET friendly AND you can use it as you would the raw API (overloads).</li>
<li>As little explicit marshaling as possible, in fact all the exposed methods that invoke the extern’d methods in OpenCL.dll are only one call/line.</li>
</ol>
<p>Initially, I started with these bindings for my project <a href="http://brahma.ananthonline.net">Brahma</a>, but decided it was a large enough effort to put up separately. I hope people find it useful alongside the other tools for OpenCL for .NET that are already available. I hope to have the API completed and released soon. Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/07/20/opencl-net-published/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Parsing command line arguments with C# &amp; LINQ</title>
		<link>http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/</link>
		<comments>http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 01:39:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/blog/dotnet/parsing-command-line-arguments-with-c-linq/</guid>
		<description><![CDATA[ Tweet <p>Whenever I sit down to write an application (mostly a console application), I find myself wishing I had some code I could just drop in to parse command line arguments with. A friend of mine has authored the excellent ConsoleFX library, and it&#8217;s really good if you want to do heavy processing, validations [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F07%2F02%2Fparsing-command-line-arguments-with-c-linq%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/"  data-text="Parsing command line arguments with C# &#038; LINQ" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Whenever I sit down to write an application (mostly a console application), I find myself wishing I had some code I could just drop in to parse command line arguments with. A friend of mine has authored the excellent ConsoleFX library, and it&#8217;s really good if you want to do heavy processing, validations and complex command line argument structures with help. Most of the time, however, I don&#8217;t.</p>
<p>So I spent the better part of my evening writing something that I hope I will be able to carry around as a code snippet small enough to use anytime, anywhere in an elegant fashion.</p>
<pre class="csharp" style="background-color: #ffffff; font-family: consolas, monospace; font-size: small;">
<ol>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008080;">#region CommandLine</span></div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #0600ff; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">class</span> CommandLine</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> <span style="color: #0600ff; font-weight: bold;">Switch</span> <span style="font-style: italic; color: #008080;">// Class that encapsulates switch data. Not meant for direct use.</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span> name, Action<span style="color: #008000;">&lt;</span>IEnumerable<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;&gt;</span> handler, <span style="color: #6666cc; font-weight: bold;">string</span> shortForm <span style="color: #008000;">=</span> <span style="color: #0600ff; font-weight: bold;">null</span><span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			Name <span style="color: #008000;">=</span> name<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			Handler <span style="color: #008000;">=</span> handler<span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			ShortForm <span style="color: #008000;">=</span> shortForm<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> Name</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			get<span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			<span style="color: #0600ff; font-weight: bold;">private</span> set<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> ShortForm</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			get<span style="color: #008000;">;</span> <span style="color: #0600ff; font-weight: bold;">private</span> set<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> Action<span style="color: #008000;">&lt;</span>IEnumerable<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;&gt;</span> Handler</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			get<span style="color: #008000;">;</span> <span style="color: #0600ff; font-weight: bold;">private</span> set<span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> InvokeHandler<span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">[</span><span style="color: #008000;">]</span> values<span style="color: #008000;">)</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">{</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			Handler<span style="color: #008000;">(</span>values<span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			<span style="color: #0600ff; font-weight: bold;">return</span> <span style="color: #ff0000;">1</span><span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">}</span></div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="font-style: italic; color: #008080;">// The regex that extracts names and comma-separated values for switches </span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="font-style: italic; color: #008080;">// in the form (&lt;switch&gt;[:value,value,value])+</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">private</span> <span style="color: #0600ff; font-weight: bold;">static</span> <span style="color: #0600ff; font-weight: bold;">readonly</span> Regex _regex <span style="color: #008000;">=</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Regex<span style="color: #008000;">(</span><span style="color: #666666;">@"s*(?&lt;switch&gt;(?&lt;name&gt;w+)(:s*(?&lt;value&gt;w+(s*,s*w+)*))?)"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">Compiled</span> <span style="color: #008000;">|</span> RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">CultureInvariant</span> <span style="color: #008000;">|</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">ExplicitCapture</span> <span style="color: #008000;">|</span> RegexOptions<span style="color: #008000;">.</span><span style="color: #0000ff;">IgnoreCase</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">private</span> <span style="color: #0600ff; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> NameGroup <span style="color: #008000;">=</span> <span style="color: #666666;">"name"</span><span style="color: #008000;">;</span> <span style="font-style: italic; color: #008080;">// Names of capture groups</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">private</span> <span style="color: #0600ff; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">string</span> ValueGroup <span style="color: #008000;">=</span> <span style="color: #666666;">"value"</span><span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #0600ff; font-weight: bold;">public</span> <span style="color: #0600ff; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Process<span style="color: #008000;">(</span><span style="color: #0600ff; font-weight: bold;">this</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">[</span><span style="color: #008000;">]</span> args, Action printUsage, <span style="color: #0600ff; font-weight: bold;">params</span> <span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">[</span><span style="color: #008000;">]</span> switches<span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">{</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// Run through all matches in the concatenated argument list and if any</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// of the switches match, get the values and invoke the handler we were</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// given. We do a Sum() here for 2 reasons; a) To actually run the handlers</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// and b) see if any were invoked at all (each returns 1 if invoked).</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="font-style: italic; color: #008080;">// If none were invoked, we simply invoke the printUsage handler.</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">		<span style="color: #0600ff; font-weight: bold;">if</span> <span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #0600ff; font-weight: bold;">from</span> Match match <span style="color: #0600ff; font-weight: bold;">in</span> _regex<span style="color: #008000;">.</span><span style="color: #0000ff;">Matches</span><span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, args<span style="color: #008000;">)</span><span style="color: #008000;">)</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			 <span style="color: #0600ff; font-weight: bold;">from</span> arg <span style="color: #0600ff; font-weight: bold;">in</span> switches</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			 <span style="color: #0600ff; font-weight: bold;">where</span> match<span style="color: #008000;">.</span><span style="color: #0000ff;">Success</span> <span style="color: #008000;">&amp;&amp;</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">				   <span style="color: #008000;">(</span><span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Compare</span><span style="color: #008000;">(</span>match<span style="color: #008000;">.</span><span style="color: #0000ff;">Groups</span><span style="color: #008000;">[</span>NameGroup<span style="color: #008000;">]</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Value</span>, arg<span style="color: #008000;">.</span><span style="color: #0000ff;">Name</span>, <span style="color: #0600ff; font-weight: bold;">true</span><span style="color: #008000;">)</span> <span style="color: #008000;">==</span> <span style="color: #ff0000;">0</span><span style="color: #008000;">)</span> <span style="color: #008000;">||</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">					<span style="color: #008000;">(</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Compare</span><span style="color: #008000;">(</span>match<span style="color: #008000;">.</span><span style="color: #0000ff;">Groups</span><span style="color: #008000;">[</span>NameGroup<span style="color: #008000;">]</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Value</span>, arg<span style="color: #008000;">.</span><span style="color: #0000ff;">ShortForm</span>, <span style="color: #0600ff; font-weight: bold;">true</span><span style="color: #008000;">)</span> <span style="color: #008000;">==</span> <span style="color: #ff0000;">0</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			 <span style="color: #0600ff; font-weight: bold;">select</span> arg<span style="color: #008000;">.</span><span style="color: #0000ff;">InvokeHandler</span><span style="color: #008000;">(</span>match<span style="color: #008000;">.</span><span style="color: #0000ff;">Groups</span><span style="color: #008000;">[</span>ValueGroup<span style="color: #008000;">]</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Value</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Split</span><span style="color: #008000;">(</span><span style="color: #666666;">','</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Sum</span><span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">==</span> <span style="color: #ff0000;">0</span><span style="color: #008000;">)</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">			printUsage<span style="color: #008000;">(</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span> <span style="font-style: italic; color: #008080;">// We didn't find any switches</span></div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">	<span style="color: #008000;">}</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;"><span style="color: #008080;">#endregion</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
</ol>
</pre>
<p>All of the magic happens inside the Process method, where the query tries to match the arguments against the ones we want to check for. The .Sum() aggregate method does two things.</p>
<ol>
<li>It enumerates the elements of the IQueryable, actually calling the handlers in the process. Nothing happens till then!</li>
<li>Each of the InvokeHandler calls returns 1, so the result of the .Sum() is 0 if there were no matches (which is when we call the supplied printUsage handler).</li>
</ol>
<p>Neat, huh? Using it is even simpler!</p>
<pre class="csharp" style="background-color: #ffffff; font-family: consolas, monospace; font-size: x-small;">
<ol>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">            args<span style="color: #008000;">.</span><span style="color: #0000ff;">Process</span><span style="color: #008000;">(</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <span style="color: #008000;">(</span><span style="color: #008000;">)</span> <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"Usage is switch0:value switch:value switch2"</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CommandLine<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch0"</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                    val <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch 0 with value {0}"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                        <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, val<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CommandLine<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch1"</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                    val <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch 1 with value {0}"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                        <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, val<span style="color: #008000;">)</span><span style="color: #008000;">)</span>, <span style="color: #666666;">"s1"</span><span style="color: #008000;">)</span>,</div>
</li>
<li style="background-color: #f4f4f4;"></li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CommandLine<span style="color: #008000;">.</span><span style="color: #0600ff; font-weight: bold;">Switch</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch2"</span>,</div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                    val <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000ff;">WriteLine</span><span style="color: #008000;">(</span><span style="color: #666666;">"switch 2 with value {0}"</span>,</div>
</li>
<li style="font-color: #aaaaaa;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">                        <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000ff;">Join</span><span style="color: #008000;">(</span><span style="color: #666666;">" "</span>, val<span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">)</span><span style="color: #008000;">;</span></div>
</li>
<li style="background-color: #f4f4f4;">
<div style="margin: 0px; font: 1em/1.2em monospace; background: none transparent scroll repeat 0% 0%; vertical-align: top; padding: 0px;">        <span style="color: #008000;">}</span></div>
</li>
<li style="font-color: #aaaaaa;"></li>
</ol>
</pre>
<p>Any handlers you provide will be called for each switch or it&#8217;s shortform(if found, of course). Now get started writing those fantastic console applications.</p>
<p>Obligatory disclaimer and <a href="http://sam.zoy.org/wtfpl/">License</a>: The code above is for you to do whatever you want to. Even if it blows you up (like <a href="http://www.youtube.com/watch?v=OKTlkG5CdF4&amp;feature=related">Dr. Manhattan blows Rorschach up</a>), don&#8217;t come back from the dead to haunt me. I would, however appreciate it if you kept the comment attributing that code to me.</p>
<div id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:3e53c8a2-e654-480f-ae95-ad957ca154c8" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<div id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:3e53c8a2-e654-480f-ae95-ad957ca154c8" class="wlWriterSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<p>Double Edit: Modified the Regex so it can accept quoted parameters (even filenames).</p>
<div id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:681f230e-9598-44dd-bdb7-aca9b5c7fcb1" class="wlWriterSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<p>Download the code snippet from the <a href="http://www.ananthonline.net/code-snippets" target="_self">code snippets page</a>.</p>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/07/02/parsing-command-line-arguments-with-c-linq/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Website upgrade</title>
		<link>http://ananthonline.net/2010/06/08/website-upgrade/</link>
		<comments>http://ananthonline.net/2010/06/08/website-upgrade/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 13:07:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.ananthonline.net/blog/?p=50</guid>
		<description><![CDATA[ Tweet <p>I recently had to upgrade the WordPress installation on my website, and decided to do a bunch of housecleaning besides. </p> <p>I&#8217;d been looking for a good content management system that allows me to keep a blog, wiki(s) and forums (across different subdomains &#8211; brahma, blog, etc.) and I couldn&#8217;t find anything easy [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F06%2F08%2Fwebsite-upgrade%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/06/08/website-upgrade/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/06/08/website-upgrade/"  data-text="Website upgrade" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/06/08/website-upgrade/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>I recently had to upgrade the WordPress installation on my website, and decided to do a bunch of housecleaning besides.    </p>
<p>I&#8217;d been looking for a good content management system that allows me to keep a blog, wiki(s) and forums (across different subdomains &#8211; brahma, blog, etc.) and I couldn&#8217;t find anything easy to use and powerful at the same time. I&#8217;m a big stickler for themes and I hate having to manage and re-theme different applications to look the same. </p>
<p>After a lot of searching, I&#8217;ve decided to use WordPress as my CMS and am going to be trying out these wonderful plugins:</p>
<ol>
<li><a href="http://wp-wiki.org/" target="_blank">WordPress Wiki</a> &#8211; This looks interesting, although I have no idea how I&#8217;m going to integrate this into a subdomain.domain.net/wiki URL structure. If anyone has any ideas, I&#8217;ll be glad to hear them. </li>
<li><a href="http://simple-press.com/" target="_blank">Simple Press</a> &#8211; This is the other thing I wanted on my website, and I&#8217;m quite happy WordPress has a plugin for it. </li>
</ol>
<p>Unfortunately, to do a lot of this, I might have to shuffle some URLs and pages around. I will do my best to keep the site as functional as possible (perhaps even resorting to the evil redirection trick), but if you can&#8217;t find anything or see a problem with the website, please contact me so I can fix the problem. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/06/08/website-upgrade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ATI Stream SDK on non-AMD machines</title>
		<link>http://ananthonline.net/2010/01/18/ati-stream-sdk-on-non-amd-machines/</link>
		<comments>http://ananthonline.net/2010/01/18/ati-stream-sdk-on-non-amd-machines/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 02:15:00 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[OpenCL]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=43</guid>
		<description><![CDATA[ Tweet <p>It seems the ATI stream SDK installer doesn&#8217;t install anything but the OpenCL profiler on machines with no AMD/ATI hardware. Running the MSI&#8217;s from &#8220;C:C:ATISUPPORTstreamsdk_2-0-0_XXXXPackagesApps&#8221; folder seems to install OpenCL (CPU only, of course) support for me.</p> <p>Note: I originally found this solution on geeks3d.com.</p> <p>&#8211; Edit &#8212; ATI/AMD have since fixed this, [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F01%2F18%2Fati-stream-sdk-on-non-amd-machines%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/01/18/ati-stream-sdk-on-non-amd-machines/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/01/18/ati-stream-sdk-on-non-amd-machines/"  data-text="ATI Stream SDK on non-AMD machines" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/01/18/ati-stream-sdk-on-non-amd-machines/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>It seems the ATI stream SDK installer doesn&#8217;t install anything but the OpenCL profiler on machines with no AMD/ATI hardware. Running the MSI&#8217;s from &#8220;C:C:ATISUPPORTstreamsdk_2-0-0_XXXXPackagesApps&#8221; folder seems to install OpenCL (CPU only, of course) support for me.</p>
<p>Note: I originally found this solution on <a href="http://www.geeks3d.com/20091222/gpu-caps-viewer-1-8-1-updated-for-ati-stream-sdk-v2-0-0/comment-page-1/#comment-9142" target="_blank">geeks3d.com</a>.</p>
<p>&#8211; Edit &#8212;<br />
ATI/AMD have since fixed this, and everything installs with the latest version of the <a href="http://developer.amd.com/gpu/atistreamsdk/pages/default.aspx">Stream SDK</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/01/18/ati-stream-sdk-on-non-amd-machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brahma and OpenCL</title>
		<link>http://ananthonline.net/2010/01/12/brahma-and-opencl/</link>
		<comments>http://ananthonline.net/2010/01/12/brahma-and-opencl/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 03:48:37 +0000</pubDate>
		<dc:creator>ananth</dc:creator>
				<category><![CDATA[Brahma]]></category>
		<category><![CDATA[GPGPU]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[OpenCL]]></category>

		<guid isPermaLink="false">http://blog.ananthonline.net/?p=42</guid>
		<description><![CDATA[ Tweet <p>Despite the lack of updates on this site, I have been hard at work on a new provider, Brahma.OpenCL. I am very excited at all the possibilities that OpenCL brings to the table. I will try to summarize some of the new features that OpenCL will bring to Brahma.</p> Different memory pools &#8211; [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fananthonline.net%2F2010%2F01%2F12%2Fbrahma-and-opencl%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://ananthonline.net/2010/01/12/brahma-and-opencl/"></g:plusone>
			</div>
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://ananthonline.net/2010/01/12/brahma-and-opencl/"  data-text="Brahma and OpenCL" data-count="horizontal" data-via="ananthonline">Tweet</a>
			</div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ananthonline.net/2010/01/12/brahma-and-opencl/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Despite the lack of updates on this site, I have been hard at work on a new provider, Brahma.OpenCL. I am very excited at all the possibilities that OpenCL brings to the table. I will try to summarize some of the new features that OpenCL will bring to Brahma.</p>
<ol>
<li><strong>Different memory pools</strong> &#8211; OpenCL supports the idea of host memory, device memory and host-addressable memory. Brahma will allow the creation of DataParallelArrays in these memory pools and will allow host-addressable memory (and host memory) to maintain only one copy of the data. </li>
<li><strong>Asynchronous operations</strong> &#8211; OpenCL supports the idea of asynchronous operations (data-transfers, concurrent kernel execution) and now so does Brahma. Brahma will also allow the user to introduce &#8220;fences&#8221; in any command queue for fork-join parallelism. </li>
<li><strong>Free memory-layout</strong> &#8211; Because memory layouts vary across applications (Morton coding, bricking, overlapped bricks or other index based arbitrary data-structures), DataParallelArrays will now be independent of layout (with a layout manager YOU provide &#8211; or use a stock one). This means Data-ParallelArrays will now have arbitrary dimensionality. </li>
<li><strong>Arbitrary data</strong> &#8211; This is perhaps very exciting. DataParallelArrays can now contain any kind of <a href="http://msdn.microsoft.com/en-us/library/75dwhxf7.aspx">blittable struct</a>. So, if you&#8217;re working with an equation that requires two floats and an int called a, b and factor; you can create a struct with those members and use them in your calculations! </li>
</ol>
<p>And, to whet your appetite; here&#8217;s what Brahma.OpenCL code will look like.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 138.74%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; height: 210px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Create compiled, named query</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">CompiledQuery query = </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    _provider.Compile(<span style="color: #006080">&quot;q1&quot;</span>, (d1, d2) =&gt; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            from val1 <span style="color: #0000ff">in</span> d1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            from val2 <span style="color: #0000ff">in</span> d2</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            select <span style="color: #0000ff">new</span> Coefficients </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            { </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">              a = val1.a + val2.a, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">              b = 0f,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">              factor = a.factor++</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            });</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Create a dataparallel array, and provide a</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// memory layout implementation, and a pool to use</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var d1 = <span style="color: #0000ff">new</span> DataParallelArray&lt;Coefficients&gt;(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    _provider, <span style="color: #0000ff">null</span>, length,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">new</span> LinearMemoryLayout(length), Pool.Shared);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Create a command that takes the array and </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// a GetValues lambda</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// but - don't do anything just yet</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var transferd1 += Command.Transfer(d1, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    x =&gt; <span style="color: #0000ff">new</span> Coefficients</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 a = 0.0, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 b = 1.0, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 factor = 0</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             });</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Ditto for d2 - create ...</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var d2 = <span style="color: #0000ff">new</span> DataParallelArray&lt;Coefficients&gt;(</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    _provider, <span style="color: #0000ff">null</span>, length,</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">new</span> LinearMemoryLayout(length), Pool.Shared);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// ... and create a transfer command</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">var transferd2 += Command.Transfer(d1, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    x =&gt; <span style="color: #0000ff">new</span> Coefficients</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 a = 0.0, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 b = 1.0, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                 factor = 0</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             });</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Queue 0 - add the transfer command</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">_provider.CommandQueues[0] += transferd1;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Queue 1 - add the transfer </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// and wait for transferd1</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">_provider.CommandQueues[1] += </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">new</span>[]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            transferd2, </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            Command.Wait(transferd1)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        };</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Begin running commands on queues 0 and 1</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">ResultSet results = _provider.Run(0, 1);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Access results from the result-set <img src='http://ananthonline.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">foreach</span> (Coefficient coeff <span style="color: #0000ff">in</span> results[<span style="color: #006080">&quot;q1&quot;</span>])</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    ...</pre>
<p><!--CRLF--></div>
</div>
<p>Hope that got you excited . I would love to hear comments and suggestions from everyone!</p>
<p><em>For those of you who have written to me and not received a reply, please write to me again, these past few months have been terribly hectic; settling down in a new job in a new country.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://ananthonline.net/2010/01/12/brahma-and-opencl/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

