%* installation (deps, build/install procedure, making module/ml work)
%* configuration (either via ./configure at build time, or via
%   $LMOD_FOO), most important configure options
%* setting up the system spider cache: configuring Lmod, updating spider
%  cache, difference between system/user spider cache
%* + all (other) aspects mentioned on slide #26 in this slide deck:
%   explained + example :)
%* what settarg is all about

\documentclass{beamer}

\usetheme[headernav]{TACC} %%Drop the 'headernav' if you don't like
                           %%the stuff at the top of your slide

\usepackage{amsmath,amssymb,amsthm}
\usepackage{alltt}
\usepackage{graphicx}

\title{Transitioning to Lmod}


\author{Robert McLay}
\institute{The Texas Advanced Computing Center}

\date{January 28, 2014}  %% Use this if you want to fix the date in
                        %% stone rather than use \today

\newcommand{\bfnabla}{\mbox{\boldmath$\nabla$}}
\newcommand{\laplacian}[1]{\bfnabla^2 #1}
\newcommand{\grad}[1]{\bfnabla #1}
\newcommand{\tgrad}[1]{\bfnabla^T #1}
\newcommand{\dvg}[1]{\bfnabla \cdot #1}
\newcommand{\curl}[1]{\bfnabla \times #1}
\newcommand{\lap}[1]{\bfnabla^2 #1}

\begin{document}

\begin{frame}
  \titlepage
\end{frame}

\section{Introduction}

\begin{frame}{Transitioning to Lmod}
  \begin{itemize}
    \item What does Lmod offer?
    \item A transition strategy
    \item New features
  \end{itemize}
\end{frame}


\begin{frame}{Why You Might Want To Switch}
  \begin{itemize}
    \item Active Development;  Frequent Releases; Bug fixes.
    \item Vibrant Community
    \item It is used from Norway to Isreal to New Zealand from Stanford to MIT to NASA
    \item Enjoy many capabilities w/o changing a single module file
    \item Debian and Fedora packages available
    \item Many more advantages when you're ready
  \end{itemize}
\end{frame}

\begin{frame}{Features requiring no changes to modulefiles}
  \begin{itemize}
    \item Reads TCL modulefiles directly (Cray modules supported)
    \item User default and named collections of modules
    \item Module cache system: Faster avail, spider, etc
    \item Tracking module usage
    \item A few edge cases where Env. Modules and Lmod differ
  \end{itemize}
\end{frame}

\begin{frame}{Features of Lmod with small changes to modulefiles}
  \begin{itemize}
    \item Family function: Prevent users from loading two compilers at
      the same time (experts can override)
    \item Properties: (MIC-aware, Beta, etc)
    \item Sticky modules
    \item ...
  \end{itemize}
\end{frame}

\begin{frame}{Lmod supports a software hierarchy}
  \begin{itemize}
    \item Lmod supports flat layout of modules
    \item Some really cool features if you have a software hierarchy
      \begin{itemize}
        \item Protecting users from mismatched modules
        \item Auto Swapping of Compiler and MPI dependent modules
      \end{itemize}
    \item When you are ready, it will be there
  \end{itemize}
\end{frame}

\section{A Transition Strategy}

\begin{frame}{A Transition Strategy}
  \begin{itemize}
    \item Install Lmod in your account
    \item Staff \& Friendly Opt-in Testing
    \item Deploy to your users with an Opt-out choice
    \item Some users can run TCL/C modules
    \item Others can run Lmod
    \item No single user can run both at the same time!
  \end{itemize}
\end{frame}

\begin{frame}{Personal Testing of Lmod}
  \begin{itemize}
    \item Install it in your account
      \begin{itemize}
        \item Take current list and remove in reverse order to find
          required modules
        \item LMOD\_SYSTEM\_DEFAULT\_MODULES=mod1:mod2:mod3
        \item \texttt{\bf \$ module purge;}
        \item Redefine module command to use Lmod
        \item \texttt{\bf \$ module restore;}
      \end{itemize}
    \item I normally run a personal copy of Lmod in all my accounts
      (including \texttt{\bf darter}, a Cray XC-30)
    \item Test, build a spider cache, module avail
    \item Module collections, ...
  \end{itemize}
\end{frame}

\begin{frame}{Staff \& Friendly User Testing}
  \begin{itemize}
    \item Install Lmod in system location.
    \item Install \emph{/etc/profile.d/z00\_lmod.sh} to redefine the
      \texttt{\bf module} cmd.
    \item Load system  default modules (if any) after previous step
    \item Users who have a file named \texttt{$\sim$/.lmod} use Lmod
    \item At TACC we did this for 6 months
  \end{itemize}
\end{frame}

\begin{frame}{Deploy}
  \begin{itemize}
    \item When you are ready, change \emph{/etc/profile.d/z00\_lmod.sh}
    \item Users can opt-out
    \item We supported this for another 6 months
    \item We broke Env. Module support when we added the family function
    \item Both transitions generated very few tickets (2 + 2)
  \end{itemize}
\end{frame}

\begin{frame}{For those who can't type: ``\texttt{ml}''}
  \begin{itemize}
    \item \texttt{ml} is a wrapper:
      \begin{itemize}
        \item With no argument: \texttt{ml} means \texttt{module list}
        \item With a module name: \texttt{ml foo} means \texttt{module
            load foo}.
        \item With a module command: \texttt{ml spider} means
          \texttt{module spider}.
      \end{itemize}
    \item See \texttt{ml --help} for more documentation.
  \end{itemize}
\end{frame}

\section{Hierarchical Module layout}

\begin{frame}[fragile]
    \frametitle{Example of Lmod (I)}
    {\tiny
\begin{alltt}
\$ {\color{blue} module avail}
------------------ /opt/apps/modulefiles/MPI/intel/12.0/mpich2/1.4 ------------------
  petsc/3.1 (default)    petsc/3.1-debug    pmetis/4.0    tau/2.20.3

------------------- /opt/apps/modulefiles/Compiler/intel/12.0 -----------------------
  boost/1.45.0              gotoblas2/1.13          openmpi/1.4.3
  boost/1.46.0              mpich2/1.3.2            openmpi/1.5.1
  boost/1.46.1 (default)    mpich2/1.4 (default)    openmpi/1.5.3 (default)

-------------------------- /opt/apps/modulefiles/Core -------------------------------
  StdEnv               intel/11.1               papi/4.1.4
  admin/admin-1.0      intel/12.0 (default)     scite/2.28
  ddt/ddt              lmod/lmod                tex/2010
  dmalloc/dmalloc      local/local (default)    unix/unix (default)
  fdepend/1.2          mkl/mkl                  visit/visit
  gcc/4.4              noweb/2.11b
  gcc/4.5 (default)
\end{alltt}
    }
\end{frame}

\begin{frame}[fragile]
    \frametitle{Example of Lmod (II)}
    {\tiny
\begin{alltt}
{\color{blue}\$ module list}
    Currently Loaded Modules:
      1) StdEnv  2) gcc/4.5  3) mpich2/1.4  4) petsc/3.1
{\color{blue}\$ module unload gcc}
    Inactive Modules:
      1) mpich2  2) petsc
{\color{blue}\$ module list}
    Currently Loaded Modules:
      1) StdEnv
    Inactive Modules:
      1) mpich2  2) petsc
{\color{blue}\$ module load intel}
    Activating Modules:
      1) mpich2  2) petsc
{\color{blue}\$ module swap intel gcc}
    Due to MODULEPATH changes the follow modules have been reloaded:
      1) mpich2  2) petsc
