<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252583</link>
    <title>MATLAB Central Newsreader - Simultaneous disk read and computations</title>
    <description>Feed for thread: Simultaneous disk read and computations</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 31 May 2009 20:17:01 -0400</pubDate>
      <title>Simultaneous disk read and computations</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/252583#653680</link>
      <author>NIcholas </author>
      <description>Hello,&lt;br&gt;
I have amount of data stored on disk - now about 10GB stored as 20 different files in 500MB blocks.  I need to loop through each block, do some computations, take in the next block etc.  Right now, reading the file (binary format) takes about as much time as my computations.  I was wondering if it were possible to read in the next block while the CPU is processing the first block.&lt;br&gt;
Code looks something like this:&lt;br&gt;
&lt;br&gt;
for i=1:nBlock&lt;br&gt;
A=fread(fid{i},inf,'*uint8');&lt;br&gt;
result{i} = doSomething(A);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
I would like to do something like this:&lt;br&gt;
&lt;br&gt;
A{1} = fread(fid{1},inf,'*uint8');&lt;br&gt;
for i=1:nBlock-1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;indCurr = mod(i-1,2)+1; %1 if i if odd, 2 if i is even&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;indNext = mod(i,2)+1; %1 if i is even, 2 if i is odd&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;b{i} = doSomething(A{indCurr});             % CPU intensive&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;A{indNext} = fread(fid{1+1},inf,'*uint8'); % disk intensive&lt;br&gt;
end&lt;br&gt;
b{nBlock} = doSomthing(A{indNext});&lt;br&gt;
&lt;br&gt;
where the lines labeled &quot;CPU intensive&quot; and &quot;disk intensive&quot; are done in parralel.&lt;br&gt;
Thanks,&lt;br&gt;
Nick</description>
    </item>
  </channel>
</rss>

