<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE flagsdescription SYSTEM "http://www.spec.org/dtd/cpuflags1.dtd">
<flagsdescription>

<!-- filename to begin with "NEC-platform-linux64" -->
<filename>NEC-platform-linux64-revC.xml</filename>

<title>SPEC CPU2006 Flag Description for NEC Server Platform</title>

<platform_settings>
 <![CDATA[
         <p><b>Platform settings</b></p>

         <p>One or more of the following settings may have been set.  If so, the "General Notes" section of the
         report will say so; and you can read below to find out more about what these settings mean.</p>


	 <p><b>Linux Huge Page settings</b></p>
	 <p>In order to take advantage of large pages, your system must be configured to use large pages.
	    To configure your system for huge pages perform the following steps:</p>
	    <ul>
		<li>Create a mount point for the huge pages: "mkdir /mnt/hugepages"</li>
		<li>The huge page file system needs to be mounted when the systems reboots.  Add the following to a system boot configuration file before any services are started: "mount -t hugetlbfs nodev /mnt/hugepages"</li>
		<li>Set vm/nr_hugepages=N in your /etc/sysctl.conf file where N is the maximum number of pages the system may allocate.</li>
		<li>Reboot to have the changes take effect.(Not necessary on some operating systems like RedHat Enterprise Linux 6.1.</li>
	    </ul>

	 <p>Note that further information about huge pages may be found in your Linux documentation file: /usr/src/linux/Documentation/vm/hugetlbpage.txt</p>

	 <p><b>HUGETLB_MORECORE </b></p>
	 <p>
	    Set this environment variable to "yes" to enable applications to use large pages. 
	 </p>

	 <p><b>LD_PRELOAD=/usr/lib64/libhugetlbfs.so </b></p>
	 <p>
	    Setting this environment variable is necessary to enable applications to use large pages. 
	 </p>

         <p><b>KMP_STACKSIZE </b></p>
         <p>
         Specify stack size to be allocated for each thread.
         </p>

         <p><b>KMP_AFFINITY </b></p>
         <p>
         KMP_AFFINITY  =  &lt; physical | logical &gt;, starting-core-id <br/>
         specifies the static mapping of user threads to physical cores. For example,
         if you have a system configured with 8 cores, OMP_NUM_THREADS=8 and
         KMP_AFFINITY=physical,0 then thread 0 will mapped to core 0, thread 1 will be mapped to core 1, and
         so on in a round-robin fashion.   <br/> </p>

         <p>
         KMP_AFFINITY = granularity=fine,scatter <br/>
         The value for the environment variable KMP_AFFIINTY affects how the threads from an auto-parallelized program are scheduled across processors. <br/>
         Specifying granularity=fine selects the finest granularity level, causes each OpenMP thread to be bound to a single thread context. <br/>
         This ensures that there is only one thread per core on cores supporting HyperThreading Technology<br/>
         Specifying scatter distributes the threads as evenly as possible across the entire system. <br/>
         Hence a combination of these two options, will spread the threads evenly across sockets, with one thread per physical core. <br/>
         </p>

         <p><b>OMP_NUM_THREADS </b></p>
         <p>
         Sets the maximum number of threads to use for OpenMP* parallel regions if no other value is specified in the application. This environment variable
         applies to both -openmp and -parallel (Linux and Mac OS X) or /Qopenmp and /Qparallel (Windows).
         Example syntax on a Linux system with 8 cores:
         export OMP_NUM_THREADS=8
         </p>

         <p><b>Patrol Scrub:</b></p>
         <p>
         This is a background activity initiated by the processor to seek out and fix memory errors. Patrol Scrub scans all of
         memory doing simulated "READs" while checking for ECC errors. If any ECC errors are detected during this process,
         they are logged as Patrol errors. Correctable errors are corrected and written back into memory. This mode is able to
         set to "Enable" or "Disable" in Maintenance Console.
         </p>


         <p><b>zone_reclaim_mode</b></p>
         <p>Zone_reclaim_mode allows someone to set more or less aggressive approaches to
reclaim memory when a zone runs out of memory. If it is set to zero then no zone reclaim occurs. Allocations will be satisfied from other zones / nodes in the system.</p>

         <p>This is value ORed together of</p>
         <p>1 = Zone reclaim on<br/>
            2 = Zone reclaim writes dirty pages out<br/>
            4 = Zone reclaim swaps pages</p>

         <p>zone_reclaim_mode is set during bootup to 1 if it is determined that pages from remote zones will cause a measurable performance reduction. The page allocator will then reclaim easily reusable pages (those page cache pages that are currently not used) before allocating off node pages.</p>
         <p>It may be beneficial to switch off zone reclaim if the system is used for a file server and all of memory should be used for caching files from disk. In that case the caching effect is more important than data locality.</p>
         <p>Allowing zone reclaim to write out pages stops processes that are writing large amounts of data from dirtying pages on other nodes. Zone reclaim will write out dirty pages if a zone fills up and so effectively throttle the process. This may decrease the performance of a single process since it cannot use all of system memory to buffer the outgoing writes anymore but it preserve the memory on other nodes so that the performance of other processes running on other nodes will not be affected.</p>
         <p>Allowing regular swap effectively restricts allocations to the local node unless explicitly overridden by memory policies or cpuset configurations.</p>


         <p><b>ulimit -s &lt;n&gt; </b></p>
         <p>
         Sets the stack size to <b>n</b> kbytes, or <b>unlimited</b> to allow the stack size to grow without limit.
         </p>

         <p><b>submit= MYMASK=`printf '0x%x' $((1&lt;&lt;$SPECCOPYNUM))`; /usr/bin/taskset $MYMASK $command </b></p>
         <p>When running multiple copies of benchmarks, the SPEC config file feature
         <b>submit</b> is sometimes used to cause individual jobs to be bound to
         specific processors. This specific submit command is used for Linux.
         The description of the elements of the command are:</p>
         <ul>
         <li><b>/usr/bin/taskset [options] [mask] [pid | command [arg] ... ]</b>: <br/>
         taskset is used to set or retrieve the CPU affinity of a running
         process given its PID or to launch a new COMMAND with a given CPU
         affinity. The CPU affinity is represented as a bitmask, with the
         lowest order bit corresponding to the first logical CPU and highest
         order bit corresponding to the last logical CPU. When the taskset
         returns, it is guaranteed that the given program has been scheduled
         to a legal CPU.<br/>
         The default behavior of taskset is to run a new command with a
         given affinity mask: <br/>
         taskset [mask] [command] [arguments]</li>
         <li><b>$MYMASK</b>: The bitmask (in hexadecimal) corresponding to a specific
         SPECCOPYNUM. For example, $MYMASK value for the first copy of a
         rate run will be 0x00000001, for the second copy of the rate will
         be 0x00000002 etc. Thus, the first copy of the rate run will have a
         CPU affinity of CPU0, the second copy will have the affinity CPU1
         etc.</li>
         <li><b>$command</b>: Program to be started, in this case, the benchmark instance
         to be started.</li>
         </ul>

         <p><b>Using numactl to bind processes and memory to cores</b></p>
         <p>For multi-copy runs or single copy runs on systems with multiple sockets, it is advantageous to bind a process to a particular core. Otherwise, the OS may arbitrarily move your process from one core to another.  This can affect performance.  To help, SPEC allows the use of a "submit" command where users can specify a utility to use to bind processes.  We have found the utility 'numactl' to be the best choice.</p>
         <p>numactl runs processes with a specific NUMA scheduling or memory placement policy.  The policy is set for a command and inherited by all of its children. The numactl flag "--physcpubind" specifies which core(s) to bind the process. "-l" instructs numactl to keep a process memory on the local node while "-m" specifies which node(s) to place a process memory.  For full details on using numactl, please refer to your Linux documentation, 'man numactl'</p>

         <p><b>submit= $[top]/mysubmit.pl $SPECCOPYNUM "$command" </b></p>
         <p> On Xeon 74xx series processors, some benchmarks at peak will run n/2 copies on a system with n logical processors.
         The mysubmit.pl script assigns each copy in such a way that no two copies will share an L2 cache, for optimal performance.
         The script looks in /proc/cpuinfo to come up with the list of cores that will satisfy this requirement.

         The source code is shown below.</p>

         <p><b>Source</b><br />

         ******************************************************************************************************<br /></p>

<pre>

#!/usr/bin/perl
 
use strict;
use Cwd;
 
# The order in which we want copies to be bound to cores
# Copies: 0, 1, 2, 3
# Cores:  0, 1, 3, 6
 
my $rundir        = getcwd;
 
my $copynum = shift @ARGV;

my $i;
my $j;
my $tag;
my $num;
my $core;
my $numofcores; 

my @proc;
my @cores;

open(INPUT, "/proc/cpuinfo") or
   die "can't open /proc/cpuinfo\n"; 

#open(OUTPUT, "STDOUT");

# proc[i][0] = logical processor ID
# proc[i][1] = physical processor ID
# proc[i][2] = core ID

$i = 0;
$numofcores = 0;

while(&lt;INPUT&gt;)
{
  chop;
 
  ($tag, $num) = split(/\s+:\s+/, $_);


  if ($tag eq "processor") {
      $proc[$i][0] = $num;
  }

  if ($tag eq "physical id") {
      $proc[$i][1] = $num;
  }

  if ($tag eq "core id") {
      $proc[$i][2] = $num;
      $i++;
      $numofcores++;
  }
}

$i = 0;
$j = 0;

for $core (0, 4, 2, 1, 5, 3) {
  while ($i &lt; $numofcores) {
     if ($proc[$i][2] == $core) {
        $cores[$j] = $proc[$i][0];
        $j++;
     }
     $i++;
  }
  $i=0;
}

open  RUNCOMMAND, "&gt; runcommand" or die "failed to create run file";
print RUNCOMMAND "cd $rundir\n";
print RUNCOMMAND "@ARGV\n";
close RUNCOMMAND;
system 'taskset', '-c', $cores[$copynum], 'sh', "$rundir/runcommand";

</pre>


  ]]> 
</platform_settings>

</flagsdescription>

