% Begin your document as any latex file
%\documentclass{article}
% Use package 6895
%\usepackage{6895}
%\usepackage{psfig}
%\usepackage{epsfig}

% Begin the lecture with a line like the following:
% This replaces the usual \begin{document} that a latex
% file begins with.
\begin{lecture}{20}{Permuting Data on Parallel Disks}{Sajindra Jayasena, Sharad Ganesh}

% Now summarize the lecture.  This should be like an abstract
% for the lecture, broken down into a few bullet points.
\begin{summary}
  % The first item of each \sumitem is the title of the part of the
  % lecture, and the second part is a description (i.e. abstract) of
  % that part.
  \sumitem{Parallel Disk Systems}{In this section, an overview of parallel Disk systems is given with a brief look at practical examples}
  \sumitem{Problem of permuting Disk Blocks}{In this section,we investigate how a disk access permutation is performed which would materialize high level of parallelism}
  \sumitem{Conflict Graphs}{This section looks at the theoretical aspects on how a non-conflicting schedule could be created for parallel disk access}
  \sumitem{Hall's Theorem}{Here we look at Hall's theorem and its application to a non blocking scheduling}
\end{summary}

% Now organize your lecture into sections.
\section{Parallel Disk Systems}
\seclabel{general-instructions}In this section we will briefly
look at parallel disk systems.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=.5]{20/disks.eps}
\caption{Parallel disks }
\end{center}
\end{figure}
\\One class of parallel disk systems that's used widely is RAID, which stands for
\textbf{R}edundant \textbf{A}rray of \textbf{I}nexpensive
\textbf{D}isks. In RAID, error correction is done across the disks
and multiple disks can be accessed concurrently. RAID defines
several levels of configurations that provide a combination of
properties like level of performance,fault tolerance,redundancy
etc that the user can select depending on his
requirement.\\
Some example of levels are: \\
\begin{enumerate}
\item RAID 0: Striping - The controller stripes data across
multiple drives in the RAID subsystem. RAID 0 has the best
performance and capacity of any RAID level, but the lowest
availability (no fault tolerance). \item RAID 1: Mirroring - In
RAID 1, the controller duplicates all data from one drive to
another. RAID 1 provides complete data redundancy, but at the cost
of doubling the required data storage capacity. RAID 1 has the
highest availability but lowest capacity, since twice the number
of drives are required. \item RAID 3: Striping with Dedicated
Parity - RAID level 3 provides disk striping and complete data
redundancy through a dedicated parity drive. The stripe size must
be 64KB if RAID 3 is used. RAID 3 handles data at the block level,
not the byte level, so it is ideal for networks that often handle
very large files, such as graphic images. \item RAID 5: Striping
with Rotational Parity  - The controller stripes blocks of data
and parity information across all drives. The parity block is
distributed among the drives of the array, giving a more balanced
access load across the drives. The parity information is used to
recover the data if one drive fails, and explains why this method
is the most popular.
\end{enumerate}
Another type of configuration is JBOD which stands for
\textbf{J}ust a \textbf{B}unch \textbf{O}f \textbf{D}isks.This is
just a collection of disks without any high level inter disk
management system.
\\ \textbf{Current disk timings :}
Generally following are the current timing for data access and
data transfer in modern disk systems.
\begin{enumerate}
\item Data access times: $\simeq 10^{-2}$ seconds  \item Data
Transfer Rate $\simeq 10^8$ words per seconds.
\end{enumerate}
it is clear that disk access takes most of the time compared to
disk transfer.Therefore the main strategy is  to \textbf{reduce or
parallelize the disk accesses as much as
possible}.\\\\
One convenient engineering assumption is: \\
Instead of having free writing across the disk , the disk is
broken down into large fixed size blocks. For example each block
might consist of 1000+ words or possibly million words.This is to
amortize the cost of data access over a larger number of
words.Therfore it would make the cost per word
relatively lesser.\\
Now we will look at an example and visualize how it is modelled in
a disk.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=.6]{20/blocks-intro.eps}
\caption{Disk block layout  }
\end{center}
\end{figure}
\\In  Figure 2, there are P disks and N data records. \\Therefore
to store N data records, the number of tracks needed are : \\
\textbf{Number of Tracks =  N / P$\centerdot$B}
\\
This is also equal to the number of IOs' to read all the data in N
records.This is true because in parallel disk systems , at each
unit time  one block per each disk can be read. For example:
\\At Time $T_1$ : read track 1 \\
At Time $T_2$ : read track 2
\\ .......
\\At Time $T_n$ : read track n\\
This simplifies the model to a Block read , without the need to
look into the intricacies of each block.\\
Typically a computer  has a certain size of memory. For example it
might be able to hold M data records where the general assumption
is that M $\gg$ P$\centerdot$B . ( i.e in reality the size of
memory is significantly large compared to the amount of data that
could be read at unit time from P parallel disks )
\section{Problem of permuting Disk Blocks}
Now we will look at how an actual disk access works and how it
should be scheduled in such a manner in obtaining maximum
parallelism in disk access. \\Here we will look at a permutation
which is :
\begin{enumerate}
\item Offline ( Fixed in advance )
 \item Not In Place
