<?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: available memory with ALLOCATE in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750087#M6789</link>
    <description>What kernel-level call is the code making when it allocates memory? I'd like to pose this question to the linux-mm.org folks.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
    <pubDate>Wed, 10 Sep 2008 21:20:37 GMT</pubDate>
    <dc:creator>gregfi04</dc:creator>
    <dc:date>2008-09-10T21:20:37Z</dc:date>
    <item>
      <title>available memory with ALLOCATE</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750083#M6785</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm trying to write some code to determine how much memory is available on the machine, such that processing doesn't start when there's not enough memory to finish the problem. My understanding is that there is no native Fortran command to determine this, correct?&lt;BR /&gt;&lt;BR /&gt;I've hacked together the following, which progressively allocates more and more memory, until it finds the limit:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2" face="Courier New"&gt;program mem_test&lt;BR /&gt;implicit none&lt;BR /&gt;&lt;BR /&gt;real, dimension(:,:,:), allocatable :: MX&lt;BR /&gt;integer :: err_alloc,ng&lt;BR /&gt;NG = 1700&lt;BR /&gt;&lt;BR /&gt; DO WHILE (.NOT.ALLOCATED(MX))&lt;BR /&gt; IF (.NOT.ALLOCATED(MX)) ALLOCATE (MX(1:NG,1:NG,1:NG), STAT = ERR_ALLOC)&lt;BR /&gt; IF (ERR_ALLOC == 0) THEN&lt;BR /&gt; NG = NG + 5&lt;BR /&gt; DEALLOCATE(MX)&lt;BR /&gt; ELSE IF(ERR_ALLOC /= 0) THEN&lt;BR /&gt; WRITE (*,*) "STOPPING AT NG=",NG, " WITH ERROR=",ERR_ALLOC&lt;BR /&gt; EXIT&lt;BR /&gt; ENDIF&lt;BR /&gt; END DO&lt;BR /&gt;&lt;BR /&gt;WRITE (*,*) 'ALLOCATED ', 4.0 * (NG**3) / 1000000.0, ' MEGABYTES.'&lt;BR /&gt;end program&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;I'm running this on a quad-core Xeon workstation with 16 GB of memory. See below:&lt;BR /&gt;&lt;FONT size="2" face="Courier New"&gt;&lt;BR /&gt;849 fischega@lxlog01[~/testdir/memtest]&amp;gt; free -m&lt;BR /&gt; total used free shared buffers cached&lt;BR /&gt;Mem: 16054 3852 12201 0 116 3158&lt;BR /&gt;-/+ buffers/cache: 578 15476&lt;BR /&gt;Swap: 8236 0 8236&lt;BR /&gt;850 fischega@lxlog01[~/testdir/memtest]&amp;gt; uname -a&lt;BR /&gt;Linux lxlog01 2.6.16.60-0.21-smp #1 SMP Tue May 6 12:41:02 UTC 2008 x86_64 x86_64 x86_64 GNU/Linux&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;BR /&gt;I seem to be hitting a limit around 7 GB, whereas "free" claims there is 12 GB available. What gives? Is my math wrong? 4 bytes for a vanilla REAL, right?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Greg&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Sep 2008 20:12:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750083#M6785</guid>
      <dc:creator>gregfi04</dc:creator>
      <dc:date>2008-09-10T20:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: available memory with ALLOCATE</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750084#M6786</link>
      <description>The math seems right.&lt;BR /&gt;&lt;BR /&gt;I think that maximum memory is limited by the OS and not by the compiler.&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Sep 2008 20:29:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750084#M6786</guid>
      <dc:creator>Tabrez_Ali</dc:creator>
      <dc:date>2008-09-10T20:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: available memory with ALLOCATE</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750085#M6787</link>
      <description>Note that you are fragmenting memory with this scheme. You might try allocating 16GB first and then working your way down until it succeeds.&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Sep 2008 21:01:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750085#M6787</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-09-10T21:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: available memory with ALLOCATE</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750086#M6788</link>
      <description>I still seem to end up with roughly the same answer. ~7GB instead of ~12 GB. I suppose this is more of a Linux memory management question, eh? &lt;BR /&gt;</description>
      <pubDate>Wed, 10 Sep 2008 21:14:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750086#M6788</guid>
      <dc:creator>gregfi04</dc:creator>
      <dc:date>2008-09-10T21:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: available memory with ALLOCATE</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750087#M6789</link>
      <description>What kernel-level call is the code making when it allocates memory? I'd like to pose this question to the linux-mm.org folks.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Sep 2008 21:20:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750087#M6789</guid>
      <dc:creator>gregfi04</dc:creator>
      <dc:date>2008-09-10T21:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: available memory with ALLOCATE</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750088#M6790</link>
      <description>malloc&lt;BR /&gt;&lt;BR /&gt;You may want to see if strace provides any useful information. You can also try it with malloc and free in place of ALLOCATE (remembering to get the number of bytes right.)&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Sep 2008 12:59:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750088#M6790</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-09-11T12:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: available memory with ALLOCATE</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750089#M6791</link>
      <description>&lt;P&gt;Greg,&lt;/P&gt;
