You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ALP_Transition_Path_Tutorial.tex
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
-
\section{Introduction to ALP and Transition Paths}\label{sec:intro}
1
+
\section{ALP Transition Paths}\label{sec:intro}
2
2
3
3
\textbf{Algebraic Programming (ALP)} is a C++ framework for high-performance linear algebra that can auto-parallelize and auto-optimize your code. A key feature of ALP is its transition path APIs, which let you use ALP through standard interfaces without changing your existing code. In practice, ALP generates drop-in replacements for established linear algebra APIs. You simply re-link your program against ALP's libraries to get optimized performance (no code modifications needed). ALP v0.8 provides transition-path libraries for several standards, including the NIST Sparse BLAS and a CRS-based iterative solver interface (ALP/Solver). This means you can take an existing C/C++ program that uses a supported API and benefit from ALP's optimizations (such as vectorization and parallelism) just by linking with ALP's libraries [1].
4
4
5
5
One of these transition paths, and the focus of this tutorial, is ALP's \textbf{sparse Conjugate Gradient (CG) solver}. This CG solver accepts matrices in Compressed Row Storage (CRS) format (also known as CSR) and solves $Ax=b$ using an iterative method. Under the hood it leverages ALP's non-blocking execution model, which overlaps computations and memory operations for efficiency. From the user's perspective, however, the solver is accessed via a simple C-style API that feels synchronous. In this workshop, we'll learn how to use this CG solver interface step by step: from setting up ALP, to coding a solution for a small linear system, to building and running the program.
6
6
7
-
\section{Setup: Installing ALP and Preparing to Use the Solver}\label{sec:setup}
7
+
\subsection{Setup: Installing ALP and Preparing to Use the Solver}\label{sec:setup}
8
8
9
9
This section explains how to install ALP on a Linux system and compile a simple example. ALP (Algebraic Programming) provides a C++17 library implementing the GraphBLAS interface for linear-algebra-based computations.
10
10
11
-
\subsection{Installation on Linux}
11
+
\subsubsection*{Installation on Linux}
12
12
13
13
\begin{enumerate}
14
14
\item Install prerequisites: Ensure you have a C++11 compatible compiler (e.g. \texttt{g++} 4.8.2 or later) with OpenMP support, CMake (>= 3.13) and GNU Make, plus development headers for libNUMA and POSIX threads.
@@ -67,7 +67,7 @@ \subsection{Installation on Linux}
67
67
(ALP's documentation provides details on which libraries to link for each backend [3].) Using grbcxx is recommended for simplicity, but it's good to know what happens under the hood. Now that our environment is set up, let's look at the CG solver API.
68
68
69
69
70
-
\section{Overview of ALP's Non-Blocking Sparse CG API}\label{sec:api}
70
+
\subsection{Overview of ALP's Non-Blocking Sparse CG API}\label{sec:api}
71
71
72
72
The ALP/Solver transition path provides a C-style interface for initializing and running a Conjugate Gradient solver. All functions are exposed via a header (e.g. solver.h in ALP's include directory) and use simple types like pointers and handles. The main functions in this API are:
This API is non-blocking in the sense that internally ALP may overlap operations (like sparse matrix-vector multiplications and vector updates) and use asynchronous execution for performance. However, the above functions themselves appear synchronous. For example, sparse\_cg\_solve will only return after the solve is complete (there’s no separate “wait” call exposed in this C interface). The benefit of ALP’s approach is that you, the developer, don’t need to manage threads or message passing at all. ALP’s GraphBLAS engine handles parallelism behind the scenes. You just call these routines as you would any standard library. Now, let’s put these functions into practice with a concrete example.
85
85
86
86
87
-
\section{Example: Solving a Linear System with ALP’s CG Solver}
87
+
\subsection{Example: Solving a Linear System with ALP’s CG Solver}
88
88
89
89
Suppose we want to solve a small system $Ax = b$ to familiarize ourselves with the CG interface. We will use the following $3\times3$ symmetric positive-definite matrix $A$: $$ A = \begin{pmatrix} 4 & 1 & 0\\
Copy file name to clipboardExpand all lines: ALP_Tutorial.tex
+4-5Lines changed: 4 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -663,13 +663,11 @@ \section{Solution to Exercise 8}\label{sec:simple_example}
663
663
$
664
664
\end{lstlisting}
665
665
666
-
667
-
668
-
\section{Makefile and CMake Instructions}\label{sec:build_instructions}
666
+
\subsection{Makefile and CMake Instructions}\label{sec:build_instructions}
669
667
670
668
Finally, we provide guidance on compiling and running the above example in your own development environment. If you followed the installation steps and used \texttt{grbcxx}, compilation is straightforward. Here we outline two approaches: using the ALP wrapper scripts, and integrating ALP manually via a build system.
671
669
672
-
\subsection*{Using the ALP compiler wrapper}
670
+
\subsubsection*{Using the ALP compiler wrapper}
673
671
674
672
The simplest way to compile your ALP-based program is to use the provided wrapper. After sourcing the ALP environment (setenv script), the commands \texttt{grbcxx} and \texttt{grbrun} are available in your PATH. You can compile the example above by saving it (e.g. as \texttt{example.cpp}) and running:
675
673
\begin{lstlisting}[language=bash]
@@ -688,7 +686,7 @@ \subsection*{Using the ALP compiler wrapper}
688
686
689
687
(You can also run \texttt{./example} directly for a non-distributed run; \texttt{grbrun} is mainly needed for orchestrating distributed runs or setting up the execution environment.)
690
688
691
-
\subsection*{Using a custom build (Make/CMake)}
689
+
\subsubsection*{Using a custom build (Make/CMake)}
692
690
693
691
If you prefer to compile without the wrapper (for integration into an existing project or custom build system), you need to instruct your compiler to include ALP's headers and link against the ALP library and dependencies. The ALP installation (at the chosen \texttt{--prefix}) provides an include directory and a library directory.
694
692
@@ -723,3 +721,4 @@ \subsection*{Using a custom build (Make/CMake)}
723
721
\bigskip
724
722
725
723
This tutorial has introduced the fundamentals of using ALP/GraphBLAS in C++ on Linux, from installation to running a basic example. With ALP set up, you can explore more complex graph algorithms and linear algebra operations, confident that the library will handle parallelization and optimization under the hood. Happy coding!
0 commit comments