Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Add source of slides used in OpenHarmony Tutorial
Browse files Browse the repository at this point in the history
The slides added here are for the OpenHarmony Tutorial
at ASPLOS'24.

Signed-off-by: Diogo Behrens <diogo.behrens@huawei.com>
  • Loading branch information
db7 committed Apr 27, 2024
1 parent 424919a commit 2b25996
Show file tree
Hide file tree
Showing 52 changed files with 1,461 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build_latex_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Docker latex image

on:
push:
paths:
- slides/Dockerfile

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-latex-docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/open-s4c/latex

tags: |
type=edge,branch=main
type=raw,latest
- name: Log in to the Container registry
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup docker buildx
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
uses: docker/build-push-action@v5.1.0
with:
context: .github
file: "slides/Dockerfile"
cache-from: type=gha
cache-to: type=gha,mode=max

push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

28 changes: 28 additions & 0 deletions .github/workflows/release_slides.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build and release slides

on:
release:
types:
- published
- edited

jobs:
build-release:
runs-on: ubuntu-latest
container: ghcr.io/open-s4c/latex:latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
- name: Build
run: |
make -C slides LATEXMK=latexmk
cp slides/slides.pdf slides-${{ github.event.release.tag_name }}.pdf
- name: Release
uses: softprops/action-gh-release@v2
with:
files: slides-${{ github.event.release.tag_name }}.pdf
3 changes: 3 additions & 0 deletions slides/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.nav
*.snm
*.vrb
21 changes: 21 additions & 0 deletions slides/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG FROM_IMAGE=ubuntu:22.04
FROM ${FROM_IMAGE}