\end{alltt}
    }
\end{frame}

\begin{frame}{module avail vs. module spider}
  \begin{itemize}
     \item Can't show every module with \texttt{\bf module avail}
     \item Lmod added the command \texttt{\bf module spider} to walk
       the tree.
  \end{itemize}
\end{frame}
\begin{frame}[fragile]
    \frametitle{Module Proprieties (I)}
  \begin{itemize}
    \item Modules can have properties
    \item At TACC, we have MIC, and GPU accelerators.
    \item Some libraries are MIC aware.
    {\small
\begin{verbatim}
    add_property("arch","mic")
\end{verbatim}
}
    \item This is controlled by the table in lmodrc.lua
  \end{itemize}
\end{frame}

\begin{frame}[fragile]
    \frametitle{Module Properties (II)}
  \begin{itemize}
    \item Some modules will be ``MIC'' aware: mkl, fftw3, phdf5, ...
    \item Lmod will decorate these modules:
  {\tiny
    \begin{alltt}
  1) unix/unix     3) ddt/ddt       5) mpich2/1.5    7) phdf5/1.8.9 {\color{blue}(m)}
  2) intel/13.0    4) mkl/mkl {\color{red}(*)}   6) petsc/3.2     8) StdEnv

  Where:
   {\color{blue}(m)}:  module is build natively for MIC
   {\color{red}(*)}:  module is build natively for MIC and offload to the MIC

   ------
   add_property("arch","mic")              -- > phdf5
   add_property("arch","mic:offload")      -- > mkl
    \end{alltt}
}
  \item What properties would you like to support?
  \end{itemize}
