\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{test2000} \pdfinfo{ /Title (parallel.pdf) /Creator (Cheatography) /Author (test2000) /Subject (Parallel Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{6F33A3} \definecolor{LightBackground}{HTML}{F6F2F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Parallel Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{test2000} via \textcolor{DarkBackground}{\uline{cheatography.com/168552/cs/35244/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}test2000 \\ \uline{cheatography.com/test2000} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 5th November, 2022.\\ Updated 27th January, 2023.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{MPI (Basic)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.76 cm} x{4.24 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Setup and Tear Down}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{void main(int argc, char *argv)}} & starts up the MPI runtime environment at the beginning of a run. \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} {\bf{MPI\_Finalize()}} & shuts down the MPI runtime environment at the end of a run. \tn % Row Count 7 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Gathering Information}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{MPI\_Comm\_rank(MPI\_COMM\_WORLD,\&myid)}} & gets the process ID that the current process uses, which is between 0 and Np-1 inclusive. \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} {\bf{MPI\_Comm\_size(MPI\_COMM\_WORLD,\&numprocs)}} & gets the number of processes in a run. \tn % Row Count 8 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{MPI Data Types}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{MPI\_CHAR}} & char \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{MPI\_SHORT}} & short int \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{MPI\_INT}} & int \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} {\bf{MPI\_FLOAT}} & float \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{MPI\_DOUBLE}} & double \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} {\bf{MPI\_LONG\_DOUBLE}} & long double \tn % Row Count 7 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{MPI\_BYTE}} & consists of a byte (8 binary digits) \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.28 cm} x{4.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Compile}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{mpicc}} -o file file.c & compiles MPI programs written in C. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{mpiCC}} -o file file.cpp & compiles MPI programs written in C++. \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.6 cm} x{4.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Run}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{mpirun}} -np no\_processors file & run MPI compiled file with no\_processors \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.16 cm} x{5.84 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Time}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{MPI\_Wtime()}} & Returns an elapsed time on the calling processor \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.84 cm} x{6.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{int MPI\_Bcast ( *b, c,d, root,MPI\_Comm )}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{b}} & The message to be broadcasted \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{c}} & Number of elements in the message \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{d}} & The data type of the elements in the message \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} {\bf{root}} & The process number that has the message to be broadcasted to others \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} {\bf{MPI\_Comm}} & The communication world \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.92 cm} x{6.08 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{MPI\_Recv( *b, c, d, sender, t, MPI\_Comm, status)}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{b}} & Receive in buffer b \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{c}} & The number of element of data type d \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{d}} & The data type of element b \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} {\bf{sender}} & The rank of the sender \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{t}} & The tag used in the communication \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} {\bf{MPI\_Comm}} & The communication world \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{status}} & the status of the reception operation \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.84 cm} x{6.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{int MPI\_Scatter({\emph{sb,sc,sd,}}rb,rc,rd,root,MPI\_Comm)}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{sb}} & The buffer containing the data to disptach from the root process. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{sc}} & The number of elements to send to each process, not the total number of elements in the send buffer. \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} {\bf{sd}} & The type of one send buffer element \tn % Row Count 9 (+ 2) % Row 3 \SetRowColor{white} {\bf{rb}} & The buffer in which store the data dispatched. \tn % Row Count 11 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{rc}} & The number of elements in the receive buffer \tn % Row Count 13 (+ 2) % Row 5 \SetRowColor{white} {\bf{rd}} & The type of one receive buffer element. \tn % Row Count 15 (+ 2) % Row 6 \SetRowColor{LightBackground} {\bf{root}} & The rank of the root process \tn % Row Count 16 (+ 1) % Row 7 \SetRowColor{white} {\bf{MPI\_Comm}} & The communication world \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.32 cm} x{5.68 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Libraries}} \tn % Row 0 \SetRowColor{LightBackground} \textless{}mpi.h\textgreater{} & For MPI implementation \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \textless{}stdio.h\textgreater{} & C input\&output \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \textless{}math.h\textgreater{} & Handles Math \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.32 cm} x{5.68 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Terms}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Blocking}} & return after their actions complete \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{Non-Blocking}} & return immediately. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{Message Tag}} & carried within message and used to differentiate between different types of messages being sent \tn % Row Count 8 (+ 4) % Row 3 \SetRowColor{white} {\bf{MPI\_Status}} & represents the status of a reception operation. \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.08 cm} x{5.92 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{MPI Point-to-Point Communication}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{MPI\_Send()}} & sends a message from the current process to some other process. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{MPI\_Recv()}} & receives a message on the current process from some other process. \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Collective Communication}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{MPI\_Bcast()}} & Broadcast from root to all other processes \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{MPI\_Gather()}} & Gather values for group of processes \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{MPI\_Scatter()}} & Scatters buffer in parts to group of processes \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\bf{MPI\_Alltoall()}} & Sends data from all processes to all processes \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{MPI\_Reduce()}} & Combine values on all processes to single value \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} {\bf{MPI\_Reduce\_scatter()}} & Combine values and scatter results \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.44 cm} x{4.56 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{MPI Nonblocking Routines}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{MPI\_Isend()}} & Non-blocking send; will return "immediately" \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{MPI\_Irecv()}} & Nonblocking receive; will return even if no message to accept. \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{MPI\_Wait({\emph{request,}}status)}} & waits until operation completed and returns then. \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} {\bf{MPI\_Test()}} & returns with flag set indicating whether operation completed at that time. \tn % Row Count 13 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{MPI (Detailed)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{MPI\_Send(*d, c, m, receiver, t, MPI\_Comm)}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{d}} & Send Data from address d \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{c}} & The number of elements of d \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{m}} & The Datatype of d \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} {\bf{receiver}} & The rank of the reciever \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{t}} & The communication is marked with t tag \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} {\bf{MPI\_Comm\_World}} & The communication world \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.84 cm} x{6.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{int MPI\_Gather(sb,sc,sd,rb,rc,rd,root,MPI\_Comm)}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{sb}} & The sender buffer \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{sc}} & The number of elements in the buffer \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{sd}} & The datatype of one element in the buffer \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} {\bf{rb}} & The buffer in which store the gathered data for the root process \tn % Row Count 8 (+ 3) % Row 4 \SetRowColor{LightBackground} {\bf{rc}} & The number of elements per message received, not the total number of elements to receive from all processes altogether. \tn % Row Count 12 (+ 4) % Row 5 \SetRowColor{white} {\bf{rd}} & The type of one receive buffer element. \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\bf{root}}} \tn % Row Count 15 (+ 1) % Row 7 \SetRowColor{white} {\bf{MPI\_Comm}} & The communication world \tn % Row Count 17 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.84 cm} x{6.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{int MPI\_Reduce({\emph{sb,}}rb,c,d,op,root,MPI\_Comm);}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{sb}} & A pointer on the buffer to send for reduction. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{rb}} & A pointer on the buffer in which store the result of the reduction \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{c}} & The number of elements in the send buffer \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} {\bf{d}} & The type of a buffer element. \tn % Row Count 8 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{op}} & The operation to apply to combine messages received in the reduction \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} {\bf{root}} & The rank of the MPI process that will collect the reduction result. \tn % Row Count 14 (+ 3) % Row 6 \SetRowColor{LightBackground} {\bf{MPI\_Comm}} & The communication world \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}