# Wolfram Mathematica ::::::{tab-set} :sync-group: lang :class: lang-tabs :::::{tab-item} En :sync: en Wolfram Mathematica is installed on the cluster, allowing simultaneously: - 100 users or Mathematica or MathKernel processes for control - and 800 Sub Mathematica and Sub MathKernel subprocesses for computation which users can check with the command monitorlm. Users can run Mathematica interactively by first moving to a compute node with `srun --partition=rome --nodes=1 --exclusive --x11 --pty bash -i`, thereby obtaining all local cores. Using Mathematica on the login node prelog is not desirable. Example of starting: ``` bash [user@gpu ~]$ module load Mathematica/13.0.0 [user@gpu ~]$ LD_PRELOAD= srun -N 1 --partition=rome --mem=0 --x11 --pty mathematica Job <3105> is submitted to default queue . ``` If Mathematica asks for activation, select **Other ways to activate** and then **Connect to a network licence server**, for which we enter viz**.hpc**, or prelog.fs.uni-lj.si in the case of installation and use on an FME personal computer (outside HPCFS). FME users can also use the licence server prelog.fs.uni-lj.si for local installations of Mathematica. Since the licence server is restricted to FME IP addresses, exceptions (static home IPs) must be entered manually, or OpenVPN access to prelog must be used. ## Benchmark A Mathematica Mark 8 test was run on one of the nodes, showing the following performance: ![](../files/u3/MathematicaMark8-Report_1.gif) ## Parallel processing If 24 threads per node are not enough, additional nodes can be used via the Parallel preferences setting. Cluster integration with the following settings is recommended: ![](../files/u3/mathematica-lsf.png) In the advanced settings, the Network interface must also be set, since there are several network interfaces on *prelog* and prelog must be correctly selected as the head node (10.0.2.100). The path to the Kernel program must also be corrected, since it wrongly defaults to 7.0 instead of 10.0 for Mathematica 10.0. It is also possible to work on prelog by disabling local kernels or limiting them to one or two processes, and running all others on remote cores. Example: ![](../files/u3/mathematica-kernel-status.png) A larger number of kernels (over 100) can cause problems when establishing remote kernel connections through SLURM (srun), and the whole connection may drop due to a "timeout". Launching kernels gradually rather than all at once (Launch All) is recommended. ## ParallelTable example Parallel processing in Mathematica is done by preparing functions that are then run on several cores. In practice, parallelization can help as soon as we notice that some functions such as Plot take too much time, so we prefer to tabulate them. The following example from plasma physics shows that a single point of the function W already takes a couple of minutes, and we then parallelize the whole function over the desired number of points. ![](../files/figs/hpc/mathematica-ex-pv.png) ::::: :::::{tab-item} Slo :sync: sl **Wolfram Mathematica** Na sestavu je nameščena Wolfram Mathematica, ki omogoča hkratno : - 100 uporabnikov oziroma procesov Mathematica ali MathKernel za nadzor - in 800 podprocesov  Sub Mathematica in Sub MathKernel za računanje kar kahko uporabniki preverijo z ukazom monitorlm. Uporabniki lahko Mathematico poganjajo interaktivno tako, da se najprej preselijo na računsko vozlišče z ukazom `srun --partition=rome --nodes=1 --exclusive --x11 --pty bash -i` in tako pridobijo vsa lokalna jedra. Uporaba mathematice na prijavnem vozlišču prelog ni zažjeljena. Primer zagona: ``` bash [user@gpu ~]$ module load Mathematica/13.0.0 [user@gpu ~]$ LD_PRELOAD= srun -N 1 --partition=rome --mem=0 --x11 --pty mathematica Job <3105> is submitted to default queue . ``` V primeru, da nas Mathematica vpraša za aktivacijo  izberemo **Other ways to activate** in nato **Connect to a network licence server** za katerega napišemo viz**.hpc** ali prelog.fs.uni-lj.si v primeru namestitve in uporabe na osebnem računalniku FS (izven HPCFS). Uporabniki FS lahko uporabijo licenčni strežnik prelog.fs.uni-lj.si tudi za lokalne namestitve Mathematice. Ker je licenčni strežnik omejen na IP številke FS, je potrebno izjeme (domači statični IPji) vnesti ročno ali uporabiti OpenVPN dostop do preloga. ## Primerjalni test Na enem od vozlišč je bil izveden Mathematica Mark 8 test, ki kaže naslednjo zmogljivost: ![](../files/u3/MathematicaMark8-Report_1.gif) ## Paralelno procesiranje Če 24 procesnih niti na vozlišču ne zadošča, lahko uporabimo dodatna vozlišča z nastavitvijo Parallel prreferences. Priporoča se integracija sestava z naslednjimi nastavitvami: ![](../files/u3/mathematica-lsf.png) Pri naprednih nastavitvah je potrebno nastaviti še vmesnik (Network interface) saj na *prelogu* obstaja več mrežnih vmesnikov in je potrebno pravilno izbrati prelog kot head node (10.0.2.100). Popraviti je potrebno tudi pot do Kernel program: saj je napačno privzeto 7.0 namesto 10.0 za Mathematico 10.0. Možno je tudi delo na prelogu tako, da lokalna jedra izklopimo ali omejimo na en proces ali dva, vse ostale pa poganjamo na oddaljenih jedrih. Primer: ![](../files/u3/mathematica-kernel-status.png) Večje število jeder (nad 100) lahko povzroči težave pri vzpostavljanju povezav z oddaljenimi jedri preko SLURM (srun) in se lahko zgodi, da zaradi "timeouta" pade delotna povezava. Priporoča se postopno zaganjanje jeder in ne hkratno (Launch All). ## Primer ParallelTable Paralelno procesiranje v Mathematici je možno tako, da pripravimo funkcije, ki jih nato poženemo na več jedrih. V praksi pa nam je paraleliyacija lahko v pomoč takoj, ko opazimo, da nekatere funkcije kot je Plot vzamejo preveč časa in jih raje tabeliramo. Naslednji primer iz fizike plazme kaže, da že za eno točko funkcije W potrebujemo par minut in nato celotno funkcijo paraleliziramo glede na željeno število točk. ![](../files/figs/hpc/mathematica-ex-pv.png) ::::: ::::::