<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — MPI and Simplyfortran]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=383&amp;type=atom" />
	<updated>2014-11-24T11:25:59Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=383</id>
		<entry>
			<title type="html"><![CDATA[Re: MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1619#p1619" />
			<content type="html"><![CDATA[<p>Thanks for that!&nbsp; Worked perfectly using the &#039;set&#039; commands in command window!&nbsp; &nbsp;Getting good scaling.</p>]]></content>
			<author>
				<name><![CDATA[Dr_Manhattan]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3583</uri>
			</author>
			<updated>2014-11-24T11:25:59Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1619#p1619</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1618#p1618" />
			<content type="html"><![CDATA[<p>With hyperthreading in your i7, OpenMp will try to use 12 cores. To restrict to 6 cores you might want to set OMP_NUM_THREADS=6. (I assume you have 6 cores).</p><p>In Windows, you can set environment variables using &quot;set&quot; from a command window, e.g.</p><p>set OMP_PROC_BIND=TRUE<br />set OMP_NUM_THREADS=6</p><p>This will work if you run your code from the command window.</p><p>However, SimplyFortran doesn&#039;t provide a facility to set up the run time environment if you are running your program from the GUI, so you will need to do this &quot;Globally&quot; so it is activated each time you login.</p><p>How you do this varies with each version of Windows; look in the control panel under System and Security, then System, then Advanced system settings. There is an &quot;Environment Variables&quot; button which allows you to define variables. You may need to reboot to get these recognised.</p>]]></content>
			<author>
				<name><![CDATA[davidb]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3463</uri>
			</author>
			<updated>2014-11-24T07:17:36Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1618#p1618</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1617#p1617" />
			<content type="html"><![CDATA[<p>Just another question in regards to OpenMP.</p><p>When I run my code on a unix cluster on a single node with 16 threads, I get good acceleration.&nbsp; However I don&#039;t seem to get that locally on my home machine under windows (12 core i7).&nbsp; In fact the code is a lot slower with OpenMP on than in serial.&nbsp; &nbsp;I asked the IT gurus about this and they mentioned this,</p><p>&quot;2. threads bounce between cores and cpus and not benefitting from cache etc.<br />to prevent threads from bouncing around you&#039;d need to pass some environment variables to the program. The simplest is to set OMP_PROC_BIND to TRUE. In Linux (in bash) you could do this by either export statement or just by starting your program in this way:<br />OMP_PROC_BIND=TRUE snap<br />But I don&#039;t know how to do this in Windows.&quot;</p><p>Any ideas of any flags that should be used when using OpenMP?&nbsp; I&#039;m just curious.&nbsp; Its not urgent, as everything will ultimately be run on the big government clusters.&nbsp; </p><p>Thanks!</p>]]></content>
			<author>
				<name><![CDATA[Dr_Manhattan]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3583</uri>
			</author>
			<updated>2014-11-24T04:27:55Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1617#p1617</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1574#p1574" />
			<content type="html"><![CDATA[<p>David,</p><p>I see what you&#039;re saying.&nbsp; Simply Fortran&#039;s indexing system does not currently support handling OpenMP sentinels, and it really should.&nbsp; I don&#039;t think it applies to the original issue in this thread, but, rather, it is an entirely separate missing feature.&nbsp; I can look into getting support added.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2014-10-30T12:57:41Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1574#p1574</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1573#p1573" />
			<content type="html"><![CDATA[<p>Jeff,</p><p>What I was suggesting was a bit more support for OpenMP dependencies.</p><p>Currently a project with the following two files will fail to build in Simply Fortran when OpenMP is enabled.</p><div class="codebox"><pre><code>! modules.f90
module omp_stuff
contains
   subroutine omp_routine
      !$ use omp_lib
      !$omp critical
      !$ print *,&#039; openmp thread &#039;, omp_get_thread_num()
      !$omp end critical
   end subroutine omp_routine
end module omp_stuff</code></pre></div><div class="codebox"><pre><code>! main.f90
program main

   !$ use omp_stuff  ! The dependency here with the file containing omp_stuff isn&#039;t detected
   
   logical :: omp_mode = .false.
   
   ! Change flag if compiled with -openmp
   !$ omp_mode = .true.
   
   !$ if (omp_mode) then
   !$    call omp_routine
   !$ end if
   
   if (.not. omp_mode) then
      print *, &#039;Program not compiled with -openmp; serial version&#039;
   end if
   
end program main</code></pre></div><p>It is just a thought though. It may not be trivial to do in a GUI. It is something I have implemented in my own command line tool, where responsiveness is less of an issue and I can just rebuild the dependency file tree each time.</p>]]></content>
			<author>
				<name><![CDATA[davidb]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3463</uri>
			</author>
			<updated>2014-10-30T09:12:41Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1573#p1573</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1572#p1572" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>If you have allowed for this, Dr_Manhatton could use OpenMP directives to get around the dependency issue:</p></blockquote></div><p>Well I believe his issue is actually a problem with improperly including disabled files in the dependency calculations.&nbsp; When the indexing engine starts processing, in his case perhaps, <em>susy_mpi.f90</em>, it will mark the <em>susy_mpi</em> module as being a part of the current project even though the file that contains it has been disabled.&nbsp; When the makefile is constructed, it determines which modules are <strong>USE</strong>d by the project that are also provided by the project.&nbsp; Even though <em>susy_mpi.f90</em> is disabled, meaning its <em>susy_mpi</em> module will never be created, it still outputs that module as a required module by other files.</p><p>The indexing engine should actually be noticing that <em>susy_mpi.f90</em> is disabled and excluding any modules that it might contain from being marked as &quot;provided by the current project.&quot;&nbsp; That way, the unfulfilled dependency isn&#039;t generated in the makefile.&nbsp; The evaluation of preprocessor macros is, in fact, not necessary for the correct behavior.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2014-10-29T19:28:16Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1572#p1572</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1571#p1571" />
			<content type="html"><![CDATA[<p>Jeff,</p><p>When you construct your file dependency tree have you allowed for use statements in OpenMP directives?</p><p>That is, in the following code you could make yyy.f90 depend on xxx.f90 when -openmp is specified (and not otherwise).<br />This would require you to check if -openmp is present and re-build the tree for each compile.</p><p>You need to avoid making a dependency link for !$ use omp_lib.</p><div class="codebox"><pre><code>! yyy.f90
program yyy
   !$ use xxx

   ! ... program stuff

end program yyy</code></pre></div><p>and</p><div class="codebox"><pre><code>! xxx.f90
module xxx

   ! ... module stuff

end module xxx</code></pre></div><p>If you have allowed for this, Dr_Manhatton could use OpenMP directives to get around the dependency issue:</p><div class="codebox"><pre><code>      !$ USE mod_GUTSUSY_mpi
      !$ USE mpi</code></pre></div><p>Then just compile with -openmp when mpi is needed.</p>]]></content>
			<author>
				<name><![CDATA[davidb]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3463</uri>
			</author>
			<updated>2014-10-29T18:43:49Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1571#p1571</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1570#p1570" />
			<content type="html"><![CDATA[<p>Ah, yes, that would be a bug.&nbsp; The dependency calculations don&#039;t evaluate preprocessor macros, so it assumes that you&#039;d want to actually execute the offending <em>USE susy_mpi</em> statement.&nbsp; However, the module is never actually compiled, causing the Makefile to be broken.</p><p>&quot;Disabling&quot; a file should exclude it from dependency calculations as well, but clearly it has not.</p><p>I&#039;ll have to look into a better way to handle this and fix the handling of disabled files.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2014-10-29T11:24:16Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1570#p1570</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1569#p1569" />
			<content type="html"><![CDATA[<p>Hi Jeff,</p><p>Thanks for that. That advice fixed things up for me in regards to those pre-processor commands.</p><p>One thing I did notice is that,</p><p>susy_mpi.f90&nbsp; is module file full of code which is called from within one of these #if statements.</p><p>If I &#039;disable it&#039;, I get the following,</p><p>Compiling .\mod_susy_data.f90<br />Compiling .\mod_susyflat_flat.f90<br />Compiling .\mod_susy_cells.f90<br />Error(F38): (modules\susy_mpi.mod) does not exist and cannot be made from existing files<br />Error(E02): Make execution terminated</p><p>* Failed *</p><p>However if I just remove the file from the project, everything compiles fine and runs perfectly (with all the pre-processor statement with the &#039;C preprocessor enabled&#039; as you suggested).&nbsp; </p><p>Just not sure if that&#039;s a bug.&nbsp; I&#039;d assume &#039;disable&#039; would be similar to not having the file in the project.</p><p>Anyhow, thanks for the help!</p>]]></content>
			<author>
				<name><![CDATA[Dr_Manhattan]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3583</uri>
			</author>
			<updated>2014-10-29T03:11:42Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1569#p1569</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1565#p1565" />
			<content type="html"><![CDATA[<p>We don&#039;t currently have any supported MPI solution, but I&#039;ve been looking into it.&nbsp; Microsoft does support an MPI package for Windows that Simply Fortran might be able to employ, but it hasn&#039;t yet been tested.&nbsp; </p><p>For preprocessor definitions like you&#039;ve shown in your example, you can actually leave them in the code.&nbsp; The &quot;#ifdef&quot; blocks are C-style preprocessor statements that can be evaluated during compilation.&nbsp; You&#039;ll actually just need to enable the C preprocessor.&nbsp; If you open the <em>Project Options</em> window from the &quot;Options...&quot; item in the Project menu, then click the <em>Fortran</em> tab, you&#039;ll find a checkbox labeled &quot;Enable C Preprocessor.&quot;&nbsp; Enable this option, click Ok, save your project, and try building again.&nbsp; Unless you&#039;ve added a flag defining &quot;USE_MPI&quot;&nbsp; under <em>Compiler Flags</em> in <em>Project Options</em>, Simply Fortran will skip compiling those USE statements.&nbsp; That way you won&#039;t need to modify the code just for our compiler.</p><div class="quotebox"><blockquote><p>Btw, love your Simplyfortran package and got quite a few physicists here in Australia using it</p></blockquote></div><p>That&#039;s great to hear!&nbsp; &nbsp;If you or any colleagues have suggestions, please don&#039;t hesitate to post them here!</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2014-10-28T14:33:55Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1565#p1565</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[MPI and Simplyfortran]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=1564#p1564" />
			<content type="html"><![CDATA[<p>Howdy all,</p><p>I&#039;ve got f90 code that someone is paralleling via MPI to run on a big cluster. <br />I note that Simplyfortran supports OpenMP but I&#039;m wondering if there is MPI support?&nbsp; </p><p>Specifically, I&#039;ve got these pre-processor labels about now and the call to mpi</p><p>#ifdef USE_MPI<br />&nbsp; &nbsp; &nbsp; USE mod_GUTSUSY_mpi<br />&nbsp; &nbsp; &nbsp; USE mpi<br />#endif</p><br /><p>Since I&#039;m developing the physics in the serial version, I&#039;ve just commented out all the #if statement and<br />can continue to develop.&nbsp; Just wondering what I should do short of those edits.</p><br /><p>Thanks!</p><br /><p>Btw, love your Simplyfortran package and got quite a few physicists here in Australia using it <img src="https://forums.approximatrix.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[Dr_Manhattan]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3583</uri>
			</author>
			<updated>2014-10-28T12:32:21Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=1564#p1564</id>
		</entry>
</feed>
