Use Perl on Pi supercomputer

Buld dependency packages via Spack

$ cd
$ git clone https://github.com/sjtuhpcc/spack.git
$ cd spack
$ ./bootstrap.sh user --install
$ bin/spack install libxml2 %gcc@5.4.0

Add the following settings to ~/.bashrc or ~/.bash_profile.

# Spack package management
if [ -d "$HOME/spack" ]; then
    export SPACK_ROOT=$HOME/spack
    source $SPACK_ROOT/share/spack/setup-env.sh
fi  

Configure CPAN (Comprehensive Perl Archive Network) on Pi

Delete existing CPAN modules if necessray.

$ rm -rf ~/.perl ~/.cpan

Load GCC and Perl modules

$ module use /lustre/usr/modulefiles
$ module load gcc perl
$ which perl
$ /lustre/spack/sandybridge/linux-centos7-x86_64/gcc-5.4.0/perl-5.24.1-h2cm7m4jeltf6yutw7xabngfdttca4mh/bin/perl

Load dependency libraries via Spack

$ source <(spack module loads --dependencies libxml2)

Run CPAN configuration

$ cpan

Add CPAN settings to .bash_profile

Add the following settings to your .bash_profile:

PATH="$HOME/perl5/bin${PATH:+:${PATH}}"
export PATH
PERL5LIB="$HOME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}":$HOME/.perl/modules
export PERL5LIB
PERL_LOCAL_LIB_ROOT="$HOME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"
export PERL_LOCAL_LIB_ROOT
PERL_MB_OPT="--install_base \"$HOME/perl5\""
export PERL_MB_OPT
PERL_MM_OPT="INSTALL_BASE=$HOME/perl5"
export PERL_MM_OPT

Log out then in to make the settings take effects.

Install Perl modules in CPAN

Synosys

$ source <(spack module loads --dependencies libxml2)
$ module use /lustre/usr/modulefiles
$ module load gcc perl
$ cpan
cpan> install MODULE_NAME

Examples

$ module use /lustre/usr/modulefiles
$ module load gcc perl
$ source <(spack module loads --dependencies libxml2)
$ cpan
cpan> install XML::LibXML
...
cpan> install Getopt::Std
...
cpan> install Encode

A SLURM job sample for Perl

Usage: sbatch job.slurm

#!/bin/bash

#SBATCH -J Perl
#SBATCH -p cpu
#SBATCH --mail-type=end
#SBATCH --mail-user=YOU@EMAIL.COM
#SBATCH -o %j.out
#SBATCH -e %j.err
#SBATCH -n 1


source /usr/share/Modules/init/bash
module use /lustre/usr/modulefiles
module purge
module load gcc perl

$ source <(spack module loads --dependencies libxml2)

perl hello.pl

Reference