<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: IML Simulation runinning very slow in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Simulation-runinning-very-slow/m-p/128378#M1005</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A good programming practice is to estimate how long your simulation will run. See Chap 15 (especially Section 15.3) of my book to learn how to run the simulation on a smaller problem and predict how long it will take on the full problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Most of your CPU stats are not relevant to this problem.&amp;nbsp; The problem is not memory intensive, so 64-bit processing and 64GB of RAM are not relevant. None of your computations are multithreaded, so the 6 cores and 12 threads are not relevant.&amp;nbsp; The only thing that matters in this problem is how fast you can iterate, because the innermost loop does not perform very much work. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have four nested loops. All of them are constant length except for the innermost, which has a DO UNTIL clause. The maximum number of iterations that you are asking for is about 7*330*10000*15000 = 350 BILLION iterations!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This is a lot.&amp;nbsp; To give you some idea, consider the following DATA step program, which does nothing more than accumulate 350 billion random numbers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options fullstimer;&lt;/P&gt;&lt;P&gt;data A;&lt;/P&gt;&lt;P&gt;call streaminit(1);&lt;/P&gt;&lt;P&gt;keep count;&lt;/P&gt;&lt;P&gt;count = 0;&lt;/P&gt;&lt;P&gt;do l= 1 to 7;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do h= 7 to 40 by 0.1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do k = 1 to 10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do m= 1 to 15000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = count + rand("Normal");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This program is much simpler than your program. It does not write any observations (writing data is a slow operation because it accesses the disk) and it does not do any numerical linear algebra. It doesn't have any IF/THEN logic. How long do you think the DATA step requires to run?&amp;nbsp; One minute? 5 minutes?&amp;nbsp; 15 minutes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How about 6.5 hours (estimated)!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And that estimate is for the DATA step, which in general can iterate faster than PROC IML because it is a simpler language with simpler parsing rules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you've said that you don't want to wait for "days" for the program to complete, I suggest you compute on a coarser grid (the H loop) and use fewer simulations (the K and M loops). I also suggest that you run a series of small-scale simulations so that you can predict how long the large-scale simulation will take.&amp;nbsp; Lastly, you should consider printing L and H inside the second loop so that you can always tell how far the program has progressed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 May 2012 19:13:46 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2012-05-29T19:13:46Z</dc:date>
    <item>
      <title>IML Simulation runinning very slow</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Simulation-runinning-very-slow/m-p/128377#M1004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif';"&gt;Hello folks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif';"&gt;I am still having trouble with the attached IML simulation code. I have made all&lt;BR /&gt;recommended changes (Thanks to Ian and Rick) and the code is still running very&lt;BR /&gt;slow. It is running on SAS 9.3 64 bit on an Intel i7 3930 3.2, 6 core, 12&lt;BR /&gt;threads, with 64GB RAM. So, I have the all the power available to any non-corprate user.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: 'Times New Roman','serif';"&gt;I am not sure why SAS is running extremely slow. This code should not run for days on&lt;BR /&gt;end and it would be OK for one, but I need around 96 different permutations to&lt;BR /&gt;finish my project. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif';"&gt;I am extremely desperate now and I would appreciate e any help if anyone could look&lt;BR /&gt;into this code and see if there is something missing.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif';"&gt;Please help if you have any ideas. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif';"&gt;Thanks you all.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2012 16:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Simulation-runinning-very-slow/m-p/128377#M1004</guid>
      <dc:creator>jhzeinab_yahoo_com</dc:creator>
      <dc:date>2012-05-29T16:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: IML Simulation runinning very slow</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Simulation-runinning-very-slow/m-p/128378#M1005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A good programming practice is to estimate how long your simulation will run. See Chap 15 (especially Section 15.3) of my book to learn how to run the simulation on a smaller problem and predict how long it will take on the full problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Most of your CPU stats are not relevant to this problem.&amp;nbsp; The problem is not memory intensive, so 64-bit processing and 64GB of RAM are not relevant. None of your computations are multithreaded, so the 6 cores and 12 threads are not relevant.&amp;nbsp; The only thing that matters in this problem is how fast you can iterate, because the innermost loop does not perform very much work. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have four nested loops. All of them are constant length except for the innermost, which has a DO UNTIL clause. The maximum number of iterations that you are asking for is about 7*330*10000*15000 = 350 BILLION iterations!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This is a lot.&amp;nbsp; To give you some idea, consider the following DATA step program, which does nothing more than accumulate 350 billion random numbers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options fullstimer;&lt;/P&gt;&lt;P&gt;data A;&lt;/P&gt;&lt;P&gt;call streaminit(1);&lt;/P&gt;&lt;P&gt;keep count;&lt;/P&gt;&lt;P&gt;count = 0;&lt;/P&gt;&lt;P&gt;do l= 1 to 7;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do h= 7 to 40 by 0.1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do k = 1 to 10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do m= 1 to 15000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = count + rand("Normal");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This program is much simpler than your program. It does not write any observations (writing data is a slow operation because it accesses the disk) and it does not do any numerical linear algebra. It doesn't have any IF/THEN logic. How long do you think the DATA step requires to run?&amp;nbsp; One minute? 5 minutes?&amp;nbsp; 15 minutes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How about 6.5 hours (estimated)!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And that estimate is for the DATA step, which in general can iterate faster than PROC IML because it is a simpler language with simpler parsing rules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you've said that you don't want to wait for "days" for the program to complete, I suggest you compute on a coarser grid (the H loop) and use fewer simulations (the K and M loops). I also suggest that you run a series of small-scale simulations so that you can predict how long the large-scale simulation will take.&amp;nbsp; Lastly, you should consider printing L and H inside the second loop so that you can always tell how far the program has progressed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2012 19:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Simulation-runinning-very-slow/m-p/128378#M1005</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2012-05-29T19:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: IML Simulation runinning very slow</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Simulation-runinning-very-slow/m-p/128379#M1006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P id="yui_3_2_0_23_1338393482129408"&gt;&lt;SPAN id="yui_3_2_0_23_1338393482129579"&gt;Thank you Rick. Great advise. I will incorporate all in my code going forward. &lt;SPAN id="misspell-0"&gt;&lt;SPAN id="yui_3_2_0_23_1338393482129563"&gt;Some&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN id="misspell-1"&gt;prospective&lt;/SPAN&gt; on this code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P id="yui_3_2_0_23_1338393482129410"&gt;&lt;/P&gt;&lt;P id="yui_3_2_0_23_1338393482129412"&gt;&lt;SPAN id="yui_3_2_0_23_1338393482129568"&gt;The m loop (15000) is a maximum or an upper bound. The loop could stop after 1 or up to 15000 iteration. That is why it is harder to estimate the total run time. Unfortunately this is the hard part of the cod&lt;/SPAN&gt;&lt;SPAN id="misspell-0"&gt;e that I have very little control over, the sweet spot between 1 &amp;amp; 15,000.&lt;/SPAN&gt;&lt;/P&gt;&lt;P id="yui_3_2_0_23_1338393482129414"&gt;&lt;/P&gt;&lt;P id="yui_3_2_0_23_1338393482129416"&gt;I've estimated the code to run about 96 hours based on initial &lt;SPAN id="misspell-1"&gt;&lt;SPAN id="yui_3_2_0_1_133839348212911060"&gt;smaller&lt;/SPAN&gt; runs. I am adding some spatial signed-rank modules in step 2 and that where the code slows down. I considered doing this in R, but &lt;SPAN id="misspell-2"&gt;the&lt;/SPAN&gt; &lt;SPAN class="mark" id="misspell-2"&gt;IML&lt;/SPAN&gt; modules written in SAS are not easily recoded in R.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2012 19:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IML-Simulation-runinning-very-slow/m-p/128379#M1006</guid>
      <dc:creator>jhzeinab_yahoo_com</dc:creator>
      <dc:date>2012-05-29T19:27:13Z</dc:date>
    </item>
  </channel>
</rss>