\end{frame}

\begin{frame}{Spider Cache}
  \begin{itemize}
      \item Modulefiles can have properties
      \item Want to show properties with \texttt{\bf module avail}
      \item Ugh! \emph{Must read all modulefiles}
      \item Faster to read one file than walk a directory tree.
      \item Spider cache was created.
  \end{itemize}
\end{frame}

\begin{frame}{Spider Cache (II)}
  \begin{itemize}
     \item Good News: having a spider cache speeds avail, spider
     \item Bad News: Sites must maintain up-to-date cache file.
     \item Lmod trusts valid system caches for avail and spider.
     \item Two kinds of caches: User \& System
  \end{itemize}
\end{frame}

\begin{frame}{User spider cache file}
  \begin{itemize}
     \item Used if no system cache is available.
     \item Written when it takes more than 2 seconds to build
     \item Valid for 24 hours.
     \item Rare if system caches exist.
  \end{itemize}
\end{frame}

\begin{frame}{System spider cache file}
  \begin{itemize}
     \item Sites can have one or more cache files.
     \item A shared file system $\Rightarrow$ One
       per system
     \item At TACC:
       \begin{itemize}
          \item Each nodes creates a local system cache
          \item Master
       \end{itemize}
  \end{itemize}
\end{frame}


\section{Design ideas behind Lmod \& Settarg}

\begin{frame}{The Design ideas behind Lmod}
  \begin{itemize}
     \item Lmod has been design to make me happy!
     \item It is fast, predictable and powerful.
     \item Action happen with minimal typing:
       \begin{itemize}
          \item ml
          \item well chosen defaults.
          \item Hierarchical module layout
          \item tab-completion
          \item never use ``\texttt{\bf swap}''
          \item don't use category/name/version.
       \end{itemize}
  \end{itemize}
\end{frame}


\begin{frame}{What are the implications?}
  \begin{itemize}
     \item Fast typing of commands
     \item Use of versions is rare.
     \item Strong use of autoswapping in three ways:
       \begin{itemize}
          \item Auto swapping of the same name: ml zlib
          \item Swapping of dependent modules MPI, PETSc, etc
          \item Autoswapping of compilers, mpi stacks.
       \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}{Numerical Software development (by me!)}
  \begin{itemize}
    \item change between debug, optimize, builds
    \item change compilers, mpi stacks, solvers, etc
    \item No ``make clean'' required when changing any of the above
    \item Make it ease to compare and contrast two different builds
    \item Integrated with module system
    \item Easy to know the state
  \end{itemize}