&lt;P&gt;I am not a Linux programmer so my comment may be for naught.&lt;/P&gt;
&lt;P&gt;The 7GB appears to be approximately 1/2 the available memory.&lt;/P&gt;
&lt;P&gt;Linux is structured to grow the application stack down from the negative address space (-8, -16, ...) or(-4, -8, ...) depending on x64 or x32.&lt;/P&gt;
&lt;P&gt;My guess is without specifying how large of stack space to reserve Linux may assume 50/50 for stack and allocatables.&lt;/P&gt;
&lt;P&gt;Try specifying a 1GB stack limit and see if you go above the 7GB. (You will have to read the docs as to how to go about specifying stack limit.)&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2008 20:19:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750089#M6791</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2008-09-11T20:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: available memory with ALLOCATE</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750090#M6792</link>
      <description>&lt;P&gt;I tried the following variant on a Linux (SLES10) system with 16 GB of physical memory and approximately 8GB of swap space. This seemed to successfully allocate all the memory available, and not more. The stack is not involved here. Note that you need -i8 or a source code change in orderto computeNG**3, else you may get an integeroverflow close to 8 GB (4.0 * 1250**3). You need to access the array after allocating it - you can allocate as much memory as you like, if it is never used.&lt;/P&gt;
&lt;P&gt;program mem_test&lt;BR /&gt;implicit none&lt;/P&gt;
&lt;P&gt;real, dimension(:,:,:), allocatable :: MX&lt;BR /&gt;integer :: ng, err_alloc, i&lt;BR /&gt;NG = NG3&lt;/P&gt;
&lt;P&gt; ALLOCATE (MX(1:NG,1:NG,1:NG), STAT = ERR_ALLOC)&lt;/P&gt;
&lt;P&gt;DO I=1,NG,NG/10&lt;BR /&gt; WRITE(*,*) MX(I,I,I)&lt;BR /&gt;ENDDO&lt;/P&gt;
&lt;P&gt;WRITE (*,*)&lt;BR /&gt;WRITE (*,*) 'ALLOCATED ', 4.0 * (NG**3) / 1000000.0, ' MEGABYTES.'&lt;BR /&gt;end program&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;ifort -fpp -i8 alloc2.f90 -DNG3=1800;./a.out&lt;/P&gt;
&lt;P&gt;.....&lt;/P&gt;
&lt;P&gt;ALLOCATED 23328.00 MEGABYTES.&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;ifort -fpp -i8 alloc2.f90 -DNG3=1850;./a.out&lt;/P&gt;
&lt;P&gt;forrtl: severe (174): SIGSEGV, segmentation fault occurred&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;____________________________________________&lt;/P&gt;
&lt;P&gt;In addition, you could call the library function SYSTEM (or SYSTEMQQ) to execute the shell command free -m:&lt;/P&gt;
&lt;P&gt;use ifport&lt;/P&gt;
&lt;P&gt;IERR=SYSTEM("free -m")&lt;/P&gt;
&lt;P&gt;and either parse and redirect the output to a file,so that you can read it back, ortry something more clever. You could even use SYSTEM to run repeatedly a test program like the one above, gradually increasing the memory allocation until it failed, and SYSTEM returns a non-zero error code.&lt;/P&gt;
&lt;P&gt;You can find a description of SYSTEM and SYSTEMQQ in the main Fortran compiler documentation.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Sep 2008 00:17:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/available-memory-with-ALLOCATE/m-p/750090#M6792</guid>
      <dc:creator>Martyn_C_Intel</dc:creator>
      <dc:date>2008-09-16T00:17:51Z</dc:date>
    </item>
  </channel>
</rss>

