<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>mottled memes</title>
	<atom:link href="http://billbrouwer.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://billbrouwer.wordpress.com</link>
	<description>misadventures in physics, cyberinfrastructure and life in general</description>
	<lastBuildDate>Thu, 19 Jan 2012 13:05:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='billbrouwer.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>mottled memes</title>
		<link>http://billbrouwer.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://billbrouwer.wordpress.com/osd.xml" title="mottled memes" />
	<atom:link rel='hub' href='http://billbrouwer.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Death by Tensor</title>
		<link>http://billbrouwer.wordpress.com/2012/01/18/death-by-tensor/</link>
		<comments>http://billbrouwer.wordpress.com/2012/01/18/death-by-tensor/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 21:44:53 +0000</pubDate>
		<dc:creator>bbrouwer</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[High Performance Computing]]></category>
		<category><![CDATA[numerical methods]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[block matrix]]></category>
		<category><![CDATA[Cartesian tensors]]></category>
		<category><![CDATA[octave]]></category>
		<category><![CDATA[shape memory alloy]]></category>

		<guid isPermaLink="false">http://billbrouwer.wordpress.com/?p=845</guid>
		<description><![CDATA[Of all the objects in Math that might kill a man, tensors have surely been lethal on more than one occasion. Sure, it&#8217;s not a traditional way to check out, but I&#8217;ll bet it happens. I don&#8217;t see a whole lot out there in the gnu space for manipulating tensors; there&#8217;s something for matlab from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=845&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Of all the objects in Math that might kill a man, tensors have surely been lethal on more than one occasion. Sure, it&#8217;s not a traditional way to check out, but I&#8217;ll bet it happens.</p>
<p>I don&#8217;t see a whole lot out there in the gnu space for manipulating tensors; there&#8217;s something for matlab from sandia with a scary looking license. When I get to production C/C++, there is a beautiful package put together by Landry at Utah, using expression templates. However nothing seemed to fit, when initially coding up <a href="http://onlinelibrary.wiley.com/doi/10.1002/nme.2964/abstract">Arghavani et al.,</a> integration algorithm for shape memory alloys, in octave. Most of the terse theory was relatively easy to code up, I used a block matrix representation for the Cartesian tensors, ostensibly of rank 2,4 and 6 eg., indices for rank 6 look like :</p>
<p><a href="http://billbrouwer.files.wordpress.com/2012/01/rank6.png"><img class="aligncenter size-medium wp-image-849" title="rank6" src="http://billbrouwer.files.wordpress.com/2012/01/rank6.png?w=298&#038;h=300" alt="" width="298" height="300" /></a></p>
<p>which in theory has good cache/locality properties; indices are increasingly fast (ie., smaller period) as one moves to smaller tiles. There are well known approaches for contraction involving indices occurring twice in expressions ie., using traditional matrix multiplication. I found it easiest to work in the space of the resultant, eg., rank2 -&gt; rank4 before an operation involving a rank4 object etc. All was going well till I came to equation A9, specifically :</p>
<p><a href="http://billbrouwer.files.wordpress.com/2012/01/eq.png"><img class="aligncenter size-medium wp-image-856" title="eq" src="http://billbrouwer.files.wordpress.com/2012/01/eq.png?w=300" alt="" height="40" /></a></p>
<p>which, as you can see if you squint hard enough dear reader, involves contraction over multiple variables, and worse, concerns more than two elements. After my eyes quit bleeding, I resolved to stick with the block matrix approach; loops are far too slow when scripting, regardless of representation. I introduced a third dimension for summation, and moved tiles around to suit the contraction at a given step. I used a number of temporary variables for ease of reading the code, a misnomer if ever I saw/wrote one. Anyhoo, the result overall was code which runs ~ 20 times faster than loops, and written in terms of higher level objects, making the task of ultimately writing C++ much easier. IN theory.</p>
<pre style="border:thin solid black;overflow:auto;display:block;white-space:pre;margin:1em;padding:5px;">a = rand(3,3);
d = rand(3,3);
b = kron(eye(3,3),rand(3,3));
c = kron(eye(3,3),rand(3,3));
f = eye(3,3);

bb = rand(3,3,3,3);
cc = rand(3,3,3,3);

%brief ndim test
tic

%contract m
for i=1:3
   for n=1:3
       for r=1:3
            for s=1:3
                for p=1:3
                    for q=1:3
                        first(i,n,r,s,p,q) = a(i,1) * bb(1,n,p,q) * cc(r,1,p,q) * d(1,s) + \
                            a(i,2) * bb(2,n,p,q) * cc(r,2,p,q) * d(2,s) + \
                            a(i,3) * bb(3,n,p,q) * cc(r,3,p,q) * d(3,s);

                    end
                end
            end
        end
    end
end

%contract n
for i=1:3
    for j=1:3
        for r=1:3
            for s=1:3
                for p=1:3
                    for q=1:3
                        second(i,j,r,s,p,q) = a(1,j) * first(i,1,r,s,p,q) + \
                            a(2,j) * first(i,2,r,s,p,q) + \
                            a(3,j) * first(i,3,r,s,p,q);
                    end
                end
            end
        end
    end
end

disp(['time brief ndim : ',num2str(toc)]);

%block matrix/loops test

tic
testa=zeros(27,27);
%contract m
for i=1:3
    for n=1:3
        for r=1:3
            for s=1:3
                for p=1:3
                    for q=1:3
                        testa((i-1)*3*3+(r-1)*3+p,(n-1)*3*3+(s-1)*3+q) = \
                            a(i,1) * b((1-1)*3+p,(n-1)*3+q) * c((r-1)*3+p,(1-1)*3+q) * d(1,s) + \
                            a(i,2) * b((2-1)*3+p,(n-1)*3+q) * c((r-1)*3+p,(2-1)*3+q) * d(2,s) + \
                            a(i,3) * b((3-1)*3+p,(n-1)*3+q) * c((r-1)*3+p,(3-1)*3+q) * d(3,s);
                    end
                end
            end
        end
    end
end
%contract n
for i=1:3
    for j=1:3
        for r=1:3
            for s=1:3
                for p=1:3
                    for q=1:3
                        testb((i-1)*3*3+(r-1)*3+p,(j-1)*3*3+(s-1)*3+q) = \
                            a(1,j) * testa((i-1)*3*3+(r-1)*3+p,(1-1)*3*3+(s-1)*3+q) + \
                            a(2,j) * testa((i-1)*3*3+(r-1)*3+p,(2-1)*3*3+(s-1)*3+q) + \
                            a(3,j) * testa((i-1)*3*3+(r-1)*3+p,(3-1)*3*3+(s-1)*3+q);
                    end    
                end
            end
        end
    end
end
%contract (formerly) r; new index p w/ 'a' row index
for i=1:3
    for j=1:3
        for s=1:3
            for p=1:3
                for r=1:3
                    for q=1:3
                        testc((i-1)*3*3+(p-1)*3+r,(j-1)*3*3+(s-1)*3+q) = \
                            a(p,1) * testb((i-1)*3*3+(1-1)*3+r,(j-1)*3*3+(s-1)*3+q) + \
                            a(p,2) * testb((i-1)*3*3+(2-1)*3+r,(j-1)*3*3+(s-1)*3+q) + \
                            a(p,3) * testb((i-1)*3*3+(3-1)*3+r,(j-1)*3*3+(s-1)*3+q);

                    end
                end
            end    
        end
    end
end

%contract (formerly) s; new index q w/ 'a' column index
for i=1:3
    for j=1:3
        for s=1:3
            for p=1:3
                for r=1:3
                    for q=1:3
                        testd((i-1)*3*3+(p-1)*3+r,(j-1)*3*3+(q-1)*3+s) = \
                            a(1,q) * testc((i-1)*3*3+(p-1)*3+r,(j-1)*3*3+(1-1)*3+s) + \
                            a(2,q) * testc((i-1)*3*3+(p-1)*3+r,(j-1)*3*3+(2-1)*3+s) + \
                            a(3,q) * testc((i-1)*3*3+(p-1)*3+r,(j-1)*3*3+(3-1)*3+s);

                    end
                end
            end    
        end
    end
end

%create bit in brackets
temp = a*d - (1/3).* f.* sum(sum(a.*d));

%distribute
for i=1:3
    for j=1:3
        for s=1:3
            for p=1:3
                for r=1:3
                    for q=1:3
                        teste((i-1)*3*3+(s-1)*3+r,(j-1)*3*3+(p-1)*3+q) = \
                            testd((i-1)*3*3+(s-1)*3+r,(j-1)*3*3+(p-1)*3+q) * temp(r,q);

                    end
                end
            end    
        end
    end
end

testf=zeros(3,27);

%contract p
for i=1:3
    for j=1:3
        for s=1:3
            for p=1:3
                for r=1:3
                    for q=1:3
                        testf(i,(j-1)*3*3+(s-1)*3+p) += \
                            teste((i-1)*3*3+(r-1)*3+q,(j-1)*3*3+(s-1)*3+p);

                    end
                end
            end    
        end
    end
end

testg=zeros(3,3);
%contract q
for i=1:3
    for j=1:3
        for r=1:3
            for q=1:3
                testg(i,j) += \
                    testf(i,(j-1)*3*3+(r-1)*3+q);

            end    
        end
    end
end

disp(['time separate loops :',num2str(toc)]);

tic

% expand 2nd  rank tensor U_im
%put m tiles in 3rd d
%i index has period 27 w/ matrix row index

foo(:,:,1)=kron(a(:,1),ones(9,27));
foo(:,:,2)=kron(a(:,2),ones(9,27));
foo(:,:,3)=kron(a(:,3),ones(9,27)); 

% expand 4th rank tensor G_mnpq
%put m tiles in 3rd d
%n index has period 27 w/ matrix column index
%p index has period 3 w/ block matrix row index
%q index has period 3 w/ block matrix column index

foo2(:,:,1)=[repmat(b(1:3,1:3),9,3), repmat(b(1:3,4:6),9,3), repmat(b(1:3,7:9),9,3)];
foo2(:,:,2)=[repmat(b(4:6,1:3),9,3), repmat(b(4:6,4:6),9,3), repmat(b(4:6,7:9),9,3)];
foo2(:,:,3)=[repmat(b(7:9,1:3),9,3), repmat(b(7:9,4:6),9,3), repmat(b(7:9,7:9),9,3)]; 

%expand 4th rank tensor Z_rmpq
%put m tiles in 3rd d
%r index has period 9 w/ block matrix row index
%p index has period 3 w/ block matrix row index
%q index has period 3 w/ block matrix column index

foo3(:,:,1)=repmat([repmat(c(1:3,1:3),1,9); repmat(c(4:6,1:3),1,9); repmat(c(7:9,1:3),1,9)],3,1);
foo3(:,:,2)=repmat([repmat(c(1:3,4:6),1,9); repmat(c(4:6,4:6),1,9); repmat(c(7:9,4:6),1,9)],3,1);
foo3(:,:,3)=repmat([repmat(c(1:3,7:9),1,9); repmat(c(4:6,7:9),1,9); repmat(c(7:9,7:9),1,9)],3,1); 

%expand 2nd rank tensor C_ms
%put m tiles in 3rd d
%s index has period 3 w/ block matrix column index

foo4(:,:,1)=repmat(kron(d(1,:),ones(27,3)),1,3);
foo4(:,:,2)=repmat(kron(d(2,:),ones(27,3)),1,3);
foo4(:,:,3)=repmat(kron(d(3,:),ones(27,3)),1,3);

%CONTRACT m; U_im * G_mnpq * Z_rmpq * C_ms -&gt;  F_inrspq

F = sum(foo.*foo2.*foo3.*foo4,3);

%clear foo foo2 foo3 foo4

%reshape F_inrspq to suit contraction w/ n
%put n tiles in 3rd d

foo5(:,:,1) = F(:,1:9);
foo5(:,:,2) = F(:,10:18);
foo5(:,:,3) = F(:,19:27); 

%CONTRACT n; U_nj * F_inrspq = G_ijrspq

G = [(foo5(:,:,1).*a(1,1) + foo5(:,:,2).*a(2,1) + foo5(:,:,3).*a(3,1)), \    %j==1 tile
    (foo5(:,:,1).*a(1,2) + foo5(:,:,2).*a(2,2) + foo5(:,:,3).*a(3,2)), \    %j==2 tile
    (foo5(:,:,1).*a(1,3) + foo5(:,:,2).*a(2,3) + foo5(:,:,3).*a(3,3)) ];    %j==3 tile
%reshape G_ijrspq to suit contraction w/ r
%put r tiles in 3rd d; r has period 9 w/ row index

foo6(:,:,1) = G(1:3,:);            %r==1 tiles
foo6(:,:,2) = G(4:6,:);            %r==2 tiles
foo6(:,:,3) = G(7:9,:);            %r==3 tiles
foo6(:,:,4) = G(10:12,:);        %r==1 tiles
foo6(:,:,5) = G(13:15,:);        %r==2 tiles
foo6(:,:,6) = G(16:18,:);        %r==3 tiles
foo6(:,:,7) = G(19:21,:);        %r==1 tiles
foo6(:,:,8) = G(22:24,:);        %r==2 tiles
foo6(:,:,9) = G(25:27,:);        %r==3 tiles

%CONTRACT r; U_pr * G_ijrspq = H_ijpspq

H = [(foo6(:,:,1).*a(1,1) + foo6(:,:,2).*a(1,2) + foo6(:,:,3).*a(1,3)); \        %p==1 tiles
    (foo6(:,:,1).*a(2,1) + foo6(:,:,2).*a(2,2) + foo6(:,:,3).*a(2,3)); \        %p==2 tiles
    (foo6(:,:,1).*a(3,1) + foo6(:,:,2).*a(3,2) + foo6(:,:,3).*a(3,3)); \        %p==3 tiles
    (foo6(:,:,4).*a(1,1) + foo6(:,:,5).*a(1,2) + foo6(:,:,6).*a(1,3)); \        %p==1 tiles
    (foo6(:,:,4).*a(2,1) + foo6(:,:,5).*a(2,2) + foo6(:,:,6).*a(2,3)); \        %p==2 tiles
    (foo6(:,:,4).*a(3,1) + foo6(:,:,5).*a(3,2) + foo6(:,:,6).*a(3,3)); \        %p==3 tiles
    (foo6(:,:,7).*a(1,1) + foo6(:,:,8).*a(1,2) + foo6(:,:,9).*a(1,3)); \        %p==1 tiles
    (foo6(:,:,7).*a(2,1) + foo6(:,:,8).*a(2,2) + foo6(:,:,9).*a(2,3)); \        %p==2 tiles
    (foo6(:,:,7).*a(3,1) + foo6(:,:,8).*a(3,2) + foo6(:,:,9).*a(3,3))]; \        %p==3 tiles

%reshape H_ijpspq to suit contraction w/ s
%put s tiles in 3rd d; s has period 9 w/ row index

foo7(:,:,1) = H(:,1:3);            %s==1 tiles
foo7(:,:,2) = H(:,4:6);            %s==2 tiles
foo7(:,:,3) = H(:,7:9);            %s==3 tiles
foo7(:,:,4) = H(:,10:12);        %s==1 tiles
foo7(:,:,5) = H(:,13:15);        %s==2 tiles
foo7(:,:,6) = H(:,16:18);        %s==3 tiles
foo7(:,:,7) = H(:,19:21);        %s==1 tiles
foo7(:,:,8) = H(:,22:24);        %s==2 tiles
foo7(:,:,9) = H(:,25:27);        %s==3 tiles

%CONTRACT s; U_sq * H_ijpspq = I_ijpqpq

I = [(foo7(:,:,1).*a(1,1) + foo7(:,:,2).*a(2,1) + foo7(:,:,3).*a(3,1)), \        %q==1 tiles
    (foo7(:,:,1).*a(1,2) + foo7(:,:,2).*a(2,2) + foo7(:,:,3).*a(3,2)), \        %q==2 tiles
    (foo7(:,:,1).*a(1,3) + foo7(:,:,2).*a(2,3) + foo7(:,:,3).*a(3,3)), \        %q==3 tiles
    (foo7(:,:,4).*a(1,1) + foo7(:,:,5).*a(2,1) + foo7(:,:,6).*a(3,1)), \        %q==1 tiles
    (foo7(:,:,4).*a(1,2) + foo7(:,:,5).*a(2,2) + foo7(:,:,6).*a(3,2)), \        %q==2 tiles
    (foo7(:,:,4).*a(1,3) + foo7(:,:,5).*a(2,3) + foo7(:,:,6).*a(3,3)), \        %q==3 tiles
    (foo7(:,:,7).*a(1,1) + foo7(:,:,8).*a(2,1) + foo7(:,:,9).*a(3,1)), \        %q==1 tiles
    (foo7(:,:,7).*a(1,2) + foo7(:,:,8).*a(2,2) + foo7(:,:,9).*a(3,2)), \        %q==2 tiles
    (foo7(:,:,7).*a(1,3) + foo7(:,:,8).*a(2,3) + foo7(:,:,9).*a(3,3))]; \        %q==3 tiles

%CONTRACT p; I_ijpqpq = J_ijqq
%CONTRACT q; J_ijqq = output_ij

foo8 = kron(ones(9,9),temp).*I;
J = [sum(foo8(1:9,:)); sum(foo8(10:18,:)); sum(foo8(19:27,:))];

output = [sum(J(:,1:9),2), sum(J(:,10:18),2), sum(J(:,19:27),2)];

disp(['time vector : ',num2str(toc)]);
disp(['error btwn loops and vector apprch :',num2str(sum(sum(output-testg)))]);</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/billbrouwer.wordpress.com/845/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/billbrouwer.wordpress.com/845/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/billbrouwer.wordpress.com/845/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/billbrouwer.wordpress.com/845/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/billbrouwer.wordpress.com/845/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/billbrouwer.wordpress.com/845/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/billbrouwer.wordpress.com/845/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/billbrouwer.wordpress.com/845/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/billbrouwer.wordpress.com/845/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/billbrouwer.wordpress.com/845/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/billbrouwer.wordpress.com/845/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/billbrouwer.wordpress.com/845/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/billbrouwer.wordpress.com/845/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/billbrouwer.wordpress.com/845/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=845&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://billbrouwer.wordpress.com/2012/01/18/death-by-tensor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/617e9a1e9e7eb3749261023f232e085b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbrouwer</media:title>
		</media:content>

		<media:content url="http://billbrouwer.files.wordpress.com/2012/01/rank6.png?w=298" medium="image">
			<media:title type="html">rank6</media:title>
		</media:content>

		<media:content url="http://billbrouwer.files.wordpress.com/2012/01/eq.png?w=300" medium="image">
			<media:title type="html">eq</media:title>
		</media:content>
	</item>
		<item>
		<title>HPC Essentials III</title>
		<link>http://billbrouwer.wordpress.com/2011/12/27/hpc-essentials-iii/</link>
		<comments>http://billbrouwer.wordpress.com/2011/12/27/hpc-essentials-iii/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 20:57:52 +0000</pubDate>
		<dc:creator>bbrouwer</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[High Performance Computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Amdahls law]]></category>
		<category><![CDATA[IPC]]></category>
		<category><![CDATA[Message Passing Interface]]></category>
		<category><![CDATA[MPI]]></category>
		<category><![CDATA[procfs]]></category>

		<guid isPermaLink="false">http://billbrouwer.wordpress.com/?p=840</guid>
		<description><![CDATA[Third lecture on Message Passing Interface, procfs, Amdahl&#8217;s law, inter-process communication and more<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=840&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href='http://billbrouwer.files.wordpress.com/2011/12/parallel_lecturesc.pdf'>Third lecture</a> on Message Passing Interface, procfs, Amdahl&#8217;s law, inter-process communication and more</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/billbrouwer.wordpress.com/840/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/billbrouwer.wordpress.com/840/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/billbrouwer.wordpress.com/840/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/billbrouwer.wordpress.com/840/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/billbrouwer.wordpress.com/840/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/billbrouwer.wordpress.com/840/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/billbrouwer.wordpress.com/840/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/billbrouwer.wordpress.com/840/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/billbrouwer.wordpress.com/840/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/billbrouwer.wordpress.com/840/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/billbrouwer.wordpress.com/840/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/billbrouwer.wordpress.com/840/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/billbrouwer.wordpress.com/840/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/billbrouwer.wordpress.com/840/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=840&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://billbrouwer.wordpress.com/2011/12/27/hpc-essentials-iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/617e9a1e9e7eb3749261023f232e085b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbrouwer</media:title>
		</media:content>
	</item>
		<item>
		<title>band of skulls</title>
		<link>http://billbrouwer.wordpress.com/2011/12/15/band-of-skulls/</link>
		<comments>http://billbrouwer.wordpress.com/2011/12/15/band-of-skulls/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 18:44:33 +0000</pubDate>
		<dc:creator>bbrouwer</dc:creator>
				<category><![CDATA[art]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[baby darling doll face honey]]></category>
		<category><![CDATA[band of skulls]]></category>

		<guid isPermaLink="false">http://billbrouwer.wordpress.com/?p=836</guid>
		<description><![CDATA[sheer genius, I can&#8217;t believe I waited this long to pick up the album !?!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=836&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>sheer genius, I can&#8217;t believe I waited this long to pick up the album !?!<br />
<img alt="" src="http://upload.wikimedia.org/wikipedia/en/f/f8/Band-of-skulls-i-know-what-i-am.jpg" title="bos" class="alignnone" width="300" height="300" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/billbrouwer.wordpress.com/836/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/billbrouwer.wordpress.com/836/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/billbrouwer.wordpress.com/836/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/billbrouwer.wordpress.com/836/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/billbrouwer.wordpress.com/836/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/billbrouwer.wordpress.com/836/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/billbrouwer.wordpress.com/836/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/billbrouwer.wordpress.com/836/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/billbrouwer.wordpress.com/836/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/billbrouwer.wordpress.com/836/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/billbrouwer.wordpress.com/836/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/billbrouwer.wordpress.com/836/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/billbrouwer.wordpress.com/836/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/billbrouwer.wordpress.com/836/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=836&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://billbrouwer.wordpress.com/2011/12/15/band-of-skulls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/617e9a1e9e7eb3749261023f232e085b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbrouwer</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/en/f/f8/Band-of-skulls-i-know-what-i-am.jpg" medium="image">
			<media:title type="html">bos</media:title>
		</media:content>
	</item>
		<item>
		<title>Quantum Espresso Quick Start</title>
		<link>http://billbrouwer.wordpress.com/2011/12/01/quantum-espresso-quick-start/</link>
		<comments>http://billbrouwer.wordpress.com/2011/12/01/quantum-espresso-quick-start/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 20:42:03 +0000</pubDate>
		<dc:creator>bbrouwer</dc:creator>
				<category><![CDATA[Ab Initio]]></category>
		<category><![CDATA[High Performance Computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[quantum mechanics]]></category>
		<category><![CDATA[fortran]]></category>
		<category><![CDATA[hpc]]></category>
		<category><![CDATA[quantum espresso]]></category>

		<guid isPermaLink="false">http://billbrouwer.wordpress.com/?p=833</guid>
		<description><![CDATA[A brief guide for the clusters at PSU, just enough to make you dangerous<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=833&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href='http://billbrouwer.files.wordpress.com/2011/12/qe-doc.pdf'>A brief guide</a> for the clusters at PSU, just enough to make you dangerous <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/billbrouwer.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/billbrouwer.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/billbrouwer.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/billbrouwer.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/billbrouwer.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/billbrouwer.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/billbrouwer.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/billbrouwer.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/billbrouwer.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/billbrouwer.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/billbrouwer.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/billbrouwer.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/billbrouwer.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/billbrouwer.wordpress.com/833/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=833&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://billbrouwer.wordpress.com/2011/12/01/quantum-espresso-quick-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/617e9a1e9e7eb3749261023f232e085b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbrouwer</media:title>
		</media:content>
	</item>
		<item>
		<title>HPC Essentials I &amp; II</title>
		<link>http://billbrouwer.wordpress.com/2011/11/30/hpc-essentials-i-ii/</link>
		<comments>http://billbrouwer.wordpress.com/2011/11/30/hpc-essentials-i-ii/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 02:39:03 +0000</pubDate>
		<dc:creator>bbrouwer</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[High Performance Computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[affinity]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[intel]]></category>
		<category><![CDATA[OpenMP]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[pthreads]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://billbrouwer.wordpress.com/?p=826</guid>
		<description><![CDATA[First two lectures from the short course at PSU; UNIX/C overview, performance, POSIX threads, OpenMP, Bash scripting, affinity, architecture<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=826&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href='http://billbrouwer.files.wordpress.com/2011/11/parallel_lectures.pdf'>First two lectures</a> from the short course at PSU; UNIX/C overview, performance, POSIX threads, OpenMP, Bash scripting, affinity, architecture</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/billbrouwer.wordpress.com/826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/billbrouwer.wordpress.com/826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/billbrouwer.wordpress.com/826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/billbrouwer.wordpress.com/826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/billbrouwer.wordpress.com/826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/billbrouwer.wordpress.com/826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/billbrouwer.wordpress.com/826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/billbrouwer.wordpress.com/826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/billbrouwer.wordpress.com/826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/billbrouwer.wordpress.com/826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/billbrouwer.wordpress.com/826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/billbrouwer.wordpress.com/826/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/billbrouwer.wordpress.com/826/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/billbrouwer.wordpress.com/826/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=826&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://billbrouwer.wordpress.com/2011/11/30/hpc-essentials-i-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/617e9a1e9e7eb3749261023f232e085b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbrouwer</media:title>
		</media:content>
	</item>
		<item>
		<title>tidy profile data</title>
		<link>http://billbrouwer.wordpress.com/2011/08/26/tidy-profile-data/</link>
		<comments>http://billbrouwer.wordpress.com/2011/08/26/tidy-profile-data/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 01:43:16 +0000</pubDate>
		<dc:creator>bbrouwer</dc:creator>
				<category><![CDATA[Ab Initio]]></category>
		<category><![CDATA[academia]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[back of the envelope]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[octave]]></category>
		<category><![CDATA[profile]]></category>
		<category><![CDATA[quantum espresso]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://billbrouwer.wordpress.com/?p=800</guid>
		<description><![CDATA[here&#8217;s a bash/octave script for tidying up the aforementioned profiling output. The script pulls relevant meta data, collecting time and frequency for same call(s) and producing a neat, sorted *csv which can be used for generating nice graphs, here again an example from the lovely quantum espresso #!/bin/bash #cleanup and sort profile data gawk '($1~"meta"){print [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=800&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>here&#8217;s a bash/octave script for tidying up the aforementioned profiling output. The script pulls relevant meta data, collecting time and frequency for same call(s) and producing a neat, sorted *csv which can be used for generating nice graphs, here again an example from the lovely quantum espresso</p>
<hr />
<p><a href="http://billbrouwer.files.wordpress.com/2011/08/prof.png"><img class="aligncenter size-medium wp-image-804" title="prof" src="http://billbrouwer.files.wordpress.com/2011/08/prof.png?w=300&#038;h=187" alt="" width="300" height="187" /></a></p>
<hr />
<pre style="border:thin solid black;overflow:auto;display:block;white-space:pre;margin:1em;padding:5px;"><code>

 #!/bin/bash
 #cleanup and sort profile data
gawk '($1~"meta"){print $0}' | \
sed 's/\ //g' | \
sed 's/meta//g' |\
sed 's/&lt;//g'|\
sed 's/\///g'|\
sed 's/&gt;//g'|\
tee prof_data_raw.txt |\
gawk 'BEGIN{FS=":"}{print NR,",",$1,",",$2$3}' &gt; foo.txt
gawk 'BEGIN{FS=":"}{print $4,",",$2,"#",$3,","}' &lt; prof_data_raw.txt &gt; names.txt 

cat &gt; temp.m &lt;&lt; %end 

load foo.txt; 

% collect the profile data for unique calls
% the call column 3 is a unique cat of call line + file number
[dat ind]=sort(foo(:,3));
 out = foo(ind,:);
%determine total unique call keys (col 3)
uniq = unique(out(:,3));
num = length(uniq); 

%output profile data matrix
profl = zeros(num,4); 

%collect call frequency information
for i=1:num
         ind = find(out(:,3)==uniq(i));
         %call frequency
         profl(i,2)=length(ind);
         %total call time
         profl(i,3)=sum(out(ind,2));
         %average call time
         profl(i,4)=profl(i,3)/profl(i,2);
         %line number
         ln = out(ind,1);
         profl(i,1) = ln(1);
end 

%sort by total time
[dat ind]=sort(profl(:,3));
out = profl(ind,:);
out=flipud(out);
fid=fopen('names.txt');
[a b]=fscanf(fid,'%s');
str = strsplit(a,",");
fclose(fid);
fid = fopen('profile_output.csv','w');  
fprintf(fid,"call, hash, total time (ms), average time (ms), frequency\n"); 

for i=1:num
         index = out(i,1);
         fprintf(fid,"%s,%s,%f,%f,%f\n",str{2*index-1},str{2*index},out(i,3),out(i,4),out(i,2));
end      

fclose(fid);
%end 

octave --silent --eval temp 

#rm temp.m prof_data_raw.txt foo.txt names.txt
exit 

</code></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/billbrouwer.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/billbrouwer.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/billbrouwer.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/billbrouwer.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/billbrouwer.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/billbrouwer.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/billbrouwer.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/billbrouwer.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/billbrouwer.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/billbrouwer.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/billbrouwer.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/billbrouwer.wordpress.com/800/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/billbrouwer.wordpress.com/800/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/billbrouwer.wordpress.com/800/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=800&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://billbrouwer.wordpress.com/2011/08/26/tidy-profile-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/617e9a1e9e7eb3749261023f232e085b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbrouwer</media:title>
		</media:content>

		<media:content url="http://billbrouwer.files.wordpress.com/2011/08/prof.png?w=300" medium="image">
			<media:title type="html">prof</media:title>
		</media:content>
	</item>
		<item>
		<title>warlocks</title>
		<link>http://billbrouwer.wordpress.com/2011/08/26/warlocks/</link>
		<comments>http://billbrouwer.wordpress.com/2011/08/26/warlocks/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 01:12:51 +0000</pubDate>
		<dc:creator>bbrouwer</dc:creator>
				<category><![CDATA[art]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[slip beneath]]></category>
		<category><![CDATA[warlocks]]></category>

		<guid isPermaLink="false">http://billbrouwer.wordpress.com/?p=793</guid>
		<description><![CDATA[magnificent, how does this have less than 1k views after 2 years??<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=793&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>magnificent, how does this have less than 1k views after 2 years??<br />
<span style="text-align:center; display: block;"><a href="http://billbrouwer.wordpress.com/2011/08/26/warlocks/"><img src="http://img.youtube.com/vi/uIifjAzkWMw/2.jpg" alt="" /></a></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/billbrouwer.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/billbrouwer.wordpress.com/793/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/billbrouwer.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/billbrouwer.wordpress.com/793/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/billbrouwer.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/billbrouwer.wordpress.com/793/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/billbrouwer.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/billbrouwer.wordpress.com/793/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/billbrouwer.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/billbrouwer.wordpress.com/793/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/billbrouwer.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/billbrouwer.wordpress.com/793/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/billbrouwer.wordpress.com/793/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/billbrouwer.wordpress.com/793/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=793&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://billbrouwer.wordpress.com/2011/08/26/warlocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/617e9a1e9e7eb3749261023f232e085b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbrouwer</media:title>
		</media:content>
	</item>
		<item>
		<title>xml call tree</title>
		<link>http://billbrouwer.wordpress.com/2011/08/16/xml-call-tree/</link>
		<comments>http://billbrouwer.wordpress.com/2011/08/16/xml-call-tree/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 14:26:07 +0000</pubDate>
		<dc:creator>bbrouwer</dc:creator>
				<category><![CDATA[Ab Initio]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[back of the envelope]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[quantum mechanics]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[fortran]]></category>
		<category><![CDATA[gawk]]></category>
		<category><![CDATA[profile]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://billbrouwer.wordpress.com/?p=781</guid>
		<description><![CDATA[To be sure, there are many great profilers out there; each with different learning curves and costs ranging from free to a kidney. If you face a new distribution or one you would like to develop with, there is no substitute for rolling your own; follow this bash script, rebuild and filter the output and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=781&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To be sure, there are many great profilers out there; each with different learning curves and costs ranging from free to a kidney. If you face a new distribution or one you would like to develop with, there is no substitute for rolling your own; follow this bash script, rebuild and filter the output and you have an xml call tree with times for calls, and pointers to source code and line number. This is applied to the fortran code(s) in quantum espresso, you can readily adapt to your own needs. Caveat: There are a variety of filter steps in the pipeline; taking into account fortran syntax and different programming styles is difficult <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Once you have your stdout filtered to proper xml, you can view in something like eclipse eg,. attached image. Be aware also that you can and will write very large files; I exclude many i/o and related functions, these you can poke with strace or similar anyway.</p>
<hr />
<p><a href="http://billbrouwer.files.wordpress.com/2011/08/screenshot.png"><img class="aligncenter size-medium wp-image-788" title="Screenshot" src="http://billbrouwer.files.wordpress.com/2011/08/screenshot.png?w=300&#038;h=187" alt="" width="300" height="187" /></a></p>
<pre style="border:thin solid black;overflow:auto;display:block;white-space:pre;margin:1em;padding:5px;"><code> #!/bin/bash

#set source and destination paths
PROFILE_DIR_PATH=~/scratch/espresso-PRACE/PW
PROFILE_BAK_PATH=~/scratch/PW_BAK

#set include/exclude strings; these i/o related function calls won't be timed later
EXCLUDE="!(\$0~\"bcast\")&amp;&amp;!(\$0~\"info\")&amp;&amp;!(\$0~\"clock\")&amp;&amp;!(\$0~\"report\")&amp;&amp;!(\$0~\"mp\")&amp;&amp;!(\$0~\"!\")&amp;&amp;!(\$0~\"error\")&amp;&amp;\
!(\$0~\"read\")&amp;&amp;!(\$0~\"write\")&amp;&amp;!(\$0~\"plot\")&amp;&amp;!(\$0~\"delete\")&amp;&amp;!(\$0~\"scan\")&amp;&amp;!(\$0~\"specific\")&amp;&amp;!(\$0~\"print\")&amp;&amp;!(\$0~\"format\")"
INCLUDE="(\$0~\"bcast\")||(\$0~\"info\")||(\$0~\"clock\")||(\$0~\"report\")||(\$0~\"mp\")||(\$0~\"!\")||(\$0~\"error\")||\
(\$0~\"read\")||(\$0~\"write\")||(\$0~\"plot\")||(\$0~\"delete\")||(\$0~\"scan\")||(\$0~\"specific\")||(\$0~\"print\")||(\$0~\"format\")"

#do once
#mkdir  -p $PROF_BAK_PATH
#cp -iu $PROF_DIR_PATH/* $PROF_BAK_PATH

declare -a file_list

#filenames to array
file_list=$(ls -l ${PROFILE_BAK_PATH} | gawk '/f90/ {print $9}')

cnt=1000;

#parse files &amp; pretty up, inserting write statements and timers
for x in $file_list
do
    let "cnt+=1"
    sed 's/\,\&amp;/\,\ \&amp;/g' $PROFILE_BAK_PATH/$x | \
    sed 's/)/)\ /g' | \
    gawk 'BEGIN{IGNORECASE=1; FS="&amp;"} (NF&lt;=1) || ($0~"#") || !($1~"if") || ($0~"!") || '$INCLUDE' {print $0}; \
    (NF&gt;1) &amp;&amp; !($0~"#") &amp;&amp; ($1~"if") &amp;&amp; !($0~"!") &amp;&amp; '$EXCLUDE' {printf("%s ",$1)}' |\
    gawk 'BEGIN{IGNORECASE=1;} /if/ { if (($0~"&amp;") &amp;&amp; !($0~"!") &amp;&amp;!($0~"#") \
    &amp;&amp; !($NF~"&amp;") &amp;&amp; !($0~"error")) {gsub(/&amp;/," ");print} else print $0}; \
    !/if/ {print $0}' |\
    gawk 'BEGIN{IGNORECASE=1; } (($1~"if")||($1~"else")) &amp;&amp; (length($0)&gt;100) \
    {{for (i=1;i&lt;=NF;i++) printf("%s",$i);} printf("\n")} !(($1~"if")||($1~"else")) || (length($0)&lt;=100) {print $0}' |\
    gawk 'BEGIN{IGNORECASE=1; FS="&amp;"} (NF==1) || ($0~"#") || !($0~"call") || '$INCLUDE' {print $0}; \
    (NF&gt;1) &amp;&amp; !($0~"#") &amp;&amp; ($0 ~ "call") &amp;&amp; '$EXCLUDE' {printf("%s ",$1)}' |\
    gawk 'BEGIN{IGNORECASE=1; FS="&amp;"} (NF==1) || ($0~"#") || !($0~"call") || '$INCLUDE' {print $0}; \
    (NF&gt;1) &amp;&amp; !($0~"#") &amp;&amp; ($0 ~ "call") &amp;&amp; '$EXCLUDE' {printf("%s ",$1)}' |\
    gawk 'BEGIN{IGNORECASE=1;} !/call/{print $0}; /call/ {for (i=1; i&lt;=NF; i++) printf("%s",$i); printf("\n")}' | \
    sed 's/call/\ call\ /g' | \
    sed 's/CALL/\ call\ /g' |\
    sed 's/(/\ (/g' | \
    gawk 'BEGIN{IGNORECASE=1; ch=1;} !/call/ || '$INCLUDE' {print $0}; \
    /call/ &amp;&amp; '$EXCLUDE' {pos=pos+1; print " call date_and_time(values=time_array_0) "; \
    for (i=1; i&lt;=NF; i++) {if ($i=="call") ch=i+1;} ;\
    print " start_time = time_array_0(6)*60 + time_array_0(7) + 0.001*time_array_0(8) "; \
    print " write(*,*)\" &lt;",$ch,"&gt;\" "; print $0; \
    print " call date_and_time(values=time_array_1) "; \
    print " finish_time=time_array_1(6)*60 + time_array_1(7) + 0.001*time_array_1(8) "; \
    print " write(*,*)\" &lt;meta&gt; \",1000*(finish_time-start_time),\" : ",NR," : ",'$cnt'," : ",$ch," &lt;/meta&gt;\" " ;\
    print " write(*,*)\" &lt;source&gt; ~/espresso-PRACE/PW/'$x' &lt;/source&gt; \" " ;  \
    print " write(*,*)\"&lt;/",$ch,"&gt;\" " ; }' | \
    gawk 'BEGIN{IGNORECASE=1; } {print $0;} /IMPLICIT NONE/{ print "INTEGER :: time_array_0(8), time_array_1(8)"; \
    print "REAL :: start_time, finish_time"; }' |\
    gawk 'BEGIN{FS=","} ($0~"call" &amp;&amp; (NF &lt;=5)) || ($0 ~ "!") || !/call/{print $0} \
    $0~"call" &amp;&amp; (NF&gt;5) &amp;&amp; !($0 ~ "!") {print $1,",",$2,",",$3,",",$4,",&amp;"; for (i=5;i&lt;NF;i++) \
    printf("%s,",$i); printf("%s \n",$NF)}' &gt; $PROFILE_DIR_PATH/$x
done

#copy in hard cases; don't bother
cp $PROFILE_BAK_PATH/input.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/symme.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/g_psi.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/pw2blip.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/stop_run.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/vcsmd.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/dynamics_module.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/paw_init.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/compute_becsum.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/h_epsi_her_*.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/wannier_*.f90 $PROFILE_DIR_PATH
cp $PROFILE_BAK_PATH/wfcinit.f90 $PROFILE_DIR_PATH

exit

</code></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/billbrouwer.wordpress.com/781/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/billbrouwer.wordpress.com/781/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/billbrouwer.wordpress.com/781/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/billbrouwer.wordpress.com/781/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/billbrouwer.wordpress.com/781/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/billbrouwer.wordpress.com/781/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/billbrouwer.wordpress.com/781/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/billbrouwer.wordpress.com/781/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/billbrouwer.wordpress.com/781/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/billbrouwer.wordpress.com/781/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/billbrouwer.wordpress.com/781/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/billbrouwer.wordpress.com/781/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/billbrouwer.wordpress.com/781/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/billbrouwer.wordpress.com/781/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=781&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://billbrouwer.wordpress.com/2011/08/16/xml-call-tree/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/617e9a1e9e7eb3749261023f232e085b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbrouwer</media:title>
		</media:content>

		<media:content url="http://billbrouwer.files.wordpress.com/2011/08/screenshot.png?w=300" medium="image">
			<media:title type="html">Screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>vectorized octave</title>
		<link>http://billbrouwer.wordpress.com/2010/12/28/vectorized-octave/</link>
		<comments>http://billbrouwer.wordpress.com/2010/12/28/vectorized-octave/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 03:13:42 +0000</pubDate>
		<dc:creator>bbrouwer</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[octave]]></category>
		<category><![CDATA[stdin]]></category>
		<category><![CDATA[stream]]></category>
		<category><![CDATA[vectorize]]></category>

		<guid isPermaLink="false">http://billbrouwer.wordpress.com/?p=773</guid>
		<description><![CDATA[octave can be very fast when vectorized, particularly when reading and formatting streams. Here&#8217;s an example which takes an array read from stdin and reformats : %reapportion bytes [m n]=size(input); if (en=='ieee-be') %7 4 byte numbers outputA = reshape(input(:,1:14),m,2,7); outputB = reshape((bitshift(outputA(:,1,:),16) + outputA(:,2,:)),m,7); %4 2 byte numbers %8 4 byte numbers outputA = reshape(input(:,19:34),m,2,8); [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=773&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>octave can be very fast when vectorized, particularly when reading and formatting streams. Here&#8217;s an example which takes an array read from stdin and reformats :</p>
<hr />
<pre style="border:thin solid black;overflow:auto;display:block;white-space:pre;margin:1em;padding:5px;"><code>

	%reapportion  bytes

	[m n]=size(input);

	if (en=='ieee-be')

	%7 4 byte numbers
	outputA = reshape(input(:,1:14),m,2,7);
	outputB = reshape((bitshift(outputA(:,1,:),16) + outputA(:,2,:)),m,7);

	%4 2 byte numbers
	%8 4 byte numbers
	outputA = reshape(input(:,19:34),m,2,8);
	outputC = reshape((bitshift(outputA(:,1,:),16) + outputA(:,2,:)),m,8);

	%2 2 byte numbers
	%4 4 byte numbers
	outputA = reshape(input(:,37:44),m,2,4);
	outputD = reshape((bitshift(outputA(:,1,:),16) + outputA(:,2,:)),m,4);

	else

	%7 4 byte numbers
	outputA = reshape(input(:,1:14),m,2,7);
	outputB = reshape((outputA(:,1,:) + bitshift(outputA(:,2,:),16)),m,7);

	%4 2 byte numbers
	%8 4 byte numbers
	outputA = reshape(input(:,19:34),m,2,8);
	outputC = reshape((outputA(:,1,:) + bitshift(outputA(:,2,:),16)),m,8);

	%2 2 byte numbers
	%4 4 byte numbers
	outputA = reshape(input(:,37:44),m,2,4);
	outputD = reshape((outputA(:,1,:) + bitshift(outputA(:,2,:),16)),m,4);

	end

	%must recast for signs
	output = [int32(outputB) int16(input(:,15:18)) int32(outputC) int16(input(:,35:36)) int32(outputD) int16(input(:,45:n))]; 	

</code></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/billbrouwer.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/billbrouwer.wordpress.com/773/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/billbrouwer.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/billbrouwer.wordpress.com/773/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/billbrouwer.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/billbrouwer.wordpress.com/773/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/billbrouwer.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/billbrouwer.wordpress.com/773/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/billbrouwer.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/billbrouwer.wordpress.com/773/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/billbrouwer.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/billbrouwer.wordpress.com/773/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/billbrouwer.wordpress.com/773/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/billbrouwer.wordpress.com/773/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=773&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://billbrouwer.wordpress.com/2010/12/28/vectorized-octave/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/617e9a1e9e7eb3749261023f232e085b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbrouwer</media:title>
		</media:content>
	</item>
		<item>
		<title>battles</title>
		<link>http://billbrouwer.wordpress.com/2010/12/28/battles/</link>
		<comments>http://billbrouwer.wordpress.com/2010/12/28/battles/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 03:00:32 +0000</pubDate>
		<dc:creator>bbrouwer</dc:creator>
				<category><![CDATA[art]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[battles]]></category>
		<category><![CDATA[prog rock]]></category>

		<guid isPermaLink="false">http://billbrouwer.wordpress.com/?p=770</guid>
		<description><![CDATA[great prog rock, sounds very good very late in the evening<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=770&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>great prog rock, sounds very good very late in the evening<br />
<img alt="" src="http://upload.wikimedia.org/wikipedia/en/e/ed/Battlesmirrored.png" title="battles" class="alignnone" width="400" height="400" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/billbrouwer.wordpress.com/770/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/billbrouwer.wordpress.com/770/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/billbrouwer.wordpress.com/770/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/billbrouwer.wordpress.com/770/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/billbrouwer.wordpress.com/770/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/billbrouwer.wordpress.com/770/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/billbrouwer.wordpress.com/770/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/billbrouwer.wordpress.com/770/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/billbrouwer.wordpress.com/770/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/billbrouwer.wordpress.com/770/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/billbrouwer.wordpress.com/770/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/billbrouwer.wordpress.com/770/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/billbrouwer.wordpress.com/770/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/billbrouwer.wordpress.com/770/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=billbrouwer.wordpress.com&amp;blog=4675622&amp;post=770&amp;subd=billbrouwer&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://billbrouwer.wordpress.com/2010/12/28/battles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/617e9a1e9e7eb3749261023f232e085b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bbrouwer</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/en/e/ed/Battlesmirrored.png" medium="image">
			<media:title type="html">battles</media:title>
		</media:content>
	</item>
	</channel>
</rss>