\end{frame}

\begin{frame}{Settarg}
  \begin{itemize}
     \item TARG: A family of environment variables that describe the
       build environment.
     \item Makefile can use those variables to control the build.
     \item Title Bar reports state of TARG
     \item PATH updated automatically: PATH=./\$TARG:\$PATH
  \end{itemize}
\end{frame}

\begin{frame}[fragile]
    \frametitle {settarg}
    \begin{itemize}
      \item Provides safety, flexibility and repeatability in a dynamic environment.
      \item Dynamically updates the state when modules change:
        {\small
          \begin{alltt}
    \$ {\color{red} env | grep '^TARG'}
    {\color{blue}TARG_BUILD_SCENARIO=dbg
    TARG=OBJ/_x86_64_dbg_gcc-4.6_mpich-3.0
    TARG_MPI_FAMILY=mpich
    TARG_MPI=mpich-3.0}
    \${\color{red} module swap mpich openmpi; opt; env | grep '^TARG'}
    {\color{blue}TARG_BUILD_SCENARIO=opt
    TARG=OBJ/_x86_64_opt_gcc-4.6_openmpi-1.6
    TARG_MPI=openmpi-1.6
    TARG_MPI_FAMILY=openmpi}
          \end{alltt}
          }
      \end{itemize}
\end{frame}

\begin{frame}[fragile]
    \frametitle {settarg (II)}
    \begin{itemize}
      \item Typically TARG is OBJ/\$ARCH\_\$SCENARIO\_\$CMPLR\_\$MPI
      \item \texttt{TARG=OBJ/\_x86\_64\_dbg\_gcc-4.6\_mpich-3.0}
      \item User can extend this with user level or directory level
        specialization.
      \item \texttt{OBJ/\_x86\_64\_dbg\_intel-14.0\_mpich-3.0\_petsc-3.4}
      \item A makefile can modified to write generated file into \$TARG.
      \item Never need to ``\texttt{make clobber}'' when switching
        scenario, compiler, etc.
      \end{itemize}
\end{frame}

% Notes on settarg:
% * It is my world and I just let you live in it. (;->)
% * Lmod and settarg and ml are designed to be fast and interactive.
%   It is minimal typing to achieve my goals.
% * It is a well designed module system where user can use the
%   defaults and not type in versions.
% * I change between dbg and opt builds frequently.
% * I also change between gcc and intel compiler frequently.
%   C++ error msgs can be hard to understand.  Sometimes the other
%   compiler says something to me that the other did not.
% * I tend to debug with gcc and run with intel.
% * So switching between compilers and dbg/opt build need to be
%   easy and fast.
% * Settarg also needs to know if certain modules are loaded:
%      compiler, mpi, solvers etc.
% * Settarg does these things:
% ** Reads the state of the modules
% ** Builds the TARG and the TARG family of env vars.
% ** changes the path.
% ** changes the title bar in an xterm.


\section{What's new in Lmod}

\begin{frame}{What's new in Lmod}
  \begin{itemize}
      \item Full support for reading Cray module files.
      \item Better support for running Lmod on shared home file systems.
      \item Priority Path: Some paths are more equal than others.
      \item \texttt{\bf sh\_to\_modulefile} converts shell scripts into modulefiles.
      \item Support for \texttt{\bf load(atleast("gcc","4.8"))}
  \end{itemize}
\end{frame}

\begin{frame}{Auto swap}
  \begin{itemize}
      \item An improvement suggested by Maxime Boissonneault.
      \item Replace \texttt{\bf module load gcc; module swap gcc intel}
      \item With \texttt{\bf module load gcc; module load intel}
      \item Let Lmod figure out that a swap is required and do it for you!
  \end{itemize}
\end{frame}




\end{document}
