\documentclass[xcolor=dvipsnames]{beamer}

\setbeamertemplate{navigation symbols}{}
% \setbeamertemplate{background}[grid][step=1cm]
\useoutertheme{infolines}
\usecolortheme[named=violet]{structure}
\setbeamertemplate{items}[circle]

\usepackage{tikz}
\usetikzlibrary{arrows,shapes,backgrounds}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{color}
\usepackage{xspace}
\usepackage{hyperref}
\hypersetup{
  pdftitle={LBNE Software and Computing, Update for CAPTAIN Software Workshop}
  pdfauthor={Brett Viren},
  colorlinks=true,
  linkcolor=DarkOrchid,
  urlcolor=DarkOrchid,
}

\newcommand{\app}[1]{\textbf{\textit{#1}}\xspace}
\def\waf{\app{waf}}
\def\hwaf{\app{hwaf}}
\def\worch{\app{worch}}

\author[Brett Viren]{Brett Viren}
\date{November 1, 2013}
\institute[BNL]
{
  Physics Department
  
  \includegraphics[height=1.5cm]{bnl-logo}
}
\title[LBNE S\&C]{LBNE Software and Computing \\
  Update for CAPTAIN Software Workshop}
\begin{document}


\lstset{%
  emphstyle=\color{red},
  keywordstyle=\color{black}\bfseries,
  basicstyle=\footnotesize,
  identifierstyle=\color{DarkOrchid}\ttfamily,
  commentstyle=\color{Brown}\ttfamily,
  stringstyle=\color{blue}\ttfamily,
  showstringspaces=false}

\begin{frame}
  \titlepage
\end{frame}
\begin{frame}
  \frametitle{Contents}

  \tableofcontents

  What I'm up to right now in LBNE:
  \begin{itemize}
  \item Developing the LBNE software installation system.
  \item Steering development of a formal LBNE S\&C requirements document.
  \item Helping the LBNE Physics Tools and S\&C coordinators.
  \item Checking out the CAPTAIN software effort!
  \item Trying hard to not be given an official title....
  \end{itemize}
\end{frame}

\section{LBNE S\&C Organization}

\begin{frame}
  \frametitle{Software and Computing, Project and Collaboration}
  Project-funded and organized part (somewhat limited scope):
  \begin{itemize}
  \item Run-control/slow-control
    \begin{itemize}
    \item Leverage IceCube experience
    \end{itemize}
  \item DAQ
    \begin{itemize}
    \item Leaning towards basing it on artdaq
    \item Will get workout soon with the 35ton prototype detector
    \end{itemize}
  \item Sundry engineering, administrative and ``project'' software.
  \end{itemize}
  Base-funded, collaboration organized (everything else)
  \begin{itemize}
  \item Simulations, data reduction and reconstruction
  \item Data storage and distribution, databases
  \item Production processing, grid computing
  \item Installation, validation
  \item Collaborative tools (FNAL Redmine, mailing lists)
  \end{itemize}
  Focus on the collaboration software and computing $\longrightarrow$
\end{frame}

\begin{frame}
  \frametitle{Current S\&C Org. Chart (WIP)}
  \begin{columns}
    \begin{column}{0.3\paperwidth}
      \footnotesize
      \begin{itemize}
      \item The structure is still being defined and refined.
      \item Very few names have been identified so far.
      \item Doesn't show S\&C Technical Advisory Committee in formation.
      \end{itemize}
    \end{column}
    \begin{column}{0.7\paperwidth}
      \begin{center}
        \includegraphics[width=0.9\textwidth,trim={3cm 10cm 1cm 5cm},clip]{orgchart.pdf}              

        \href{http://lbne2-docdb.fnal.gov:8080/cgi-bin/ShowDocument?docid=7818}{LBNE DocDB 7818}
      \end{center}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}
  \frametitle{The Three Layer Cake of Support}
  \begin{columns}
    \begin{column}{0.4\paperwidth}
      Layered support structure
      \begin{enumerate}
      \item Produce scientific results
      \item Production and verification of analysis tools
      \item Interface with Project and coordinate collaboration S\&C efforts
      \end{enumerate}
    \end{column}
    \begin{column}{0.5\paperwidth}
      \begin{center}
        \rotatebox{-90}{\includegraphics[width=0.4\textwidth,trim={4.8cm 2cm 4cm 6cm},clip]{three-layer-cake.pdf}}

        \footnotesize
        \href{http://lbne2-docdb.fnal.gov:8080/cgi-bin/ShowDocument?docid=7992}{LBNE DocDB 7992}
      \end{center}
    \end{column}
  \end{columns}
  \vspace{1cm}
  These three coordinator roles are spelled out in more detail in \\
 \href{http://lbne2-docdb.fnal.gov:8080/cgi-bin/ShowDocument?docid=6547}{``LBNE Collaboration Organization Document'', DocDB 6547}
\end{frame}

\begin{frame}
  \frametitle{S\&C Requirements Document}
  A recent effort to develop a somewhat formal ``requirements document''

  \begin{description}
  \item[Purpose] 
    \begin{itemize}
    \item Knit together the fledgling S\&C group.
    \item Organize things for ourselves as a collaboration.
    \item Inform DOE.
    \end{itemize}
  \item[Scope] S\&C (not Physics Tools) side of things: Data, Databases, Software, Grid, Production Processing, Geometry, Visualization, Networking,...
  \item[Level] Intended to list high-level needs, not dictate solutions.
  \end{description}

  
  Live document at:
  \begin{description}
  \item[Releases] \href{http://lbne2-docdb.fnal.gov:8080/cgi-bin/ShowDocument?docid=8035}{DocDB 8035}
  \item[Working area] {\footnotesize \url{http://www.phy.bnl.gov/~bviren/lbne/sc/requirements/}}
  \end{description}

\end{frame}

\section{Survey of Existing LBNE Software}
\begin{frame}
\tableofcontents[
currentsection,currentsubsection,
hideothersubsections,sectionstyle=show/shaded,
] 
\end{frame}

\begin{frame}
  \frametitle{Beam Simulation}
  G4LBNE
  \begin{itemize}
  \item Stand-alone Geant4 executable
  \item Largely derived from on G4NUMI (MINOS)
  \item Target, horns, decay pipe, absorber.
  \item Mix of hard-coded C++ and GDML geometry.
  \item \href{https://cdcvs.fnal.gov/redmine/projects/lbne-beamsim}{Redmine/CVS}
    \begin{itemize}
    \item expect to transition to Redmine/git
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Fast MC}
  Fast MC = flux files + GENIE + GLOBES $\rightarrow$ ntuples + plots
  \begin{itemize}
  \item Ties together:
    \begin{itemize}
    \item Flux files
    \item GENIE
    \item GLOBES
    \end{itemize}
  \item \href{https://cdcvs.fnal.gov/redmine/projects/fast_mc/wiki/Fast_MC_Basics}{Redmine/SVN}
    \begin{itemize}
    \item May move to Redmine/git
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Far Detector Simulation and Reconstruction}
  LArSoft:
  \begin{itemize}
  \item Multi-experiment LAr-related code base
  \item Based on art framework
  \item \href{https://cdcvs.fnal.gov/redmine/projects/larsoftsvn}{Redmine/SVN}
    \begin{itemize}
    \item Currently an SRT-based project
    \item Moving to \href{https://cdcvs.fnal.gov/redmine/projects/larsoft-alpha}{Redmine/git} and CMake
    \end{itemize}
  \end{itemize}
  35ton prototype detector studies also being done with LArSoft
\end{frame}

\begin{frame}
  \frametitle{Near Detector Software}

  \begin{itemize}
  \item An initial plan for ``fast'' and ``full'' simulations exists
  \item Effort needs to ramp up here.
  \end{itemize}
\end{frame}

\section{Software Installation System}
\begin{frame}
\tableofcontents[
currentsection,currentsubsection,
hideothersubsections,sectionstyle=show/shaded,
] 
\end{frame}

\begin{frame}[fragile]
  \frametitle{LBNE Software Installation Problem Space}

  \begin{itemize}
  \item Rather large code base: $\sim 40$ externals, $\sim 5$ LBNE sub-suites
    \begin{itemize}
    \item build the build tools: CMake, GCC
    \item usual large HEP packages (Geant4, ROOT, GENIE)
    \item Python, Boost, gccxml, both PostgreSQL and MySQL, ...
    \item A large framework: art + larsoft (+artdaq for online)
    \item LBNE code: FD/ND/Beam/Fast simulation, reco
      \begin{itemize}
      \item[$\rightarrow$] not all groups need (want) all software
      \end{itemize}
    \end{itemize}
  \item Multinational, distributed collaboration, expertise varies
  \item Multiple platforms: at least Sci. Linux, Deb/Ubu, Mac OS X
  \item Require, roughly in order of decreasing importance:
    \begin{enumerate}
    \item Control versions independently from other experiments.
    \item Facilitate any collaborator building all relevant software
      from pristine sources on all supported platforms.
    \item Provide pre-built binaries.
    \end{enumerate}
  \end{itemize}
  But, above all: get the software into the hands of those that can contribute.
\end{frame}

\begin{frame}
  \frametitle{Problem Zero}

  Much of the existing software developed in a mono-culture (@fnal.gov)
  \begin{itemize}
  \item Building and using LBNE software across the entire
    collaboration is ``challenging''.
    \begin{itemize}
    \item Largely has not been possible to this point.
    \end{itemize}
  \item Building LArSoft/art is particularly daunting.
  \item The breadth of LBNE projects presents another challenge.
  \end{itemize}

  $\Rightarrow$ need a ``simple'' and ``user friendly'' way to install all the software. 
\end{frame}

\begin{frame}[fragile]
  \frametitle{Enter \worch}

  The \worch gestalt:

  \begin{itemize}
  \item Insert a layer between user and a package's native build mechanism.
  \item Aggregate required packages into a coherent suite.
  \item Distill all information required to build all packages in a
    suite into a central, human-oriented configuration file (or file set).
  \item Specify desired directory layout for temporary files and final
    install.
  \item Factor common installation patterns into reusable parts.
  \item Generate the commands to execute individual installation steps.
  \item Feed steps and their dependencies to an execution engine (\waf).
  \item Highly automated: initiate a build and go do something else
    productive for several hours.
  \item Leave behind useful information to debug when things go wrong.
  \end{itemize}
  Layers can go on top of \worch to manage suite-wide release issues (eg,
  via worch bundles) and continuous-integration systems.
\end{frame}

\begin{frame}
  \frametitle{High level \worch Design}

  \begin{center}
    \textcolor{blue}{\worch = \textbf{w}af + \textbf{orch}estration}
  \end{center}

  The ``orchestration'' consists of:
  \begin{description}
  \item[configuration] declaring all ``knowledge'' needed to install a
    software suite.
  \item[interpreter] of configuration producing per-package parameters
    and overall suite definition.
  \item[features] batteries-included set of methods driven by these
    parameters to perform \textit{steps} of an installation.
  \end{description}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Example use: ORKA's Geant4/ROOT application}
  \footnotesize
\begin{verbatim}
$ git clone https://github.com/brettviren/worch.git
$ cd worch
$ ./waf --prefix=/path/to/install \
        --orch-config=examples/orka/suite-ilcroot.cfg \
          configure build
...
'build' finished successfully (31m22.537s)
\end{verbatim}
\normalsize
    Builds some 10 externals + the main "ORKA-ILCRoot" app. $\longrightarrow$
\end{frame}

\begin{frame}[fragile]
  \frametitle{Example: ORKA}
  \vspace{-7mm}

  \begin{columns}
    \begin{column}{0.5\textwidth}
      \begin{enumerate}
      \item       cmake
      \item     gccxml
      \item    geant
      \item     geant3vmc
      \item geant4vmc
      \item ilcroot
      \item   pythia
      \item    python
      \item    root
      \item      vgm
      \item       xerces-c
      \end{enumerate}
      {\footnotesize Relatively small project.
        Figure shows build steps and their dependencies.}
    \end{column}
    \begin{column}{0.5\textwidth}
      \includegraphics[height=\textheight]{orka.pdf}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}[fragile]
  \frametitle{\worch Configuration Language}
  \begin{itemize}
  \item Syntax based on Python \texttt{ConfigParser} (aka ``INI'' files)
    \begin{itemize}
    \item Lightly-structured (\textbf{not} YAML/XML'ish)
    \item Purely declarative.
    \item Titled sections holding set of key/value pairs.
    \item No data types, everything is a string.
    \end{itemize}
  \item Interpretation extends this to allow:
    \begin{itemize}
    \item Variable references: \verb|install_dir = {package}-{version}|
    \item Hierarchical data structures via certain key's value
      interpreted to reference another section by its title.
    \item Simple ``\verb|#include|'' mechanism.
    \end{itemize}
  \item \worch adds additional interpretation:
    \begin{itemize}
    \item Feature-specific required variables (with sane defaults)
    \item Relative path resolution
    \item Expression of inter-step dependencies and environment settings.
    \end{itemize}
  \end{itemize}

  Interpretation causes all variables set in a section high in the
  hierarchy to be available, and possibly overridden, in lower-level
  sections.
\end{frame}

\begin{frame}[fragile]
  \frametitle{\worch Package ``features''}
  A \worch package feature is:
  \begin{itemize}
  \item a name in a package's \texttt{features} configuration item
  \item a reusable chunk of code which:
    \begin{itemize}
    \item factors out common, reusable installation steps 
    \item interprets configuration parameters into \waf rules
    \end{itemize}

  \end{itemize}
  Example features:
  \begin{description}
  \item[tarball]  ensures  tar/zip file is downloaded and unpacked
  \item[vcs] as above but from git/cvs/svn/hg repos and based on a tag
  \item[patch] apply a patch file (which may be downloaded)
  \item[prepare] prepare source for building, (also ``autoconf'' and ``cmake'')
  \item[makemake] basically \texttt{make; make install} steps
  \item[\textit{etc}] some specialized features for environment management
    systems (see next), tricky packages or ones lacking native build
    systems (pythia6), pure-Python packages.
  \end{description}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Environment Management}

  End-user environment management with \worch
  \begin{itemize}
  \item No special treatment, support as just another package ``feature''
  \item Produces whatever files required by a particular
    env. mgt. system based on existing \worch configuration
  \item So far, batteries-included for two systems.
  \end{itemize}
  \begin{description}
  \item[Modules] 
    \begin{itemize}
    \item Free Software: {\footnotesize \url{http://modules.sf.net/}}
    \item Creates the (TCL) \texttt{modulefile} directly.
    \end{itemize}
  \item[UPS] 
    \begin{itemize}
    \item FNAL-centric, {\footnotesize \url{http://www.fnal.gov/docs/products/ups/}}
    \item creates UPS ``database'' files w/out requiring UPS itself
      \begin{itemize}
      \item[$\rightarrow$] but \worch can/does build UPS
      \end{itemize}
    \item In-build support for UPS required for building art 
    \end{itemize}
  \end{description}
\end{frame}

\begin{frame}[fragile]
  \frametitle{What is this \waf thing???}

  \waf is at \url{http://code.google.com/p/waf/}
  \begin{itemize}
  \item The name does not mean nor stand for anything
  \item Python (v2.3-v3.1) tool for building build systems
    \begin{itemize}
    \item {\footnotesize (\worch currently tested with 2.6/2.7/3)}
    \end{itemize}
  \item Low-level \texttt{make/autoconf/cmake} replacement or a meta-layer on top.
  \item Configured in Python via ``\texttt{wscript}'' files (think \texttt{Makefile})
  \item Provides a task scheduling and dependency engine.
  \item Has batteries-included for low level build patterns \\
    (C/C++ compilations, library linkage, \LaTeX{}, etc)
  \item Packaged as a single, self-contained, downloaded Python executable
    \begin{itemize}
    \item[$\rightarrow$] can simply include the \waf executable bundle in with the source \\
    {\footnotesize (note: \worch has an additional bundling method:  \waf + \worch + configs)}
    \end{itemize}
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Aside: Synergy with ATLAS}
  ATLAS moving to \waf for build and configuration management
  \begin{itemize}
  \item Replace CMT/LCGCMT with \hwaf and \waf
    \begin{description}
    \item[\hwaf] user command line (Go) executable for setting up
      environment, initiating user analysis packages, building
    \item[\waf] replacing CMT for building experiment packages
    \item[\worch] replacing LCGCMT builders for externals
    \end{description}
  \item Work being done by Sebastien Binet of LAL/IN2P3
    \begin{itemize}
    \item frequent contributor to \worch development
    \end{itemize}
  \end{itemize}
  Once the basic LBNE installation system is working I will look into \hwaf more deeply.
\end{frame}

\begin{frame}[fragile]
  \frametitle{Software Installation Status and Near Future}
  \begin{itemize}
  \item \worch is largely feature complete
    \begin{itemize}
    \item Builds some (non-art) LBNE sub-projects
    \item Used by ORKA for their ROOT/G4-based suite
    \item ATLAS's use for building externals
    \end{itemize}
  \item Building art has been challenging
    \begin{itemize}
    \item easily taken as much effort as all other externals combined
    \item art's native CMake build requires UPS to find dependencies
      \begin{itemize}
      \item would prefer it to use the standard \verb|-DYourExternalDir=/blah|
      \end{itemize}
    \item this means UPS must be built and made available by \worch
      \begin{itemize}
      \item[$\rightarrow$] initially broke part of \worch's model
      \end{itemize}
    \item had to learn many details of UPS (manual can be misleading)
    \item dictates installation layout matches FNAL conventions
    \item[$\rightarrow$] UPS problems solved, now applying to build art itself
    \end{itemize}
  \item LArSoft's move from SVN/SRT to git/CMake in progress, will use the latter
  \item Probably want some novel end-user package management.
    \begin{itemize}
    \item I will look at \hwaf more once we get to this point
    \end{itemize}
  \end{itemize}
\end{frame}

\end{document}
