Updated 2021-05-17
Running Eigen on the Cluster¶
Overview¶
- Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.
- This guide will cover how to run Eigen on the Cluster.
- The example used in this guide comes from this link.
Summary¶
- Load the
eigen/3.2.4
module. - You can now include any of the headers found in Eigen with
#include <Eigen/<Header>>
in your C++ files. - Compile and run your C++ program normally.
Walkthrough: Run Eigen on the Cluster¶
- This walkthrough will run a C++ script that makes Eigen print out its version.
- The C++ script can be found here
- PBS script can be found here
- You can transfer the files to your account on the cluster to follow along. The file transfer guide may be helpful.
Part 1: The PBS Script¶
#PBS -N eigenTest
#PBS -A [Account]
#PBS -l nodes=1:ppn=2
#PBS -l pmem=2gb
#PBS -l walltime=3:00
#PBS -q inferno
#PBS -j oe
#PBS -o eigenTest.out
cd $PBS_O_WORKDIR
module load eigen/3.2.4
g++ eigenTest.cc
./a.out
- The
#PBS
directives are standard, requesting just 3 minutes of walltime and 1 node with 2 cores. More on#PBS
directives can be found in the PBS guide $PBS_O_WORKDIR
is a variable that represents the directory you submit the PBS script from. Make sure the files you want to use are in the same directory you put the PBS script.- Output Files will also show up in this dir as well
module load eigen/3.2.4
loads the 3.2.4 version of Eigen. To see what Eigen versions are available, runmodule avail eigen
, and load the one you want.g++ eigenTest.cc
compiles the C++ program../a.out
runs the C++ program.
Part 2: Submit Job and Check Status¶
- Be sure to change to the directory that contains the
PBS
Script qsub eigenTest.pbs
- Check job status with
qstat -t <jobid>
, replacing the number with the job id returned after running qsub - You can delete the job with
qdel <jobid>
, again replacing the number with the jobid returned after running qsub
Part 3: Collecting Results¶
- In the directory where you submitted the
PBS
script, you should see ameigenTest.out
file which contains the results of the job, aneigenTest.cc
file which contains the C++ code, and ana.out
executable. Usecat eigenTest.out
or open the file in a text editor to take a look. eigenTest.out
should look like this:
---------------------------------------
Begin PBS Prologue Fri Jun 21 15:18:51 EDT 2019
Job ID: 26121138.shared-sched.pace.gatech.edu
User ID: svemuri8
Job name: eigenTest
Queue: inferno
End PBS Prologue Fri Jun 21 15:18:51 EDT 2019
---------------------------------------
Eigen version : 2 . 4
---------------------------------------
Begin PBS Epilogue Fri Jun 21 15:18:51 EDT 2019
Job ID: 26121138.shared-sched.pace.gatech.edu
User ID: svemuri8
Job name: eigenTest
Resources: neednodes=1:ppn=2,nodes=1:ppn=2,pmem=2gb,walltime=00:03:00
Rsrc Used: cput=00:00:00,energy_used=0,mem=0kb,vmem=0kb,walltime=00:00:00
Queue: inferno
Nodes:
rich133-c38-30-l.pace.gatech.edu
End PBS Epilogue Fri Jun 21 15:18:51 EDT 2019
---------------------------------------
- After the result files are produced, you can move the files off the cluster, refer to the file transfer guide for help.
- Congratulations! You successfully ran a C++ Program using Eigen on the cluster.