This page covers Stata from version 14 onwards, which is a multiprocessor (parallel) version of Stata. Versions on the HEC earlier than this are single core (serial), and must be run as serial batch jobs without the -mp suffix.

The HEC currently hosts a 20-user licence for Stata. Starting with version 14 this is the 'MP4' 4-core version, providing up to a 4x speedup for many Stata commands. 

Invoking Stata

To enable access to the current default version, use the following modules command within your batch job script:

module add stata

This will set up your environment to enable access to the current default version of Stata, which may not be the latest version. To instead see the full list of available versions, type: module avail.

Once the chosen module is added, Stata can then be invoked within a job script with the stata-mp command.

More information

 A sample batch job script for Stata

Stata batch jobs may be run by creating a batch job control script (for example, called like the following:

#$ -S /bin/bash

#$ -q parallel
#$ -np 4
#$ -N mystatajob

#$ -l stata=1

source /etc/profile
module add stata

cd $HOME/Stata_files
stata-mp -b do filename

where Stata_files is the subdirectory (if any) containing your Stata input file named which contains the job's input instructions (what you would type on the keyboard if you were running a job interactively).

The inclusion of the line #$ -l stata=1 indicates that the job requires a Stata license. Stata will not run unless a license is requested, and the scheduler is aware of the total license count and will ensure that no more than 20 jobs requesting Stata licenses run concurrently.

The script above is then submitted for running by typing:


 A note on multi-core Stata on the HEC

The following two lines in the above job script:

#$ -q parallel
#$ -np 4

request that the job be run as a 4-core parallel job. Be aware that not all Stata commands show a 4x speedup when run as a 4-core job, as detailed in Statacorp's Stata/MP Performance Guide.

To prevent cores being used inefficiently on jobs that cannot benefit from multicore use, please refer to the Stata documentation and run small scale tests on workloads to determine the real-world speedup. If your workload makes more efficient use of a smaller number of cores, you can change the #$ -np line in your job script to request a lower, more suitable number of cores. Your stata job will be capped automatically at the number of cores requested. When submitted to the serial queue (i.e. as a single core job), stata-mp will be capped to use a single core.

 Migration notes

To ease migration from earlier serial version of Stata to multi-core Stata MP on the HEC, the commands stata and stata-se will invoke stata-mp. In particular, an old stata or stata-se job script submitted to the serial queue but run under Stata MP will do the sane thing: it will run as stata-mp and will be capped to use a single core.

Related pages