Running qlua
The command line
qlua [script.qlua | -e 'chunk'] ...
Arguments are processed left to right. A plain argument is a file name and is loaded and run; -e takes the next argument (or the rest of the same one) as a chunk of Lua source and runs that. Execution stops at the first failure: the error and a traceback go to standard error, and the job is aborted with QDP_abort(1) so that every rank goes down together.
Run with no arguments at all, qlua prints the versions of its components and exits successfully. That banner is the quickest check that a binary is a qlua and which one it is:
$ qlua
QLUA component versions:
qlua: f43f7e54d1e86416f5093d833c11ef0509feccbf
lua: f676f113bbb6a4c7d57f05ed6d4efe5adad5dc20
qdp: 415ee9e4c219106e135b48254c7c2f3f7af73279
...
colors: 2 3 N
The same strings are readable from a script as qcd.version.
Under MPI the binary is started by the usual launcher, and every rank runs the same script:
mpirun -np 4 qlua job.qlua
What a script starts with
Beyond the Lua 5.1 standard library (with the changes listed under The core language), a script begins with these globals:
| Name | What it is |
|---|
qcd | the main table: lattices, fields, I/O, solvers, contractions | complex | the complex-number constructor | gamma | the Dirac-algebra constructor | vector | flat arrays of int, real and complex | matrix | dense real and complex matrices (GSL) | gsl | root finding and minimization | openmp | the OpenMP runtime controls | xml | an XML parser and unparser | scripts | the command line, as a list of strings | _rcParam | the run-control parameter table |
scripts[1] is the first argument after the program name, so a script can find its own name and its arguments:
printf("running %s with %d extra arguments\n", scripts[1], #scripts - 1)
require searches ./?.qlua, then the installed library directory, then its lhpc subdirectory, then ./qlib/?.qlua. Setting QLUALIB in the environment replaces that list entirely.
Parallel execution and the master node
Every rank runs the whole script. Most of what follows is collective: it must be reached by every rank, in the same order, with the same arguments. Three consequences are worth keeping in mind.
print prefixes its output with the rank number when the job has more than one rank, so interleaved output can be told apart.- Writers are usually opened on the master node alone and are dummies elsewhere; readers are usually opened everywhere. Each I/O section says which.
- An error raised on one rank and caught with
pcall on that rank only will desynchronize the job. Catch collectively or not at all.
qcd.barrier() is the explicit synchronization point; os.node() and qcd.network() report where a rank sits.
|