\end{enumerate}
\begin{figure}[h]
\begin{center}
\includegraphics[scale=.6]{20/blocks-permute.eps}
\caption{Disk access permutation }
\end{center}
\end{figure}
Here in figure 3, each block would hold 1 record. Therefore the
number of tracks required to hold N data records is \textbf{N/P}
where P is the number of Disks in the parallel system. But when
there are multiple data records per block the calculation would be
slightly more complex.\\ In the diagram ,each block specifies
where it should be written to .For example the top left block
specifies that the data in that block should be written to the
second track of third
Disk.\\
\textbf{Objective of scheduling : }\\
The objective of selecting a proper access sequence for the given
permutation is to be able to direct the set of disks to read a set
of disk blocks in a column and write those disk blocks in such a
manner that the disk blocks that are read would allow the disks to
write them back
in parallel , thus  achieving the optimal parallelism.\\
For example as in the diagram, if the last track is read in
parallel, when it comes to writing them , they all have to be
written to a single column.But the issue here is they can only be
written one at a time ,since all those blocks belong to same
disk.Therefore the objective is to find an access sequence where a
set of blocks could be read at the one unit of time in parallel
and could be written at in one unit of time in parallel. i.e in
fewer IOs' as possible.
\\
Now let's look at the following schedule.For simplicity lets
assume that the read is performed in a linear fashion to a file
and would be written back  to a different location in the disks.\\
\begin{figure}[t]
\begin{center}
\includegraphics[scale=.6]{20/blocks-schedule.eps}
\caption{Disk block access sequence }
\end{center}
\end{figure}
\newpage By simulating through the schedule it is evident that reads and writes are scheduled in a fashion that
all writes can also be performed in parallel. The
permutation is done in exactly \textbf{ N/P} parallel IOs'.\\
How well could we perform this in general? The following
section presents the theorem for it.\\
\begin{theorem}
It should be possible to permute access of N data records with P disks with \textbf{O(N/P)} parallel IOs.\\
No matter what permutation is given this can be scheduled to
guarantee that it could be performed in N/P parallel Disk IOs'.
\\note : The\textbf{O(N/P)} is given since it needs to perform a read as
well as a write.
\end{theorem}
\ Now let's look at how we could model and analyze this using
Graph theory .
\section{Conflict graph}
\begin{figure}[h]
\begin{center}
\includegraphics[scale=.5]{20/conflict.eps}
\caption{Conflict Graph }
\end{center}
\end{figure}
\textbf{Idea:} \newline \newline Set up a source disk and a
destination disk. There is a vertex for every disk. The graph
models the permutations required and helps us see what the
conflicts are. \newline \newline The degree of this graph is $n =
N/P$. The smallest degree of any vertex is also $n = N/P$. \newline
\newline In fact all degrees are the same n = N/P.\newline This is
a bi-partite graph which is n-regular, since all degrees are the
same(=$n$).
\newline \newline
\textbf{Claim:} \newline \newline Any d-regular bi-partite
multigraph can be edge colored with $d$ colors.
\begin{definition}[Edge coloring]
Color the edges in such a way that all the edges coming into a
given vertex have a different color.
\end{definition}
\textbf{Claim:} Each vertex will require at least d-colors and we
argue that it is sufficient. \newline \newline In general you can
show that if $d$ is the degree of any arbitrary graph it can be
colored with at most $d+1$ colors. The fact that, whether you can
color it with d-colors is NP-Complete. When the graph is colored,
each coloring matches the vertices on the left with the vertices
on the right.
\newline
\begin{verbatim}
Color = step at which the block is moved.
\end{verbatim}
\textbf{Method of edge coloring:}
\begin{verbatim}
Find a perfect matching(everything on the left is matched to
something on the right).
\end{verbatim}
\begin{verbatim}
Color the edges in the matching using color 1.
\end{verbatim}
\begin{verbatim}
Remove all edges of color 1. (Now we have a $d-1$ regular
bi-partite multigraph. The degree of every vertex has dropped by
exactly 1).
\end{verbatim}
\begin{verbatim}
Recur.
\end{verbatim}
To know that a perfect matching exists in a d-regular bi-partite
graph, we present Hall's theorem.
\newpage
\section{\textbf{Hall's theorem -(General bi-partite graph)}}
\begin{theorem}
Claim: If it is a d-regular bi-partite graph, a perfect matching
always exists.
\end{theorem}
\begin{figure}[h]
\begin{center}
\includegraphics[scale=.5]{20/halls.eps}
\caption{Flow graph} \label{halls}
\end{center}
\end{figure}
For any particular bi-partite graph, we have, \newline \newline A
set of vertices $A \subseteq V_1$, and let $N(A) \subseteq V_2$ be
the set of neighbors of A. For any bi-partite graph a perfect
matching exists if:

$$
|N(A)| \geq |A| \forall A \subseteq V_1.
$$
\seclabel{proof}\textbf{Proof of Hall's theorem}\newline
\newline
To find a maximum matching, one way to do that is to build a flow
network shown in Figure: \ref{halls}. If the value of the flow is
$n$, then we have a perfect matching.\newline
\begin{proof} \newline
Let f be the max flow.
$$
|f| = C(S, T)
$$
For some cut (S, T) by the max-flow min-cut theorem. S has to be
in one set and T in another, according to the max-flow min-cut
theorem. If you have a maximum flow, there must be a cut, whose
capacity is equal to the cut. If there is none, then you can find
another path to route the flow.\newline \newline Let, $A = S \cap
V_1$, since the edges from vertices in $V_1$ to vertices in $V_2$
have infinite capacity.

$$
N(A)  \subseteq S
$$
The max possible flow on this network is n. Flow across any cut in
the graph is n. At the same time, the minimum cut must have the
value of the flow, and cannot be infinite. \newline Also,
$$
N(V_1 - A) \subseteq T
$$

$$
C(S, T) \geq |V_1 - A| + |N(A)|
$$

$$
|V_1 - A| + |A|
$$

$$
= |V_1| = n
$$
\end{proof}
The flow value is $n$, everyone gets matched up, which proves
Hall's theorem.

\end{lecture}
\theend
