3 # Control script for a program that tests shared memory access speeds.
5 # Copyright (C) 2003-2006 IBM
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 # Kill anything in this process group
23 trap 'kill -9 `pgrep -P $$` 2> /dev/null; exit 0' 1 2 15
25 # Try to find ramsnake
26 PROGRAM
="$POUNDER_SRCDIR/ramsnake/snake.exe"
27 if [ -z "$PROGRAM" ]; then
28 echo "Cannot find ramsnake; did you run Install?"
32 # We want enough nodes to consume 1/2 of whatever RAM isn't being used
33 # for programs or buffers. Note that we must divide again by the number
34 # of CPUs in the system so that the _total_ memory used is 1/4.
36 # Does the LONG_BIT config variable really refer to the size
38 MEM_AVAIL
=$
(( `grep ^MemFree: /proc/meminfo | awk -F " " '{print $2}'` + `grep ^Cached: /proc/meminfo | awk -F " " '{print $2}'`))
39 NUM_NODES
=$
(( (MEM_AVAIL
* 1024 / (2 * NR_CPUS
)) / $
((`getconf LONG_BIT` / 8)) ))
41 # Start up a bunch of ramsnakes in the background.
42 for ((k
=0; k
< $NR_CPUS; k
++))
44 "$POUNDER_HOME/timed_loop" 300 "$PROGRAM" -p $NR_CPUS -n $NUM_NODES &
50 # Check for errors while snake runs.
51 while [ `pgrep -P $$ | wc -l` -gt 1 ];
53 NEW_ERRORS
=`egrep -ic "(segmentation|fault|error|illegal)" $LOGFILE`
54 ERRORS
=$
(( NEW_ERRORS
- OLD_ERRORS
))
55 if [ $ERRORS -eq 255 ]; then
59 if [ $ERRORS -gt 0 ]; then
60 echo "Program crash detected. Aborting."
67 # Failures will probably hang the system or segfault snake.