GridMathematica
Obsah
Description
GridMathematica is an integrated extension system for increasing the power of your Mathematica licenses. Each gridMathematica Server gives Mathematica users a shared pool of 16 additional networkenabled Mathematica computation kernels for running distributed parallel computations over multiple CPUs.
There is no need to change your existing parallel code—just make gridMathematica Server available, and parallel programs can automatically use the additional CPU power.
Availability
Available versions:
 gridMathematica version 11: module
gridmathematica11
 gridMathematica version 9: module
gridmathematica9
 the gridMathematica version 9 could be used (together with our Mathematica licenses) by all the MetaVO users.
 the gridMathematica version 9 License Aggreement currently restricts the usage of gridMathematica in MetaCentrum just on the members (students, staff) of the following universities:
 ČVUT+VŠCHT  Czech Technical University in Prague and Institute of Chemical Technology in Prague
 UK  Charles University in Prague
 UTB  Tomas Bata University in Zlin
 JCU  University of South Bohemia in Ceske Budejovice
 VŠB  VŠBTechnical University of Ostrava
To allow an access for another academic institutions/universities, it is necessary for them to purchase/rent the Wolfram Mathematica product with an appropriate (Mathematica Site Unlimited) license. If you intend to be allowed to use MetaCentrum's gridMathematica, enabling you to perform more complex computations within Mathematica, please, let us know before the actual purchase/rent.
License
We've rented 15 licenses of gridMathematica  each of the licenses enables you to extend the computational power of Mathematica by 16 computational kernels (i.e., you are allowed to use up to 240 kernels in total).
Usage
Since MetaCentrum does not feature any licence for Wolfram Mathematica controlling kernels, it is possible to use the provided Wolfram gridMathematica just in the following two modes:
 Interactive use, using which you run your copy of the Wolfram Mathematica (with a licence of your home institution) and instruct it to connect to remote computational kernels (Wolfram gridMathematica) running within the MetaCentrum infrastructure (these will be licensed by the MetaCentrum license server).
 Batch use, using which you have to make the license server of your home institution accessible from the MetaCentrum computational nodes. Once being started, the Wolfram Mathematica then asks your license server to obtain a license for its controlling kernel; the licenses for the computational kernels will be obtained from the MetaCentrum license server.
Note: The users, whose home institutions do have the Wolfram Mathematica already installed within the MetaCentrum infrastructure (e.g., University of South Bohemia  JČU), canonce having the relevant module loaded (e.g., mathematica9jcu
)use both the presented methods automatically without any further configuration.
The usage of parallel/distributed processing in interactive mode is briefly illustrated in the presentation video.

Interactive use
Since the Mathematica 9 currently does not support the scheduling system we employ (Torque), which could prepare a set of required computational kernels (MathKernels) for your remote computations in a comfortable and transparent fashion, we have prepared a script "mathgrid
", which makes the remote computational kernels' configuration and setup (otherwise ponderous) as comfortable and easy to use as possible. This script starts the computational kernels at first, and subsequently provides you with a set of commands, which (after being run within your Mathematica frontend) instruct your controlling kernel to easily connect to and use the previously started remote computational kernels. This approach further allows you to connect to the computational kernels from "hostile" environments (behind firewalls, NAT, etc.) as well as from Mathematica being run on Windows OS without a necessity to have passwordless RSH/SSH configured.
Startup steps (depicted in the presentation video as well):
 Using a MetaCentrum frontend, ask for an interactive job specifying the number of nodes/processors you want to use, and the availability of the gridMathematica license:
qsub I l nodes=X:ppn=Y:... l gridmath9=Z # the request asks for X nodes, each of them with Y processors
# Z ... the number of Mathematica Grid servers required for your job (generally, Z=X*Y)
 Subsequently, prepare all the information necessary to connect to the remote computational kernels:
 using the interactive job console, run the following set of commands:
