-
Notifications
You must be signed in to change notification settings - Fork 2
Appendix: Convenient scripts to run a computation in pfd parallel
To run examples repeatedly, it can be useful to create a Singular script and a couple of shell scripts. This is described in the following, again at the above example.
We start out by creating a Singular script. It will loads the pfd_gspc.lib
library. A GPI-Space configure token is prepared, with the
configuration: The path of a temporary directory, where files will be stored
during the computation and handling of the various files at runtime, the
location of a nodefile, containing a location on then network where GPI-Space is
installed, the number of processes each node should run in parallel, the address
of a running instance of the GPI-Space monitoring tool, as well as the port on
which the monitoring tool is listening (note, the framework can be run without the
monitoring tool, in which case the corresponding entries should remain unset). Next,
the ring in which the numerators and denominators of the rational functions are contained is
declared. The input of the computation is specified in terms of files, referenced by the
row and column index in a matrix where it must be found, in the form
<basename>_<row>_<col>.(txt|ssi)
, where the suffix is txt if the file is in
plain text format, and ssi if the input files are in this high-performence binary format
used by Singular. In the text format input files, the
coordinates of the matrix entries to be calculated are given in a list of lists.
Finally, all the tokens and index pairs are provided to the parallel_pfd
function as arguments,
preferably with an optional argument for the path to where the input files are
found. The user may also provide in a separate argument the path of where the
output files should be written.
For the examples below, the user needs to set the following environment variables providing the software root and input and output directories:
export PFD_ROOT=$software_ROOT
export PFD_INPUT_DIR=$software_ROOT/input
export PFD_OUTPUT_DIR=$software_ROOT/results
An example script test_parallel_pfd.sing
in Singular for a 1 by 10 matrix is created as follows:
mkdir -p $PFD_ROOT/tempdir
hostname > $PFD_ROOT/nodefile
hostname > $PFD_ROOT/loghostfile
cat > test_parallel_pfd.sing.temp << "EOF"
LIB "pfd_gspc.lib";
// configuration for gpispace
configToken gspcconfig = configure_gspc();
gspcconfig.options.tempdir = "$PFD_ROOT/tempdir";
gspcconfig.options.nodefile = "$PFD_ROOT/nodefile";
gspcconfig.options.procspernode = 8;
// Should the user want to run withouth the gspc-monitor
// the following two lines may be commented out.
gspcconfig.options.loghostfile = "$PFD_ROOT/loghostfile";
gspcconfig.options.logport = 6439;
// configuration for the problem to be computed.
configToken pfdconfig = configure_pfd();
pfdconfig.options.filename = "xb_deg5";
pfdconfig.options.inputdir = "$PFD_INPUT_DIR";
pfdconfig.options.outputdir = "$PFD_OUTPUT_DIR";
pfdconfig.options.parallelism = "intertwined";
ring r = 0, x, lp;
list entries = list( list(1, 1), list(1, 2), list(1, 3), list(1, 4)
, list(1, 5), list(1, 6), list(1, 7), list(1, 8)
, list(1, 9), list(1, 10)
);
parallel_pfd( entries
, gspcconfig
, pfdconfig
);
exit;
EOF
We expand the environment variables in the script created above using the following script:
cat > shell_expand_script.sh << "EOF"
echo 'cat <<END_OF_TEXT' > temp.sh
cat "$1" >> temp.sh
echo 'END_OF_TEXT' >> temp.sh
bash temp.sh >> "$2"
rm temp.sh
EOF
chmod a+x shell_expand_script.sh
./shell_expand_script.sh test_parallel_pfd.sing.temp test_parallel_pfd.sing
Next, we create a script to start the graphical GPI-Space monitor displaying a Gant diagram of the computation.
Note that if you do not want to use the monitor, you can skip these steps, but have to comment out the respective lines in the script test_parallel_pfd.sing
.
cat > start_monitor.sh << "EOF"
#!/bin/bash
set -euo pipefail
# raster or native (native for X forwarding)
QT_DEBUG_PLUGINS=0 \
QT_GRAPHICSSYSTEM=native \
$PFD_INSTALL_DIR/libexec/bundle/gpispace/bin/gspc-monitor \
--port 6439 &
EOF
chmod a+x start_monitor.sh
It can be run as
./start_monitor.sh
Make sure that the --port
number matches the one set in the singular script.
Also, if this is run over ssh on a remote machine, make sure that x forwarding
is enabled.
Create the input files:
mkdir -p $PFD_INPUT_DIR
mkdir -p $PFD_OUTPUT_DIR
cp -v $PFD_INSTALL_DIR/example_data/* $PFD_INPUT_DIR
Finally, the test may be run with the script
cat > run_pfd_example.sh << "EOF"
SINGULARPATH="$PFD_INSTALL_DIR/LIB" \
$SINGULAR_INSTALL_DIR/bin/Singular \
test_parallel_pfd.sing
EOF
chmod a+x run_pfd_example.sh
which can be started with
./run_pfd_example.sh
Note, to run the same computation, but without the internal parallelism on each
entry, the parallelism
field in the pfdconfig
tokens options
field may be changed to
waitAll
.