RUN apt update \
&& apt install -y --no-install-recommends \
ca-certificates \
git \
make \
patch \
asciidoc \
latex-cjk-all \
latexdiff \
latexmk \
lmodern \
texlive \
texlive-fonts-extra \
texlive-lang-chinese \
texlive-latex-extra \
texlive-plain-generic \
&& rm -rf /var/lib/apt/lists/*

6 changes: 6 additions & 0 deletions slides/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
LATEXMK ?= scripts/docker-latex.sh latexmk

all:
$(LATEXMK) --pdf slides.tex
clean:
$(LATEXMK) -C slides.tex
122 changes: 122 additions & 0 deletions slides/beamerthemehuawei.sty
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
% \LaTeX beamer theme for Huawei
%
% Author: Diogo Behrens <diogo.behrens@huawei.com>
% Date: Fri Nov 8 10:07:44 CET 2019

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerthemehuawei}[2019/11/07 Huawei beamer theme]

% ubuntu 22.04 texlive has issues with textbf and textem and the following
% package.
% See https://groups.google.com/g/linux.debian.bugs.dist/c/oQk38Pkybfk
%\RequirePackage{CJKutf8}
%\AtBeginDvi{\input{zhwinfonts}}

% dont number appendix slides (backup)
\RequirePackage{appendixnumberbeamer}
\RequirePackage{authoraftertitle}

\RequirePackage{tikz}
\usetikzlibrary{positioning}

\definecolor{HuaweiRed}{RGB}{237,28,36}

\mode<presentation>
\setbeamercolor{title}{fg=HuaweiRed}
\setbeamercolor{frametitle}{fg=HuaweiRed}
\setbeamercolor{structure}{fg=HuaweiRed}
\setbeamercolor{footline}{fg=black!50}
\setbeamerfont{footline}{size={\fontsize{4}{6}}}
\setbeamertemplate{navigation symbols}{}

\makeatletter
\setbeamertemplate{frametitle}{%
\ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
\@tempdima=\textwidth%
\advance\@tempdima by\beamer@leftmargin%
\advance\@tempdima by\beamer@rightmargin%
\begin{beamercolorbox}[sep=0.3cm,left,wd=\the\@tempdima]{frametitle}
\usebeamerfont{frametitle}%
\vbox{}\vskip-1ex%
\if@tempswa\else\csname beamer@fteleft\endcsname\fi%
\tikz[overlay]\node[opacity=1] at (140mm, 2.5mm) {\includegraphics[height=10mm]{figs/openharmony.png}};
\tikz[overlay]\node[opacity=1] at (150mm, 2.8mm) {\includegraphics[height=8mm]{figs/huawei-logo-red.png}};
\strut{\insertframetitle}\par%
{%
\ifx\insertframesubtitle\@empty%
\else%
\hspace{3.1mm}{\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
\fi\hfill%
}%
\vskip-1ex%
\if@tempswa\else\vskip-.3cm\fi%
\end{beamercolorbox}%
}
\makeatother

\setbeamertemplate{footline}[text line]{%
\parbox{\linewidth}{%
\usebeamerfont{footline}%
\usebeamercolor[fg]{footline}%
\vspace*{-8pt}%
{\tiny \hspace{-8mm}\insertframenumber/\inserttotalframenumber}%
}%
}
\mode<all>

\renewcommand{\maketitle}{{%
\setbeamertemplate{footline}[text line]{}%
\begin{frame}%
\makebox[\textwidth][c]{%
\begin{tikzpicture}
\useasboundingbox[draw=none] (0,0) rectangle (.9\paperwidth,.9\paperheight);
\node[text=HuaweiRed, anchor=north, align=center, text width=154mm] at (.5\textwidth, 50mm) (title)
{\fontsize{22}{20}\selectfont{\MyTitle}};
\node at (0.5\textwidth, 68mm){\includegraphics[height=25mm]{figs/huawei-logo-red.png}
\hspace{10mm}\includegraphics[height=28mm]{figs/openharmony.png}
};
\node[text=black,below=1mm of title, font=\small, align=center] {{\MyAuthor}};
\node[text=black, font=\small] at (0.5\textwidth, 2mm) {{\MyDate}};
\end{tikzpicture}%
}
\end{frame}%
}%
\setcounter{framenumber}{0}%
}

\newcommand{\makethanks}{{%
\addtocounter{framenumber}{-1}%
\setbeamertemplate{footline}{}%

\begin{frame}
\begin{center}
\vspace{2mm}
\includegraphics[width=40mm]{figs/huawei-logo-red.png}
\vspace{15mm}

{\color{HuaweiRed}
{\fontsize{34}{12}\selectfont Thank you!}\\
\vspace{4mm}

% {\Large
% \begin{CJK*}{UTF8}{gbsn}
% 非常感谢你
% \end{CJK*}
% }
}
\vspace{3mm}

\vspace{15mm}
\begin{tikzpicture}[overlay]
\node[draw=none, text=black, minimum width =\paperwidth, align=center, text width=1.2\paperwidth,
font=\setlength{\baselineskip}{3pt}\fontsize{5}{5}\selectfont
] {
Copyright $\copyright$ \the\year{} Huawei Technologies Co., Ltd. All Rights Reserved.\\[2pt]
The information in this document may contain predictive statements including, without limitation, statements regarding the future financial and operating results, future product portfolio, new technology, etc. There are a number of factors that could cause actual results and developments to differ materially from those expressed or implied in the predictive statements. Therefore, such information is provided for reference purpose only and constitutes neither an offer nor an acceptance. Huawei may change the information at any time without notice.\\[10pt]
};

\end{tikzpicture}
\end{center}
\end{frame}
}%
}
Binary file added slides/figs/OpenHarmonyLogo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/arm-alibaba.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/arm-amazon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/arm-apple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/arm-huawei.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/arm-microsoft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions slides/figs/atomics.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
% Copyright (C) Huawei Technologies Co., Ltd. 2024. All rights reserved.
% SPDX-License-Identifier: MIT
\begin{tabular}{l|lll}
\small {\tt\color{libvsync} vatomic} & \small RISC-V & \small ARMv8 & \small x86
\\
\hline\\[-6pt]
\lstinline[language=C,style=compact]|vatomic_xchg| & \lstinline[language={C},style=compact]|amoswap.w.aq.rl.sc| & %\lstinline[style=compact]|SWPAL| or
\lstinline[style=compact]|LDAXR;STLXR| & \lstinline[style=compact]|XCHG |\\
\lstinline[language=C,style=compact]|vatomic_xchg_rel| & \lstinline[language={C},style=compact]|amoswap.w.rl| & %\lstinline[style=compact]|SWPL| or
\lstinline[style=compact]|LDXR;STLXR| & \lstinline[style=compact]|XCHG |\\
\lstinline[language=C,style=compact]|vatomic_xchg_acq| & \lstinline[language={C},style=compact]|amoswap.w.aq| & %\lstinline[style=compact]|SWPA| or
\lstinline[style=compact]|LDAXR;STXR| & \lstinline[style=compact]|XCHG |\\
\lstinline[language=C,style=compact]|vatomic_xchg_rlx| & \lstinline[language={C},style=compact]|amoswap.w| & %\lstinline[style=compact]|SWP| or
\lstinline[style=compact]|LDXR;STXR| & \lstinline[style=compact]|XCHG|\\
\lstinline[language=C,style=compact]|vatomic_read| & \lstinline[language={C},style=compact]|fence [rw,rw]; lw; fence [r,rw]| & \lstinline[style=compact]|LDAR| & \lstinline[style=compact]|MOV |\\
\lstinline[language=C,style=compact]|vatomic_read_acq| & \lstinline[language={C},style=compact]|lw; fence [r,rw]| & \lstinline[style=compact]|LDAR| & \lstinline[style=compact]|MOV|\\
\lstinline[language=C,style=compact]|vatomic_read_rlx| & \lstinline[language={C},style=compact]|lw| & \lstinline[style=compact]|LDR| & \lstinline[style=compact]|MOV|\\
\lstinline[language=C,style=compact]|vatomic_write| & \lstinline[language={C},style=compact]|fence [rw,w]; sw; fence [rw,rw]| & \lstinline[style=compact]|STLR| & \lstinline[style=compact]|MOV;MFENCE|\\
\lstinline[language=C,style=compact]|vatomic_write_rel| & \lstinline[language={C},style=compact]|fence [rw,w]; sw| & \lstinline[style=compact]|STLR| & \lstinline[style=compact]|MOV|\\
\lstinline[language=C,style=compact]|vatomic_write_rlx| & \lstinline[language={C},style=compact]|sw| & \lstinline[style=compact]|STR| & \lstinline[style=compact]|MOV|\\
\hline\\[-6pt]
\lstinline[language=C,style=compact]|vatomic_fence| & \lstinline[language={C},style=compact]|fence [rw,rw]| & \lstinline[style=compact]|DMB ISH| & \lstinline[style=compact]|MFENCE|\\
\lstinline[language=C,style=compact]|vatomic_fence_acq| & \lstinline[language={C},style=compact]|fence [r,rw]| & \lstinline[style=compact]|DMB ISHLD| & \lstinline[style=compact]|NOP |\\
\lstinline[language=C,style=compact]|vatomic_fence_rel| & \lstinline[language={C},style=compact]|fence [rw,w]| & \lstinline[style=compact]|DMB ISH| & \lstinline[style=compact]|NOP |\\
\lstinline[language=C,style=compact]|vatomic_fence_rlx| & \lstinline[language={C},style=compact]|nop| & \lstinline[style=compact]|NOP| & \lstinline[style=compact]|NOP|
\end{tabular}
Binary file added slides/figs/award.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/battery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/bike.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions slides/figs/client-code.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
% Copyright (C) Huawei Technologies Co., Ltd. 2024. All rights reserved.
% SPDX-License-Identifier: MIT
\begin{lstlisting}[language=C, style=compact]
lock_t lock;
int v = 0; // shared state
void run(int id) {
lock_acquire(&lock);
v++; // critical sec.
lock_release(&lock);
}

void main() {
pthread_t t[N]; // N == 3
for (int i=0; i < N; i++)
pthread_create(&t[i], 0, run, i);
for (int i=0; i < N; i++)
pthread_join(t[i], 0);
assert (v == N); // check of ME
}
\end{lstlisting}

%\begin{lstlisting}[language=C, style=compact]
%lock_t lock;
%int v = 0; // shared state
%void run(int id) {
% do {
% lock_acquire(&lock);
% v++; // critical sec.
% lock_release(&lock);
% } while (id++ == 0);
%}
%
%void main() {
% pthread_t t[N]; // N == 3
% for (int i=0; i < N; i++)
% pthread_create(&t[i], 0, run, i);
% for (int i=0; i < N; i++)
% pthread_join(t[i], 0);
% assert (v == N+1); // check of ME
%}
%\end{lstlisting}
Binary file added slides/figs/explosion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/fast-car.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/hardware-evolution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/hm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/huawei-logo-red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/kirin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added slides/figs/kunpeng.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions slides/figs/message-passing.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
% Copyright (C) Huawei Technologies Co., Ltd. 2024. All rights reserved.
% SPDX-License-Identifier: MIT
\begin{tikzpicture}[
a/.style = {->, thick},
j/.style = {fill=white, font=\scriptsize\bf},
b/.style = {rounded corners, align=left}, %, text width = 7mm},
i/.style = {b},
t/.style = {b, fill=light gray},
c/.style = {b, fill=light red, text width=34mm},
]
\coordinate (x);
\node[i, above=10mm of x] (a) {\verb|msg = 0; ready = false;|};
\node[t, left=5mm of x] (b1) {\verb|msg = 42;|\\ \verb|ready = true;|};
\node[t, right=0mm of x] (b2) {\verb|while(!ready) {}|\\{\verb|assert(msg == 42);|}};
%\node[c, below=of x] (c) {\verb+assert(a != 0 || b != 0);+};
%\draw[a] (a) -- (b1);
%\draw[a] (a) -- (b2);
%\draw[a] (b1) -- (c);
%\draw[a] (b2) -- (c);
%\node[j, below=1mm of a] {{\tt pthread_create}};
%\node[j, above=1mm of c] {{\tt pthread_join}};
\node[j, above=0 of a] {Init};
\node[j, fill=none, above=0 of b1] (t1) {Thread 1};
\node[j, fill=none, above=0 of b2] (t2) {Thread 2};
\node[text=HuaweiRed, right=-2mm of b2.south east, yshift=2.5mm] {\xmark};

%\draw[a] (a) -- (t1);
%\draw[a] (a) -- (t2);
\draw<1->[<->, very thick, HuaweiRed] (b1.170) to [out=180, in = 90]
node[midway, left=1mm, align=center, font=\scriptsize] {WMM\\reorder}
+(-4mm, -2mm) to [out = -90, in = 180] (b1.190);
\end{tikzpicture}
Binary file added slides/figs/monalisa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2b25996

Please sign in to comment.