Difference between revisions of "Processors Command"

From OSUPDOCS
Jump to navigation Jump to search
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
The Processors command selects the number of processors to use when running parallel versions of [[NairnMPM]], and [[NairnFEA]]. The format is
__TOC__
Run parallel calculations.
 
== Number of Processors ==
In scripting files, the <tt>Processors</tt> command selects the number of processors to use when [[NairnMPM]], and [[NairnFEA]] in parallel. The format is


  Processors (number)
  Processors (number)


where <tt>number</tt> is the number of processors.
where <tt>number</tt> is the number of processors. Setting number of processors greater than 1 implies you are running in parallel. If the requested number is greater than the available number of processors, it will be reduced to the available number of processors.


To select number of processors when using <tt>XML</tt> input files, enter the following comment anywhere in the file:
To select number of processors when using <tt>XML</tt> input files, enter the following comment anywhere in the file:
Line 11: Line 15:
where # is replaced by the number of processors. But note that this <tt>XML</tt> comment option only works when launching calculations in [[NairnFEAMPM]] or [[NairnFEAMPMViz]]. When using a [[Options for Running Calculations#Command-Line Execution|command line]] to launch calculations, pick the number of processors with each code engine's <tt>-np</tt> option instead.
where # is replaced by the number of processors. But note that this <tt>XML</tt> comment option only works when launching calculations in [[NairnFEAMPM]] or [[NairnFEAMPMViz]]. When using a [[Options for Running Calculations#Command-Line Execution|command line]] to launch calculations, pick the number of processors with each code engine's <tt>-np</tt> option instead.


=== Hyperthreading ===
== Custom Patching ==
 
Parallel calculations when running [[NairnMPM]] divide the orthogonal grid into orthogonal patches. 2D grids are divided into <tt>(xnum)X(ynum)</tt> patches and 3D grids are divided into <tt>(xnum)X(ynum)X(znum)</tt> where <tt>(inum)</tt> is number of patches along the <tt>i</tt> axis. The <tt>(inum)</tt> values are automatically determined by factoring the number of processors, <tt>p</tt>, with attention to putting more patches along longer grid axes. All patches will be the same size.
 