module add gridmathematica9
## OR use
# module add mathematica9XXX ## JUST in cases the module for your institution (XXX) exists
# start the computational kernels
mathgrid start # for more details, see: mathgrid help
 copy the output of the mathgrid command into a clipboard
 Start your local Mathematica (
Mathematica
command for GUI frontend, ormath
command for a commandline frontend) and open a new worksheet (notebook) if your home institution does allow to start the Mathematica on the MetaCentrum nodes (i.e., there is a module dedicated for your institution  e.g., the "mathematica9jcu" module for the University of South Bohemia  see Mathematica), or you have performed an explicit configuration of the license server of your home institution (see below), you can start the controlling Mathematica process (i.e., Mathematica frontend) directly from the established interactive job (and subsequently instruct the controlling process to connect to the started gridMathematica computational kernels).
 Copy the output of the mathgrid command (mentioned above) into the notebook and press SHIFT+ENTER
 Once the commands become executed, there are all the required remote computational kernels prepared for your computations.
 The list of running computational processes/kernels can be obtained by entering the Kernels[] command into the Mathematica worksheet
 To check the functionality of parallel processing, enter the following command into the Mathematica's worksheet (and confirm by pressing SHIFT+ENTER):
TableForm[
ParallelEvaluate[{$KernelID, $MachineName, $SystemID, $ProcessID, $Version}],
TableHeadings > {None,{"ID","host","OS","process","Mathematica Version"}}]
 Once finished, do not forget to stop the running kernels (command CloseKernels[]) and subsequently to stop the interactive job.
Batch use
As mentioned above, to allow the batch computations using the provided Wolfram gridMathematica, there is a necessity to obtain a licence for the Wolfram Mathematica controlling process (i.e., the frontend). If your home institution does allow to start the Mathematica on the MetaCentrum nodes (i.e., there is a module dedicated for your institution  e.g., the "mathematica9jcu
" module for the University of South Bohemia), this license is available automatically for you. OTHERWISE, you have to perform an explicit configuration to make the Mathematica controlling process asking for a license the license server that is legally available for you (see the following section).
How to configure Mathematica controlling kernels to use a specific license server:
 in the Mathematica configuration directory (located in your home directory), create a file
$HOME/.Mathematica/Licensing/mathpass
, which will contain an identification of your home institution's license server:
echo '!mylicenseserver.somewhere.cz' >$HOME/.Mathematica/Licensing/mathpass
 Note: The "!" character is essential for a correct server identification.
 we suggest you to make this file unreadable for anybody else except you:
chmod go= $HOME/.Mathematica/Licensing/mathpass
Startup steps:
 Copy the Mathematica's worksheet containing the intended computation (file *.nb) to a MetaCentrum frontend (and save it to a shared filesystem, for example)
 Insert the following lines, performing an initialization and releasing of parallel environment at computational nodes, at the beginning/end of your file:
<< "! mathgrid start"
... Your parallel computation ...
CloseKernels[]
 see the example file example.nb
 Subseqently, prepare a startup script for your job (named, e.g., startup_script.sh):
#!/bin/bash
# module add mathematica9 ## use JUST in cases you have explicitely configured a license server in your $HOME
# module add mathematica9XXX ## use JUST in cases the module for your institution (XXX) exists
module add gridmathematica9
math run <path_to_your_Mathematica_file
# ALTERNATIVELY (without implicit outputs): math script path_to_your_Mathematica_file
 Submit the startup script together with a specification of requested resources (number of computational nodes/processors) and gridMathematica license availability:
qsub l nodes=X:ppn=Y:... l gridmath9=Z startup_script.sh # request for X nodes, each of them with Y processors
# Z ... the number of Mathematica Grid servers required for your job (generally, Z=X*Y)
Documentation
Program administrator
Tomáš Rebok (rebok at ics.muni.cz)
Useful hints
Using gridMathematica for parallel runs of computations
 for example, if you have a serial computation, which you want to be run multiple times in parallel (based on the available cores), create a common masterslave computation as follows:
 the slave script will perform the computation
 the master script will run the slave script on all the available cores, using the ParallelEvaluate function
 example of such a computation is available for download HERE
Useful links
 Mathematica and Maple comparison: http://www.wolfram.com/mathematica/comparemathematica/comparemathematicaandmaple.html
Note.: If you have some tips for useful Mathematicarelated pages, please, let us know...