If the automatic patching calculations or the use of equally-sized patches is not ideal for a specific simulation, you can override that calculation with custom patching with the following <tt>XML</tt> element in the [[MPM_Input_Files#Main_Header|MPM Header]].
 
&lt;PatchGrid x="xnum" y="ynum" z="znum"&gt;
    &lt;Xpatches&gt;n<sub>1</sub>,n<sub>2</sub>,...n<sub>xnum-1</sub>&lt;/Xpatches&gt;
    &lt;Ypatches&gt;n<sub>1</sub>,n<sub>2</sub>,...n<sub>ynum-1</sub>&lt;/Ypatches&gt;
    &lt;Zpatches&gt;n<sub>1</sub>,n<sub>2</sub>,...n<sub>znum-1</sub>&lt;/Ypatches&gt;
&lt;/PatchGrid&gt;
 
where <tt>xnum</tt>, <tt>ynum</tt>, and <tt>znum</tt> are the number of patches in the x, y, and z direction (z only used for 3D patching). Their product must be equal to the number of processors used in the calculations. This command can be used in scripted files by using the [[XMLData Command]] for the <tt>MPMHeader</tt> section.
 
By default, the patches will be equally sized along each axis. If unequal patch sizes can improve parallel scaling, they can be created using <tt>Xpatches</tt>, <tt>Ypatches</tt>, or <tt>Zpatches</tt> elements. Each patches element must contain exactly <tt>inum-1</tt> (i = x, y, or z) monotonically increasing numbers between zero and one for the fractional break points between patches. If an axis has <tt>N</tt> elements, the <tt>k<sup>th</sup></tt> patch (for <tt>k</tt> from 1 to <tt>inum</tt>) will include elements <tt>int(n<sub>k-1</sub>*N)</tt> to <tt>int(n<sub>k</sub>*N)</tt> (where n<sub>0</sub> is set to 0 and n<sub>inum</sub> is set to 1). All patches must have at least two elements or must have <tt>int(n<sub>k</sub>*N)</tt>&gt;<tt>int(n<sub>k-1</sub>*N)</tt> for all <tt>k</tt>. The patches elements are optional. Any omitted axes will use equally sizes patches corresponding to <tt>n<sub>i</sub>=i/inum</tt>.
 
== Hyperthreading ==


Most computers with multi-core processors also enable hyperthreading, which allows the machine to appear as if it has twice as many cores as the physical number of cores. Not surprisingly, if you are doing scientific calculations that are actually using the CPU full time, the additional of virtual cores is no benefit. For example, if you have an 8-core chip and plot calculation time vs. number of processors used, the performance will peak for 8 processors. Calculations times will not improve for more the 8 processors and may even get slightly slower. Furthermore, overhead needed to enable hyperthreading will slightly degrade calculation speed even when only using the 8 physical cores.
Most computers with multi-core processors also enable hyperthreading, which allows the machine to appear as if it has twice as many cores as the physical number of cores. Not surprisingly, if you are doing scientific calculations that are actually using the CPU full time, the additional of virtual cores is no benefit. For example, if you have an 8-core chip and plot calculation time vs. number of processors used, the performance will peak for 8 processors. Calculations times will not improve for more the 8 processors and may even get slightly slower. Furthermore, overhead needed to enable hyperthreading will slightly degrade calculation speed even when only using the 8 physical cores.
Line 31: Line 51:


You can test your setting by running a calculation with processors option set to a number higher than the physical number of cores. If you request more processors than available, your setting will be changed to the maximum number of available processors. Look near the beginning of any output <tt>.mpm</tt> or <tt>.fea</tt> file to verify number of processors used by the calculations and available on your computer.
You can test your setting by running a calculation with processors option set to a number higher than the physical number of cores. If you request more processors than available, your setting will be changed to the maximum number of available processors. Look near the beginning of any output <tt>.mpm</tt> or <tt>.fea</tt> file to verify number of processors used by the calculations and available on your computer.
== Notes ==
* Setting number of processors greater than 1 implies you are running parallel versions of code engines. If not, an error will result and no calculations will run.
* If the requested number is greater than the available number of processors, it will be reduced to the available number of processors.

Latest revision as of 14:02, 2 February 2023

Run parallel calculations.

Number of Processors

In scripting files, the Processors command selects the number of processors to use when NairnMPM, and NairnFEA in parallel. The format is

Processors (number)

where number is the number of processors. Setting number of processors greater than 1 implies you are running in parallel. If the requested number is greater than the available number of processors, it will be reduced to the available number of processors.

To select number of processors when using XML input files, enter the following comment anywhere in the file:

<!--processors #-->

where # is replaced by the number of processors. But note that this XML comment option only works when launching calculations in NairnFEAMPM or NairnFEAMPMViz. When using a command line to launch calculations, pick the number of processors with each code engine's -np option instead.

Custom Patching

Parallel calculations when running NairnMPM divide the orthogonal grid into orthogonal patches. 2D grids are divided into (xnum)X(ynum) patches and 3D grids are divided into (xnum)X(ynum)X(znum) where (inum) is number of patches along the i axis. The (inum) values are automatically determined by factoring the number of processors, p, with attention to putting more patches along longer grid axes. All patches will be the same size.

If the automatic patching calculations or the use of equally-sized patches is not ideal for a specific simulation, you can override that calculation with custom patching with the following XML element in the MPM Header.

<PatchGrid x="xnum" y="ynum" z="znum">
   <Xpatches>n1,n2,...nxnum-1</Xpatches>
   <Ypatches>n1,n2,...nynum-1</Ypatches>
   <Zpatches>n1,n2,...nznum-1</Ypatches>
</PatchGrid>

where xnum, ynum, and znum are the number of patches in the x, y, and z direction (z only used for 3D patching). Their product must be equal to the number of processors used in the calculations. This command can be used in scripted files by using the XMLData Command for the MPMHeader section.

By default, the patches will be equally sized along each axis. If unequal patch sizes can improve parallel scaling, they can be created using Xpatches, Ypatches, or Zpatches elements. Each patches element must contain exactly inum-1 (i = x, y, or z) monotonically increasing numbers between zero and one for the fractional break points between patches. If an axis has N elements, the kth patch (for k from 1 to inum) will include elements int(nk-1*N) to int(nk*N) (where n0 is set to 0 and ninum is set to 1). All patches must have at least two elements or must have int(nk*N)>int(nk-1*N) for all k. The patches elements are optional. Any omitted axes will use equally sizes patches corresponding to ni=i/inum.

Hyperthreading

Most computers with multi-core processors also enable hyperthreading, which allows the machine to appear as if it has twice as many cores as the physical number of cores. Not surprisingly, if you are doing scientific calculations that are actually using the CPU full time, the additional of virtual cores is no benefit. For example, if you have an 8-core chip and plot calculation time vs. number of processors used, the performance will peak for 8 processors. Calculations times will not improve for more the 8 processors and may even get slightly slower. Furthermore, overhead needed to enable hyperthreading will slightly degrade calculation speed even when only using the 8 physical cores.

The maximum performance is normally to disable hyperthreading and to run with processors set to the physical number of cores. Hyperthreading can be disabled as follows:

  • MacOS
    1. Install XCode
    2. Run XCode and choose Instruments from the XCode→Other Development Tool submenu.
    3. Choose Preferences... menu command.
    4. Click on CPUs and uncheck "Hardware Multithreading."
    5. According to Apple, this setting has to be repeated each time you restart or each time your computer goes to sleep.
  • Windows
    1. Restart you computer and hold down the Esc key until menu or option to get a menu appears.
    2. The menu allows you to configure the BIOS. Look for hyperthreading control under "Performance."
    3. Set hyperthreading control to "Disabled."
    4. Save and exit the BIOS configuration.
    5. This change will permanently disable hyperthreading, but you can also get it back by repeating above process and choosing "Enabled."

You can test your setting by running a calculation with processors option set to a number higher than the physical number of cores. If you request more processors than available, your setting will be changed to the maximum number of available processors. Look near the beginning of any output .mpm or .fea file to verify number of processors used by the calculations and available on your computer.