]> AND Private Git Repository - book_gpu.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
new
authorcouturie <couturie@extinction>
Thu, 18 Jul 2013 12:03:05 +0000 (14:03 +0200)
committercouturie <couturie@extinction>
Thu, 18 Jul 2013 12:03:05 +0000 (14:03 +0200)
BookGPU/BookGPU.tex
BookGPU/Chapters/chapter2/ch2.tex
BookGPU/Chapters/chapter2/ex1.cu
BookGPU/Chapters/chapter3/ch3.aux
BookGPU/sunil.cls

index 7212cf1a2daf54a89f734f427a41ddc7cb64735b..cdb98f0996e62bafc017ddf1c9004065a5e6b276 100755 (executable)
 
 \makeindex
 %\includeonly{Chapters/chapter10/ch10}
 
 \makeindex
 %\includeonly{Chapters/chapter10/ch10}
-
+\DeclareCaptionLabelSeparator{colon}{\ }
 \begin{document}
 
 
 \begin{document}
 
 
index 2f4f4eab09c00c7438ded1a86bf74fe947587f5a..9c6d0def10d3bdff5fee0604f9e4e40e532d46f5 100755 (executable)
 \chapterauthor{Raphaël Couturier}{Femto-ST Institute, University of Franche-Comte, France}
 
 \chapterauthor{Raphaël Couturier}{Femto-ST Institute, University of Franche-Comte, France}
 
-\chapter{Introduction to Cuda}
+\chapter{Introduction to CUDA}
 \label{chapter2}
 
 \section{Introduction}
 \label{ch2:intro}
 
 \label{chapter2}
 
 \section{Introduction}
 \label{ch2:intro}
 
-In this chapter  we give some simple examples of Cuda  programming.  The goal is
-not to provide an exhaustive presentation of all the functionalities of Cuda but
-rather to give some basic elements. Of  course, readers that do not know Cuda are
-invited  to read  other  books that  are  specialized on  Cuda programming  (for
-example: \cite{ch2:Sanders:2010:CEI}).
+In this chapter  we give some simple examples of CUDA  programming.  The goal is
+not to provide an exhaustive presentation of all the functionalities of CUDA but
+rather to give some basic elements. Of  course, readers who do not know CUDA are
+invited  to read  other  books that  are  specialized on  CUDA programming  (for
+example, \cite{ch2:Sanders:2010:CEI}).
 
 
 \section{First example}
 \label{ch2:1ex}
 
 This first example is  intented to show how to build a  very simple program with
 
 
 \section{First example}
 \label{ch2:1ex}
 
 This first example is  intented to show how to build a  very simple program with
-Cuda.  Its goal  is to perform the sum  of two arrays and put the  result into a
-third array.  A Cuda program consists in  a C code which calls Cuda kernels that
-are executed on a GPU. The listing of this code is in Listing~\ref{ch2:lst:ex1}.
+CUDA.  Its goal  is to perform the sum  of two arrays and put the  result into a
+third array.  A CUDA program consists in  a C code which calls CUDA kernels that
+are executed on a GPU. This code is in Listing~\ref{ch2:lst:ex1}.
 
 
 
 
-As GPUs have  their own memory, the first step consists  in allocating memory on
-the GPU.  A call to  \texttt{cudaMalloc}\index{Cuda~functions!cudaMalloc} allows
-to allocate memory on the GPU. The first parameter of this function is a pointer
-on a memory on the device (i.e. the GPU). In this example, \texttt{d\_} is added
-on each variable allocated  on the GPU, meaning this variable is  on the GPU. The
-second parameter represents the size of the allocated variables, this size is expressed in
-bits.
+As GPUs have  their own memory, the first step consists  of allocating memory on
+the   GPU.   A   call   to  \texttt{cudaMalloc}\index{CUDA~functions!cudaMalloc}
+allocates memory  on the GPU.  The  second parameter represents the  size of the
+allocated variables, this size is expressed in bits.
+
+\lstinputlisting[label=ch2:lst:ex1,caption=simple example]{Chapters/chapter2/ex1.cu}
+
 
 In this example, we  want to compare the execution time of  the additions of two
 arrays in  CPU and  GPU. So  for both these  operations, a  timer is  created to
 
 In this example, we  want to compare the execution time of  the additions of two
 arrays in  CPU and  GPU. So  for both these  operations, a  timer is  created to
-measure the  time. Cuda proposes to  manipulate timers quite  easily.  The first
-step is to create the timer\index{Cuda~functions!timer}, then to start it and at
+measure the  time. CUDA proposes to  manipulate timers quite  easily.  The first
+step is to create the timer\index{CUDA~functions!timer}, then to start it, and at
 the end to stop it. For each of these operations a dedicated function is used.
 
 the end to stop it. For each of these operations a dedicated function is used.
 
-In  order to  compute  the same  sum  with a  GPU, the  first  step consists  in
-transferring the data from the CPU (considered as the host with Cuda) to the GPU
-(considered as the  device with Cuda).  A call  to \texttt{cudaMemcpy} allows to
-copy the content of an array allocated in the host to the device when the fourth
+In  order to  compute  the same  sum  with a  GPU, the  first  step consists  of
+transferring the data from the CPU (considered as the host with CUDA) to the GPU
+(considered as the  device with CUDA).  A call  to \texttt{cudaMemcpy} copies the content of an array allocated in the host to the device when the fourth
 parameter                                 is                                 set
 parameter                                 is                                 set
-to  \texttt{cudaMemcpyHostToDevice}\index{Cuda~functions!cudaMemcpy}.  The first
+to  \texttt{cudaMemcpyHostToDevice}\index{CUDA~functions!cudaMemcpy}.  The first
 parameter of the function is the  destination array, the second is the
 parameter of the function is the  destination array, the second is the
-source  array and  the third  is the  number of  elements to  copy  (expressed in
+source  array, and  the third  is the  number of  elements to  copy  (expressed in
 bytes).
 
 Now the  GPU contains the  data needed to  perform the addition.   In sequential
 bytes).
 
 Now the  GPU contains the  data needed to  perform the addition.   In sequential
-programming, such  addition is  achieved out  with a loop  on all  the elements.
+programming, such  addition is  achieved   with a loop  on all  the elements.
 With a GPU,  it is possible to perform  the addition of all the  elements of the
 two  arrays in  parallel (if  the number  of blocks  and threads  per  blocks is
 With a GPU,  it is possible to perform  the addition of all the  elements of the
 two  arrays in  parallel (if  the number  of blocks  and threads  per  blocks is
-sufficient).   In Listing\ref{ch2:lst:ex1}  at the  beginning, a  simple kernel,
+sufficient).   In Listing~\ref{ch2:lst:ex1}  at the  beginning, a  simple kernel,
 called \texttt{addition} is defined to  compute in parallel the summation of the
 called \texttt{addition} is defined to  compute in parallel the summation of the
-two     arrays.      With     Cuda,     a     kernel     starts     with     the
-keyword   \texttt{\_\_global\_\_}   \index{Cuda~keywords!\_\_shared\_\_}   which
+two     arrays.      With     CUDA,     a     kernel     starts     with     the
+keyword   \texttt{\_\_global\_\_}   \index{CUDA~keywords!\_\_shared\_\_}   which
 indicates that this kernel can be called from the C code.  The first instruction
 in this kernel is used to compute the variable \texttt{tid} which represents the
 thread index.   This thread index\index{thread  index} is computed  according to
 the           values            of           the           block           index
 indicates that this kernel can be called from the C code.  The first instruction
 in this kernel is used to compute the variable \texttt{tid} which represents the
 thread index.   This thread index\index{thread  index} is computed  according to
 the           values            of           the           block           index
-(called  \texttt{blockIdx} \index{Cuda~keywords!blockIdx}  in Cuda)  and  of the
-thread   index   (called   \texttt{blockIdx}\index{Cuda~keywords!threadIdx}   in
-Cuda). Blocks of threads and thread  indexes can be decomposed into 1 dimension,
-2 dimensions or  3 dimensions.  According to the  dimension of manipulated data,
+(called  \texttt{blockIdx} \index{CUDA~keywords!blockIdx}  in CUDA)  and  of the
+thread   index   (called   \texttt{threadIdx}\index{CUDA~keywords!threadIdx}   in
+CUDA). Blocks of threads and thread  indexes can be decomposed into 1 dimension,
+2 dimensions, or  3 dimensions. {\bf A REGARDER} According to the  dimension of manipulated data,
 the appropriate dimension  can be useful. In our example,  only one dimension is
 the appropriate dimension  can be useful. In our example,  only one dimension is
-used.   Then using notation  \texttt{.x} we  can access  to the  first dimension
-(\texttt{.y}  and \texttt{.z}  respectively allow to access  to the  second and
-third dimension).   The variable \texttt{blockDim}\index{Cuda~keywords!blockDim}
+used.   Then using the notation  \texttt{.x}, we  can access  the  first dimension
+(\texttt{.y}  and \texttt{.z},  respectively allow access  to the  second and
+third dimension).   The variable \texttt{blockDim}\index{CUDA~keywords!blockDim}
 gives the size of each block.
 
 
 
 gives the size of each block.
 
 
 
-\lstinputlisting[label=ch2:lst:ex1,caption=A simple example]{Chapters/chapter2/ex1.cu}
+
 
 \section{Second example: using CUBLAS}
 \label{ch2:2ex}
 
 The Basic Linear Algebra Subprograms  (BLAS) allows programmers to use efficient
 
 \section{Second example: using CUBLAS}
 \label{ch2:2ex}
 
 The Basic Linear Algebra Subprograms  (BLAS) allows programmers to use efficient
-routines  that are  often  required. Those  routines  are heavily  used in  many
+routines for basic linear operations. Those  routines  are heavily  used in  many
 scientific applications  and are optimized for  vector operations, matrix-vector
 scientific applications  and are optimized for  vector operations, matrix-vector
-operations                           and                           matrix-matrix
+operations,                           and                           matrix-matrix
 operations~\cite{ch2:journals/ijhpca/Dongarra02}. Some  of those operations seem
 operations~\cite{ch2:journals/ijhpca/Dongarra02}. Some  of those operations seem
-to be  easy to  implement with Cuda.   Nevertheless, as  soon as a  reduction is
-needed, implementing an efficient reduction routine with Cuda is far from being
+to be  easy to  implement with CUDA.   Nevertheless, as  soon as a  reduction is
+needed, implementing an efficient reduction routine with CUDA is far from being
 simple. Roughly speaking, a reduction operation\index{reduction~operation} is an
 operation  which combines  all the  elements of  an array  and extracts  a number
 simple. Roughly speaking, a reduction operation\index{reduction~operation} is an
 operation  which combines  all the  elements of  an array  and extracts  a number
-computed with all the  elements. For example, a sum, a maximum  or a dot product
+computed from all the  elements. For example, a sum, a maximum,  or a dot product
 are reduction operations.
 
 are reduction operations.
 
-In this second example, we consider that  we have two vectors $A$ and $B$. First
-of all, we want to compute the sum  of both vectors in a vector $C$. Then we want
+In this second example,   we have two vectors $A$ and $B$. First
+of all, we want to compute the sum  of both vectors and store the result in a vector $C$. Then we want
 to compute the  scalar product between $1/C$ and $1/A$. This  is just an example
 to compute the  scalar product between $1/C$ and $1/A$. This  is just an example
-which has no direct interest except to show how to program it with Cuda.
+which has no direct interest except to show how to program it with CUDA.
 
 
-Listing~\ref{ch2:lst:ex2} shows this example with Cuda. The first kernel for the
+Listing~\ref{ch2:lst:ex2} shows this example with CUDA. The first kernel for the
 addition  of two  arrays  is exactly  the same  as  the one  described in  the
 previous example.
 
 addition  of two  arrays  is exactly  the same  as  the one  described in  the
 previous example.
 
-The  kernel  to  compute the  opposite  of  the  elements  of  an array  is  very
+The  kernel  to  compute the  inverse  of  the  elements  of  an array  is  very
 simple. For  each thread index,  the inverse of  the array replaces  the initial
 array.
 
 In the main function,  the beginning is very similar to the  one in the previous
 simple. For  each thread index,  the inverse of  the array replaces  the initial
 array.
 
 In the main function,  the beginning is very similar to the  one in the previous
-example.  First,  the user is  askef to define  the number of elements.   Then a
-call  to \texttt{cublasCreate}  allows  to initialize  the  cublas library.   It
+example.  First,  the user is  asked to define  the number of elements.   Then a
+call  to \texttt{cublasCreate}  initializes  the  CUBLAS library.   It
 creates a handle. Then all the arrays  are allocated in the host and the device,
 as in the  previous example.  Both arrays $A$ and $B$  are initialized.  The CPU
 creates a handle. Then all the arrays  are allocated in the host and the device,
 as in the  previous example.  Both arrays $A$ and $B$  are initialized.  The CPU
-computation is performed  and the time for this CPU  computation is measured. In
-order to  compute the same result  on the GPU, first  of all, data  from the CPU
+computation is performed  and the time for this  is measured. In
+order to  compute the same result  for the GPU, first  of all, data  from the CPU
 need to be  copied into the memory of  the GPU. For that, it is  possible to use
 need to be  copied into the memory of  the GPU. For that, it is  possible to use
-cublas   function   \texttt{cublasSetVector}.    This   function   has   several
+CUBLAS   function   \texttt{cublasSetVector}.    This   function   has   several
 arguments. More precisely, the first  argument represents the number of elements
 to transfer, the second arguments is the size of each element, the third element
 represents the source  of the array to  transfer (in the GPU), the  fourth is an
 offset between each element of the source  (usually this value is set to 1), the
 arguments. More precisely, the first  argument represents the number of elements
 to transfer, the second arguments is the size of each element, the third element
 represents the source  of the array to  transfer (in the GPU), the  fourth is an
 offset between each element of the source  (usually this value is set to 1), the
-fifth is  the destination (in the  GPU) and the  last is an offset  between each
+fifth is  the destination (in the  GPU), and the  last is an offset  between each
 element  of the  destination. Then  we call  the kernel  \texttt{addition} which
 computes the  sum of all elements  of arrays $A$ and  $B$.  The \texttt{inverse}
 kernel  is called twice,  once to  inverse elements  of array  $C$ and  once for
 $A$. Finally,  we call the  function \texttt{cublasDdot} which computes  the dot
 product  of two  vectors.   To use  this  routine, we  must  specify the  handle
 element  of the  destination. Then  we call  the kernel  \texttt{addition} which
 computes the  sum of all elements  of arrays $A$ and  $B$.  The \texttt{inverse}
 kernel  is called twice,  once to  inverse elements  of array  $C$ and  once for
 $A$. Finally,  we call the  function \texttt{cublasDdot} which computes  the dot
 product  of two  vectors.   To use  this  routine, we  must  specify the  handle
-initialized by  Cuda, the number  of elements to  consider, then each  vector is
+initialized by  CUDA, the number  of elements to  consider, then each  vector is
 followed by the offset between every  element.  After the GPU computation, it is
 followed by the offset between every  element.  After the GPU computation, it is
-possible to check that both computation produce the same result.
+possible to check that both computations produce the same result.
 
 
-\lstinputlisting[label=ch2:lst:ex2,caption=A simple example with cublas]{Chapters/chapter2/ex2.cu}
+\lstinputlisting[label=ch2:lst:ex2,caption=simple example with CUBLAS]{Chapters/chapter2/ex2.cu}
 
 \section{Third example: matrix-matrix multiplication}
 \label{ch2:3ex}
 
 \section{Third example: matrix-matrix multiplication}
 \label{ch2:3ex}
@@ -131,53 +130,53 @@ possible to check that both computation produce the same result.
 
 
 Matrix-matrix multiplication is an operation  which is quite easy to parallelize
 
 
 Matrix-matrix multiplication is an operation  which is quite easy to parallelize
-with a GPU. If we consider that  a matrix is represented using a two dimensional
-array, $A[i][j]$ represents the element of  the $i^{th}$ row and of the $j^{th}$
-column. In  many cases, it is  easier to manipulate a  1D array instead  of a 2D
-array.   With Cuda,  even if  it is  possible to  manipulate 2D  arrays,  in the
+with a GPU. If we consider that  a matrix is represented using a two-dimensional
+array, $A[i][j]$ represents the element of  the $i$ row and of the $j$
+column. In  many cases, it is  easier to manipulate a  one-dimentional (1D) array rather than a 2D
+array.   With CUDA,  even if  it is  possible to  manipulate 2D  arrays,  in the
 following we present an example based on a 1D array. For the sake of simplicity,
 we  consider we  have  a square  matrix of  size  \texttt{size}.  So  with a  1D
 array,  \texttt{A[i*size+j]} allows  us to  have access  to the  element  of the
 following we present an example based on a 1D array. For the sake of simplicity,
 we  consider we  have  a square  matrix of  size  \texttt{size}.  So  with a  1D
 array,  \texttt{A[i*size+j]} allows  us to  have access  to the  element  of the
-$i^{th}$ row and of the $j^{th}$ column.
+$i$ row and of the $j$ column.
 
 
-With  a sequential  programming, the  matrix multiplication  is  performed using
+With  sequential  programming, the  matrix-matrix multiplication  is  performed using
 three loops. We assume that $A$, $B$  represent two square matrices and the
 result   of    the   multiplication    of   $A   \times    B$   is    $C$.   The
 element \texttt{C[i*size+j]} is computed as follows:
 \begin{equation}
 three loops. We assume that $A$, $B$  represent two square matrices and the
 result   of    the   multiplication    of   $A   \times    B$   is    $C$.   The
 element \texttt{C[i*size+j]} is computed as follows:
 \begin{equation}
-C[i*size+j]=\sum_{k=0}^{size-1} A[i*size+k]*B[k*size+j];
+C[size*i+j]=\sum_{k=0}^{size-1} A[size*i+k]*B[size*k+j];
 \end{equation}
 
 In Listing~\ref{ch2:lst:ex3},  the CPU computation  is performed using  3 loops,
 \end{equation}
 
 In Listing~\ref{ch2:lst:ex3},  the CPU computation  is performed using  3 loops,
-one  for $i$,  one for  $j$  and one  for $k$.   In  order to  perform the  same
-computation on a  GPU, a naive solution consists in  considering that the matrix
-$C$ is split into  2 dimensional blocks.  The size of each  block must be chosen
-such as the number of threads per block is inferior to $1,024$.
+one  for $i$,  one for  $j$,  and one  for $k$.   In  order to  perform the  same
+computation on a  GPU, a naive solution consists of  considering that the matrix
+$C$ is split into  2-dimensional blocks.  The size of each  block must be chosen
+such that the number of threads per block is less than $1,024$.
 
 
 In Listing~\ref{ch2:lst:ex3},  we consider that  a block contains 16  threads in
 each   dimension,  the   variable  \texttt{width}   is  used   for   that.   The
 
 
 In Listing~\ref{ch2:lst:ex3},  we consider that  a block contains 16  threads in
 each   dimension,  the   variable  \texttt{width}   is  used   for   that.   The
-variable \texttt{nbTh} represents the number of threads per block. So, to be able
+variable \texttt{nbTh} represents the number of threads per block. So, 
 to compute the matrix-matrix product on a GPU, each block of threads is assigned
 to compute the matrix-matrix product on a GPU, each block of threads is assigned
-to compute the result  of the product for the elements of  this block.  The main
+to compute the result  of the product of the elements of  that block.  The main
 part of the code is quite similar to the previous code.  Arrays are allocated in
 the  CPU and  the GPU.   Matrices $A$  and $B$  are randomly  initialized.  Then
 part of the code is quite similar to the previous code.  Arrays are allocated in
 the  CPU and  the GPU.   Matrices $A$  and $B$  are randomly  initialized.  Then
-arrays are  transferred inside the  GPU memory with call  to \texttt{cudaMemcpy}.
+arrays are  transferred to the  GPU memory with call  to \texttt{cudaMemcpy}.
 So the first step for each thread of a block is to compute the corresponding row
 So the first step for each thread of a block is to compute the corresponding row
-and   column.    With   a    2   dimensional   decomposition,   \texttt{int   i=
+and   column.    With   a   2-dimensional   decomposition,   \texttt{int   i=
 blockIdx.y*blockDim.y+ threadIdx.y;} allows us to compute the corresponding line
 and  \texttt{int  j=   blockIdx.x*blockDim.x+  threadIdx.x;}  the  corresponding
 blockIdx.y*blockDim.y+ threadIdx.y;} allows us to compute the corresponding line
 and  \texttt{int  j=   blockIdx.x*blockDim.x+  threadIdx.x;}  the  corresponding
-column. Then each  thread has to compute the  sum of the product of  the line of
+column. Then each  thread has to compute the  sum of the product of  the row of
 $A$   by   the  column   of   $B$.    In  order   to   use   a  register,   the
 kernel  \texttt{matmul}  uses a  variable  called  \texttt{sum}  to compute  the
 sum. Then the result is set into  the matrix at the right place. The computation
 of  CPU matrix-matrix multiplication  is performed  as described  previously.  A
 $A$   by   the  column   of   $B$.    In  order   to   use   a  register,   the
 kernel  \texttt{matmul}  uses a  variable  called  \texttt{sum}  to compute  the
 sum. Then the result is set into  the matrix at the right place. The computation
 of  CPU matrix-matrix multiplication  is performed  as described  previously.  A
-timer measures  the time.   In order to  use 2 dimensional  blocks, \texttt{dim3
+timer measures  the time.   In order to  use 2-dimensional  blocks, \texttt{dim3
 dimGrid(size/width,size/width);} allows us  to create \texttt{size/width} blocks
 in each  dimension.  Likewise,  \texttt{dim3 dimBlock(width,width);} is  used to
 create \texttt{width} thread  in each dimension. After that,  the kernel for the
 matrix  multiplication is  called. At  the end  of the  listing, the  matrix $C$
 dimGrid(size/width,size/width);} allows us  to create \texttt{size/width} blocks
 in each  dimension.  Likewise,  \texttt{dim3 dimBlock(width,width);} is  used to
 create \texttt{width} thread  in each dimension. After that,  the kernel for the
 matrix  multiplication is  called. At  the end  of the  listing, the  matrix $C$
-computed by the GPU is transferred back  into the CPU and we check if both matrices
+computed by the GPU is transferred back  into the CPU and we check that both matrices
 C computed by the CPU and the GPU are identical with a precision of $10^{-4}$.
 
 
 C computed by the CPU and the GPU are identical with a precision of $10^{-4}$.
 
 
@@ -185,15 +184,15 @@ With $1,024  \times 1,024$ matrices,  on a C2070M  Tesla card, this  code takes
 $37.68$ms to perform the multiplication. With an Intel Xeon E31245 at $3.30$GHz, it
 takes $2465$ms  without any parallelization (using only  one core). Consequently
 the speed up  between the CPU and GPU  version is about $65$ which  is very good
 $37.68$ms to perform the multiplication. With an Intel Xeon E31245 at $3.30$GHz, it
 takes $2465$ms  without any parallelization (using only  one core). Consequently
 the speed up  between the CPU and GPU  version is about $65$ which  is very good
-regarding the difficulty of parallelizing this code.
+considering the difficulty of parallelizing this code.
 
 
-\lstinputlisting[label=ch2:lst:ex3,caption=simple Matrix-matrix multiplication with cuda]{Chapters/chapter2/ex3.cu}
+\lstinputlisting[label=ch2:lst:ex3,caption=simple matrix-matrix multiplication with cuda]{Chapters/chapter2/ex3.cu}
 
 \section{Conclusion}
 
 \section{Conclusion}
-In this chapter, three simple Cuda examples have been  presented. They are
-quite  simple. As we  cannot  present  all the  possibilities  of  the  Cuda
-programming, interested  readers  are  invited  to  consult  Cuda  programming
-introduction books if some issues regarding the Cuda programming are not clear.
+In this chapter, three simple CUDA examples have been  presented. They are
+quite  simple. As we  cannot  present  all the  possibilities  of  the  CUDA
+programming, interested  readers  are  invited  to  consult  CUDA  programming
+introduction books if some issues regarding the CUDA programming are not clear.
 
 \putbib[Chapters/chapter2/biblio]
 
 
 \putbib[Chapters/chapter2/biblio]
 
index cae3c9c57fee76a271412be32a79edfa88fd9f18..8f2b404eff64f6c67d9674b52fdf5e6a03c00fd4 100644 (file)
@@ -64,9 +64,9 @@ int main( int argc, char** argv)
        printf("GPU processing time : %f (ms) \n", cutGetTimerValue(timer_gpu));
        cutDeleteTimer(timer_gpu);
 
        printf("GPU processing time : %f (ms) \n", cutGetTimerValue(timer_gpu));
        cutDeleteTimer(timer_gpu);
 
-       for(i=0;i<size;i++)
+       for(i=0;i<size;i++) {
                assert(h_arrayC[i]==h_arrayCgpu[i]);
                assert(h_arrayC[i]==h_arrayCgpu[i]);
-
+       }
        cudaFree(d_arrayA);
        cudaFree(d_arrayB);
        cudaFree(d_arrayC);
        cudaFree(d_arrayA);
        cudaFree(d_arrayB);
        cudaFree(d_arrayC);
index 8a1e22e4bcc6715560e17fdb5ddadcdff50850d1..69d76c60f7f693b25427bf2b6e07e4c61fb2b744 100644 (file)
@@ -64,9 +64,9 @@
 \@writefile{toc}{\contentsline {subsection}{\numberline {4.4.2}Further optimization}{38}}
 \@writefile{lof}{\contentsline {figure}{\numberline {4.4}{\ignorespaces Comparison of pixel throughputs on GPU C2070 and CPU for generic median, 3$\times $3 median register-only and \textit  {libJacket}.\relax }}{39}}
 \newlabel{fig:compMedians1}{{4.4}{39}}
 \@writefile{toc}{\contentsline {subsection}{\numberline {4.4.2}Further optimization}{38}}
 \@writefile{lof}{\contentsline {figure}{\numberline {4.4}{\ignorespaces Comparison of pixel throughputs on GPU C2070 and CPU for generic median, 3$\times $3 median register-only and \textit  {libJacket}.\relax }}{39}}
 \newlabel{fig:compMedians1}{{4.4}{39}}
-\@writefile{lof}{\contentsline {figure}{\numberline {4.5}{\ignorespaces Forgetful selection with the minimal element register count. Illustration for 3$\times $3 pixel window represented in a row and supposed sorted.\relax }}{39}}
-\newlabel{fig:forgetful_selection}{{4.5}{39}}
 \@writefile{toc}{\contentsline {subsubsection}{\numberline {4.4.2.1}Reducing register count }{39}}
 \@writefile{toc}{\contentsline {subsubsection}{\numberline {4.4.2.1}Reducing register count }{39}}
+\@writefile{lof}{\contentsline {figure}{\numberline {4.5}{\ignorespaces Forgetful selection with the minimal element register count. Illustration for 3$\times $3 pixel window represented in a row and supposed sorted.\relax }}{40}}
+\newlabel{fig:forgetful_selection}{{4.5}{40}}
 \@writefile{lof}{\contentsline {figure}{\numberline {4.6}{\ignorespaces Determination of the Median value by the forgetful selection process, applied to a $3\times 3$ neighborhood window.\relax }}{41}}
 \newlabel{fig:forgetful3}{{4.6}{41}}
 \newlabel{lst:medianForget1pix3}{{4.3}{41}}
 \@writefile{lof}{\contentsline {figure}{\numberline {4.6}{\ignorespaces Determination of the Median value by the forgetful selection process, applied to a $3\times 3$ neighborhood window.\relax }}{41}}
 \newlabel{fig:forgetful3}{{4.6}{41}}
 \newlabel{lst:medianForget1pix3}{{4.3}{41}}
 \newlabel{fig:sap_examples2}{{4.11}{49}}
 \newlabel{lst:medianSeparable}{{4.6}{50}}
 \@writefile{lol}{\contentsline {lstlisting}{\numberline {4.6}generic pseudo median kernel.}{50}}
 \newlabel{fig:sap_examples2}{{4.11}{49}}
 \newlabel{lst:medianSeparable}{{4.6}{50}}
 \@writefile{lol}{\contentsline {lstlisting}{\numberline {4.6}generic pseudo median kernel.}{50}}
-\@writefile{toc}{\contentsline {section}{Bibliography}{51}}
 \@setckpt{Chapters/chapter3/ch3}{
 \setcounter{page}{53}
 \setcounter{equation}{0}
 \@setckpt{Chapters/chapter3/ch3}{
 \setcounter{page}{53}
 \setcounter{equation}{0}
index c54ae3e35113334969787aeb9281eab764791775..6c26076f44ca5320649a222f678b20bfc528a4f0 100755 (executable)
   \def\@xviiipt{18}
  \def\@xxivpt{24}
 
   \def\@xviiipt{18}
  \def\@xxivpt{24}
 
+\newcommand\ContributorAffiliationFont{\reset@font\fontsize{10}{12}\raggedright\selectfont}
+\newcommand\ContributorNameFont{\reset@font\fontsize{10}{12}\bfseries\raggedright\selectfont}
+
 \newcommand\SectionHeadFont{\fontsize{12}{14}\bfseries\selectfont}
 \newcommand\SubsectionHeadFont{\fontsize{11}{13}\bfseries\selectfont}
 \newcommand\SubsubsectionHeadFont{\fontsize{10}{12}\bfseries\selectfont}
 \newcommand\SectionHeadFont{\fontsize{12}{14}\bfseries\selectfont}
 \newcommand\SubsectionHeadFont{\fontsize{11}{13}\bfseries\selectfont}
 \newcommand\SubsubsectionHeadFont{\fontsize{10}{12}\bfseries\selectfont}
 
 \if@ChapterTOCs
   \newwrite\@chaptoc
 
 \if@ChapterTOCs
   \newwrite\@chaptoc
-  \def\secnumwidth{21pt}\def\subsecnumwidth{30pt}\def\ssubsecnumwidth{36pt}\fi
+  \def\secnumwidth{21pt}\def\subsecnumwidth{30pt}\def\ssubsecnumwidth{36pt}\def\subsubsecnumwidth{66pt}\fi
 \long\def\@trplarg#1{\@ifnextchar[{\@xtrplarg{#1}}{\@ztrplarg{#1}}}
 \long\def\@xtrplarg#1[#2]{\@ifnextchar[{#1[#2]}{\@ytrplarg{#1}[{#2}]}}
 \long\def\@ytrplarg#1[#2]#3{#1[{#2}][{#2}]{#3}}
 \long\def\@trplarg#1{\@ifnextchar[{\@xtrplarg{#1}}{\@ztrplarg{#1}}}
 \long\def\@xtrplarg#1[#2]{\@ifnextchar[{#1[#2]}{\@ytrplarg{#1}[{#2}]}}
 \long\def\@ytrplarg#1[#2]#3{#1[{#2}][{#2}]{#3}}
                    \@topnewpage[\@makeschapterhead{#1}]%
                  \else
                    \@makeschapterhead{#1}%
                    \@topnewpage[\@makeschapterhead{#1}]%
                  \else
                    \@makeschapterhead{#1}%
+                   \addcontentsline{toc}{fm}{#1}
+                   \markboth{#1}{#1}
                    \@afterheading
                  \fi}
                  
                    \@afterheading
                  \fi}
                  
   \fi
   \@xsect{#5}}
 
   \fi
   \@xsect{#5}}
 
+%%Change mydotted also
+\newdimen\secwd
+\newdimen\subsecwd
+\newdimen\subsubsecwd
+
+\def\secwd{31pt}
+\def\subsecwd{36pt}
+\def\subsubsecwd{56pt}
+
+
+\def\ssubnumberline#1{\@hangfrom{\hbox to \secwd{#1\hfill}}}
+\def\subnumberline#1{\@hangfrom{\hskip\subsecnumwidth\hbox to \subsecwd{#1\hfill}}}
+\def\subsubnumberline#1{\@hangfrom{\hskip\subsubsecnumwidth\hbox to \subsubsecwd{#1\hfill}}}
+
+
 \newcommand\section{%
   \gdef\chapterauthor{\@caplusone}%
   \gdef\endchapterauthors{\end@casplusone}%
   \@ifstar{\@ssection}{\@trplarg{\@section}}}
 \def\@ssection#1{%
   \if@ChapterTOCs
 \newcommand\section{%
   \gdef\chapterauthor{\@caplusone}%
   \gdef\endchapterauthors{\end@casplusone}%
   \@ifstar{\@ssection}{\@trplarg{\@section}}}
 \def\@ssection#1{%
   \if@ChapterTOCs
-    \myaddcontentsline{\@chaptoc}{chapsection}{\string\makebox[\secnumwidth][l]{}#1}\fi
+    \myaddcontentsline{\@chaptoc}{chapsection}{\protect\ssubnumberline{\thesection}#1}\fi
   \@startsection{section}{1}{\z@}{30\p@}{6\p@}{\sec@rule\nopagebreak\vskip13.5\p@\nopagebreak\SectionHeadFont}*{#1}}
 \def\@section[#1][#2]#3{%
   \if@ChapterTOCs
     \addtocounter{section}{1}%
   \@startsection{section}{1}{\z@}{30\p@}{6\p@}{\sec@rule\nopagebreak\vskip13.5\p@\nopagebreak\SectionHeadFont}*{#1}}
 \def\@section[#1][#2]#3{%
   \if@ChapterTOCs
     \addtocounter{section}{1}%
-    \myaddcontentsline{\@chaptoc}{chapsection}{\string\makebox[\secnumwidth][l]{\thesection}#1}%
+    \myaddcontentsline{\@chaptoc}{chapsection}{\protect\ssubnumberline{\thesection}#1}%
     \addtocounter{section}{-1}\fi
   \@startsection{section}{1}{\z@}{30\p@}{6\p@}{\sec@rule\nopagebreak\vskip13.5\p@\nopagebreak\SectionHeadFont}[#2]{#3}}
 \def\sectionauthor#1{\hfill{\ChapTOCAuthorFont #1}}
     \addtocounter{section}{-1}\fi
   \@startsection{section}{1}{\z@}{30\p@}{6\p@}{\sec@rule\nopagebreak\vskip13.5\p@\nopagebreak\SectionHeadFont}[#2]{#3}}
 \def\sectionauthor#1{\hfill{\ChapTOCAuthorFont #1}}
 \def\@subsection[#1][#2]#3{%
   \if@ChapterTOCs
     \addtocounter{subsection}{1}%
 \def\@subsection[#1][#2]#3{%
   \if@ChapterTOCs
     \addtocounter{subsection}{1}%
-    \myaddcontentsline{\@chaptoc}{chapsubsection}{\string\makebox[\subsecnumwidth][l]{\thesubsection}#1}%
+    \myaddcontentsline{\@chaptoc}{chapsubsection}{\protect\subnumberline{\thesubsection}#1}%
     \addtocounter{subsection}{-1}\fi
   \@startsection{subsection}{2}{\z@}{18\p@}{6\p@}{%
     \SubsectionHeadFont}[#2]{#3}}
     \addtocounter{subsection}{-1}\fi
   \@startsection{subsection}{2}{\z@}{18\p@}{6\p@}{%
     \SubsectionHeadFont}[#2]{#3}}
 \def\@subsubsection[#1][#2]#3{%
   \if@ChapterTOCs
     \addtocounter{subsubsection}{1}%
 \def\@subsubsection[#1][#2]#3{%
   \if@ChapterTOCs
     \addtocounter{subsubsection}{1}%
-    \myaddcontentsline{\@chaptoc}{chapsubsubsection}{\hskip21pt\string\makebox[\ssubsecnumwidth][l]{\thesubsubsection}#1}%
+        \myaddcontentsline{\@chaptoc}{chapsubsubsection}{\protect\subsubnumberline{\thesubsubsection}#1}%
     \addtocounter{subsubsection}{-1}\fi
   \@startsection{subsubsection}{3}{\z@}{12\p@}{6\p@}{%
     \SubsubsectionHeadFont}[#2]{#3}}
     \addtocounter{subsubsection}{-1}\fi
   \@startsection{subsubsection}{3}{\z@}{12\p@}{6\p@}{%
     \SubsubsectionHeadFont}[#2]{#3}}
 \setlength\belowcaptionskip{0\p@}
 \long\def\@makecaption#1#2{%
   \vskip\abovecaptionskip
 \setlength\belowcaptionskip{0\p@}
 \long\def\@makecaption#1#2{%
   \vskip\abovecaptionskip
-  \sbox\@tempboxa{#1: #2}%
+  \sbox\@tempboxa{{\FigCapFont #1} #2}%
   \ifdim \wd\@tempboxa >\hsize
   \ifdim \wd\@tempboxa >\hsize
-    {\FigCapFont #1}: #2\par
+    {\FigCapFont #1} #2\par
   \else
     \global \@minipagefalse
     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
   \else
     \global \@minipagefalse
     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
 \newcounter{numauthors}
 \newif\if@break
 \newif\if@firstauthor
 \newcounter{numauthors}
 \newif\if@break
 \newif\if@firstauthor
-\newcommand\tableofcontents{%
+\newcommand\tableofcontents{\cleardoublepage\thispagestyle{folio}%
+  \gdef\chapterauthor{\@caplusone}%
+  \gdef\endchapterauthors{\end@casplusone}%
+  \make@cornermarks
     \if@twocolumn
       \@restonecoltrue\onecolumn
     \else
       \@restonecolfalse
     \fi
     \if@twocolumn
       \@restonecoltrue\onecolumn
     \else
       \@restonecolfalse
     \fi
-    \chapter*{\contentsname
-        \@mkboth{%
-           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
+      {\parindent \z@ \raggedright \baselineskip 6\p@ \lineskip \z@ \parskip \z@
+    \vbox{
+    \vskip 22\p@
+    \chap@rule
+    \vskip -1\p@
+    \FMHeadFont \contentsname
+    \vskip 59\p@}}%
+%%%    \chapter*{\contentsname
+%%%        \@mkboth{%
+%%%           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
+\markboth{Contents}{Contents}
              {\let\break\space
     \let\author\toc@author
     \reset@authors
              {\let\break\space
     \let\author\toc@author
     \reset@authors
 \toc@draw
  \gdef\toc@draw{\draw@part{\large #1}{\large #2}}}
 
 \toc@draw
  \gdef\toc@draw{\draw@part{\large #1}{\large #2}}}
 
+  \def\l@fm#1#2{%
+  \toc@draw
+  \gdef\toc@draw{\draw@fm{#1}{#2}}}
+\def\@pnumwidth{1.8em}
+\def\draw@fm#1#2{%
+  \addpenalty{-\@highpenalty}%
+  \vskip1em plus\p@
+  \@tempdima1.5em
+  \begingroup
+    \parindent\z@\rightskip\@pnumwidth
+    \parfillskip-\rightskip
+    \bfseries
+    \leavevmode
+    \advance\leftskip\@tempdima
+    \hskip-\leftskip
+    {#1\hfil}\nobreak
+      \if@pdf
+      \else
+        \hfil\nobreak\hb@xt@\@pnumwidth{\hss #2}%
+\fi
+    \par
+    \penalty\@highpenalty\endgroup}
+    
 
   \def\l@chapter#1#2{%
   \toc@draw
 
   \def\l@chapter#1#2{%
   \toc@draw
 }
 \def\draw@authors{%
   \let\@t\@authors
 }
 \def\draw@authors{%
   \let\@t\@authors
-  \ifx\@t\@empty
+        \hskip\leftskip
+  \noindent\vbox{\hsize26pc\raggedright\addvspace{4pt}\ifx\@t\@empty
     \let\@t\last@author\fi
   \ifx\@t\@empty\else
     \hskip\leftskip
     \let\@t\last@author\fi
   \ifx\@t\@empty\else
     \hskip\leftskip
       \if@break\break\fi
       \ and \fi
     \last@author\break\fi
       \if@break\break\fi
       \ and \fi
     \last@author\break\fi
-  \reset@authors}
+  \reset@authors}}
 \def\reset@authors{%
   \gdef\@authors{}%
   \gdef\last@author{}%
 \def\reset@authors{%
   \gdef\@authors{}%
   \gdef\last@author{}%
                                                                     \chapter@authorfour\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfour}
                                                                         \fi
                                                                     \chapter@authorfour\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfour}
                                                                         \fi
- \ifnum\c@numauthors=5
                                                   \ifnum\c@numauthors=5
                                                         \chapter@authorone\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationone}\vskip12\p@
                                                             \chapter@authortwo\vskip6\p@
                                                         \chapter@authorone\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationone}\vskip12\p@
                                                             \chapter@authortwo\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationthree}\vskip12\p@
                                                                     \chapter@authorfour\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfour}\vskip12\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationthree}\vskip12\p@
                                                                     \chapter@authorfour\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfour}\vskip12\p@
-                                                                    \chapter@authorfive\vskip6\p@
+                                                                            \chapter@authorfive\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfive}
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfive}
-                                                                        \fi
- \ifnum\c@numauthors=6
+                                                                        \fi                                                                        
                                                   \ifnum\c@numauthors=6
                                                         \chapter@authorone\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationone}\vskip12\p@
                                                             \chapter@authortwo\vskip6\p@
                                                         \chapter@authorone\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationone}\vskip12\p@
                                                             \chapter@authortwo\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationthree}\vskip12\p@
                                                                     \chapter@authorfour\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfour}\vskip12\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationthree}\vskip12\p@
                                                                     \chapter@authorfour\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfour}\vskip12\p@
-                                                                    \chapter@authorfive\vskip6\p@
+                                                                            \chapter@authorfive\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfive}\vskip12\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfive}\vskip12\p@
-                                                                    \chapter@authorsix\vskip6\p@
+                                                                                    \chapter@authorsix\vskip6\p@
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationsix}
         {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationsix}
-                                                                        \fi
+                                                                        \fi                                                                                                                                                
+                                                    \ifnum\c@numauthors=7
+                                                        \chapter@authorone\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationone}\vskip12\p@
+                                                            \chapter@authortwo\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationtwo}\vskip12\p@
+                                                                \chapter@authorthree\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationthree}\vskip12\p@
+                                                                    \chapter@authorfour\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfour}\vskip12\p@
+                                                                      \chapter@authorfive\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfive}\vskip12\p@
+                                                                       \chapter@authorsix\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationsix}\vskip12\p@
+                                                                               \chapter@authorseven\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationseven}
+                                                                        \fi                                                                                                                                                
+                                                    \ifnum\c@numauthors=8
+                                                        \chapter@authorone\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationone}\vskip12\p@
+                                                            \chapter@authortwo\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationtwo}\vskip12\p@
+                                                                \chapter@authorthree\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationthree}\vskip12\p@
+                                                                    \chapter@authorfour\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfour}\vskip12\p@
+                                                                      \chapter@authorfive\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfive}\vskip12\p@
+                                                                       \chapter@authorsix\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationsix}\vskip12\p@
+                                                                       \chapter@authorseven\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationseven}\vskip12\p@
+                                                                        \chapter@authoreight\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationeight}
+                                                                        \fi                                                                                                                                                
+                                                    \ifnum\c@numauthors=9
+                                                        \chapter@authorone\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationone}\vskip12\p@
+                                                            \chapter@authortwo\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationtwo}\vskip12\p@
+                                                                \chapter@authorthree\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationthree}\vskip12\p@
+                                                                    \chapter@authorfour\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfour}\vskip12\p@
+                                                                      \chapter@authorfive\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationfive}\vskip12\p@
+                                                                       \chapter@authorsix\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationsix}\vskip12\p@
+                                                                       \chapter@authorseven\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationseven}\vskip12\p@
+                                                                        \chapter@authoreight\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationeight}\vskip12\p@
+                                                                        \chapter@authornine\vskip6\p@
+        {\it\fontsize{10\p@}{10\p@}\selectfont\chapter@affiliationnine}
+                                                                        \fi                                                                                                                                                
+                                                                       
 }
  \gdef\chapter@authorone{}\gdef\chapter@affiliationone{}%
  \gdef\chapter@authortwo{}\gdef\chapter@affiliationtwo{}%
  \gdef\chapter@authorthree{}\gdef\chapter@affiliationthree{}%
  \gdef\chapter@authorfour{}\gdef\chapter@affiliationfour{}%
 }
  \gdef\chapter@authorone{}\gdef\chapter@affiliationone{}%
  \gdef\chapter@authortwo{}\gdef\chapter@affiliationtwo{}%
  \gdef\chapter@authorthree{}\gdef\chapter@affiliationthree{}%
  \gdef\chapter@authorfour{}\gdef\chapter@affiliationfour{}%
- \gdef\chapter@authorfive{}\gdef\chapter@affiliationfive{}%
- \gdef\chapter@authorsix{}\gdef\chapter@affiliationsix{}%
+  \gdef\chapter@authorfive{}\gdef\chapter@affiliationfive{}%
+   \gdef\chapter@authorsix{}\gdef\chapter@affiliationsix{}%
+    \gdef\chapter@authorseven{}\gdef\chapter@affiliationseven{}%
+     \gdef\chapter@authoreight{}\gdef\chapter@affiliationeight{}%
+      \gdef\chapter@authornine{}\gdef\chapter@affiliationnine{}%
+       \gdef\chapter@authorten{}\gdef\chapter@affiliationten{}%
+   \gdef\chapter@authoreleven{}\gdef\chapter@affiliationeleven{}%
+    \gdef\chapter@authortwelve{}\gdef\chapter@affiliationtwelve{}%
+     \gdef\chapter@authorthirteen{}\gdef\chapter@affiliationthirteen{}%
+      \gdef\chapter@authorfourteen{}\gdef\chapter@affiliationfourteen{}%
+       \gdef\chapter@authorfifteen{}\gdef\chapter@affiliationfifteen{}%       
+
   \vskip 14.6\p@
 {\leftskip\secnumwidth\def\author##1##2{}\@input{\thechapter.toc}\par}%
   }
   \vskip 14.6\p@
 {\leftskip\secnumwidth\def\author##1##2{}\@input{\thechapter.toc}\par}%
   }
 %
 \newif\iffinishedfromsix
 \global\finishedfromsixfalse
 %
 \newif\iffinishedfromsix
 \global\finishedfromsixfalse
+%
+\newif\iffinishedfromseven
+\global\finishedfromsevenfalse
+%
+\newif\iffinishedfromeight
+\global\finishedfromeightfalse
+%
+\newif\iffinishedfromnine
+\global\finishedfromninefalse
+%
+\newif\iffinishedfromten
+\global\finishedfromtenfalse
+%
+\newif\iffinishedfromeleven
+\global\finishedfromelevenfalse
+%
+\newif\iffinishedfromtwelve
+\global\finishedfromtwelvefalse
+%
+\newif\iffinishedfromthirteen
+\global\finishedfromthirteenfalse
+%
+\newif\iffinishedfromfourteen
+\global\finishedfromfourteenfalse
+%
+\newif\iffinishedfromfifteen
+\global\finishedfromfifteenfalse
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-\newcommand\singleauthorchapter{\finishedfromonetrue}
-\newcommand\twoauthorchapter{\finishedfromtwotrue}
-\newcommand\threeauthorchapter{\finishedfromthreetrue}
-\newcommand\fourauthorchapter{\finishedfromfourtrue}
-\newcommand\fiveauthorchapter{\finishedfromfivetrue}
-\newcommand\sixauthorchapter{\finishedfromsixtrue}
+\def\singleauthorchapter{\finishedfromonetrue}
+\def\twoauthorchapter{\finishedfromtwotrue}
+\def\threeauthorchapter{\finishedfromthreetrue}
+\def\fourauthorchapter{\finishedfromfourtrue}
+\def\fiveauthorchapter{\finishedfromfivetrue}
+\def\sixauthorchapter{\finishedfromsixtrue}
+\def\sevenauthorchapter{\finishedfromseventrue}
+\def\eightauthorchapter{\finishedfromeighttrue}
+\def\nineauthorchapter{\finishedfromninetrue}
+\def\tenauthorchapter{\finishedfromtentrue}
+\def\elevenauthorchapter{\finishedfromeleventrue}
+\def\twelveauthorchapter{\finishedfromtwelvetrue}
+\def\thirteenauthorchapter{\finishedfromthirteentrue}
+\def\fourteenauthorchapter{\finishedfromfourteentrue}
+\def\fifteenauthorchapter{\finishedfromfifteentrue}
 %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \newif\iffinish
 %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \newif\iffinish
 \newsavebox\@AUfourbox
 \newsavebox\@AUfivebox
 \newsavebox\@AUsixbox
 \newsavebox\@AUfourbox
 \newsavebox\@AUfivebox
 \newsavebox\@AUsixbox
+\newsavebox\@AUsevenbox
+\newsavebox\@AUeightbox
+\newsavebox\@AUninebox
+\newsavebox\@AUtenbox
+\newsavebox\@AUelevenbox
+\newsavebox\@AUtwelvebox
+\newsavebox\@AUthirteenbox
+\newsavebox\@AUfourteenbox
+\newsavebox\@AUfifteenbox
+
 %
 \newsavebox\@AUaffonebox
 \newsavebox\@AUafftwobox
 %
 \newsavebox\@AUaffonebox
 \newsavebox\@AUafftwobox
 \newsavebox\@AUafffourbox
 \newsavebox\@AUafffivebox
 \newsavebox\@AUaffsixbox
 \newsavebox\@AUafffourbox
 \newsavebox\@AUafffivebox
 \newsavebox\@AUaffsixbox
+\newsavebox\@AUaffsevenbox
+\newsavebox\@AUaffeightbox
+\newsavebox\@AUaffninebox
+\newsavebox\@AUafftenbox
+\newsavebox\@AUaffelevenbox
+\newsavebox\@AUafftwelvebox
+\newsavebox\@AUaffthirteenbox
+\newsavebox\@AUafffourteenbox
+\newsavebox\@AUafffifteenbox
+
 %
 \newsavebox\@finalAUboxfromone
 \newsavebox\@finalAUboxfromtwo
 %
 \newsavebox\@finalAUboxfromone
 \newsavebox\@finalAUboxfromtwo
 \newsavebox\@finalAUboxfromfour
 \newsavebox\@finalAUboxfromfive
 \newsavebox\@finalAUboxfromsix
 \newsavebox\@finalAUboxfromfour
 \newsavebox\@finalAUboxfromfive
 \newsavebox\@finalAUboxfromsix
+\newsavebox\@finalAUboxfromseven
+\newsavebox\@finalAUboxfromeight
+\newsavebox\@finalAUboxfromnine
+\newsavebox\@finalAUboxfromten
+\newsavebox\@finalAUboxfromeleven
+\newsavebox\@finalAUboxfromtwelve
+\newsavebox\@finalAUboxfromthirteen
+\newsavebox\@finalAUboxfromfourteen
+\newsavebox\@finalAUboxfromfifteen
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 \def\@ca#1#2{%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 \def\@ca#1#2{%
   \fi
 %%%%%%%%%%%%%%%
 
   \fi
 %%%%%%%%%%%%%%%
 
-\ifnum\c@numauthors>6
-    %\setcounter{numauthors}{0}
+\ifnum\c@numauthors>8
     \resetcounter{numauthors}
 \fi 
 \stepcounter{numauthors}
     \resetcounter{numauthors}
 \fi 
 \stepcounter{numauthors}
     \def\chapter@authorfive{\copy\@finalAUboxfromfive}
     \def\chapter@affiliationfive{\copy\@AUafffivebox}
 \fi \ifnum\c@numauthors=6
     \def\chapter@authorfive{\copy\@finalAUboxfromfive}
     \def\chapter@affiliationfive{\copy\@AUafffivebox}
 \fi \ifnum\c@numauthors=6
-    \sbox\@AUsixbox{\CAPlusOneFont#1}
+    \sbox\@AUsixbox{\vbox{\hsize\textwidth\CAPlusOneFont\raggedright\noindent \CAPlusOneFont#1}}
     \sbox\@AUaffsixbox{\vbox{\hsize\textwidth\CAAPlusOneFont\noindent #2\par}}
     \sbox\@finalAUboxfromsix{\copy\@AUsixbox}
     \def\chapter@authorsix{\copy\@finalAUboxfromsix}
     \def\chapter@affiliationsix{\copy\@AUaffsixbox}
     \sbox\@AUaffsixbox{\vbox{\hsize\textwidth\CAAPlusOneFont\noindent #2\par}}
     \sbox\@finalAUboxfromsix{\copy\@AUsixbox}
     \def\chapter@authorsix{\copy\@finalAUboxfromsix}
     \def\chapter@affiliationsix{\copy\@AUaffsixbox}
-\fi
-}
+\fi \ifnum\c@numauthors=7
+    \sbox\@AUsevenbox{\vbox{\hsize\textwidth\CAPlusOneFont\raggedright\noindent \CAPlusOneFont#1}}
+    \sbox\@AUaffsevenbox{\vbox{\hsize\textwidth\CAAPlusOneFont\noindent #2\par}}
+    \sbox\@finalAUboxfromseven{\copy\@AUsevenbox}
+    \def\chapter@authorseven{\copy\@finalAUboxfromseven}
+    \def\chapter@affiliationseven{\copy\@AUaffsevenbox}
+\fi \ifnum\c@numauthors=8
+    \sbox\@AUeightbox{\vbox{\hsize\textwidth\CAPlusOneFont\raggedright\noindent \CAPlusOneFont#1}}
+    \sbox\@AUaffeightbox{\vbox{\hsize\textwidth\CAAPlusOneFont\noindent #2\par}}
+    \sbox\@finalAUboxfromeight{\copy\@AUeightbox}
+    \def\chapter@authoreight{\copy\@finalAUboxfromeight}
+    \def\chapter@affiliationeight{\copy\@AUaffeightbox}
+\fi \ifnum\c@numauthors=9
+    \sbox\@AUninebox{\vbox{\hsize\textwidth\CAPlusOneFont\raggedright\noindent \CAPlusOneFont#1}}
+    \sbox\@AUaffninebox{\vbox{\hsize\textwidth\CAAPlusOneFont\noindent #2\par}}
+    \sbox\@finalAUboxfromnine{\copy\@AUninebox}
+    \def\chapter@authornine{\copy\@finalAUboxfromnine}
+    \def\chapter@affiliationnine{\copy\@AUaffninebox}
+\fi}
 
 
 \def\@caplusone{\@ifstar{\@scaplusone}{\@ifnextchar[{\@xcaplusone}{\@xcaplusone[]}}}
 
 
 \def\@caplusone{\@ifstar{\@scaplusone}{\@ifnextchar[{\@xcaplusone}{\@xcaplusone[]}}}
 }
 
 \def\chapterauthoronly#1#2{\@ca{#1}{}\@scaplusone{#1}{#2}}
 }
 
 \def\chapterauthoronly#1#2{\@ca{#1}{}\@scaplusone{#1}{#2}}
-\def\myaddcontentsline#1#2#3{%
+\def\myaddcontentsline#1#2#3{\pagebreak[3]%
   \if@filesw
     \begingroup
     \let\label\@gobble\let\index\@gobble\let\glossary\@gobble
   \if@filesw
     \begingroup
     \let\label\@gobble\let\index\@gobble\let\glossary\@gobble
 \def\@mydottedtocline#1#2#3#4#5{%
   \ifnum #1>\c@chaptocdepth
   \else
 \def\@mydottedtocline#1#2#3#4#5{%
   \ifnum #1>\c@chaptocdepth
   \else
-    \vskip 2pt plus.2\p@
-{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -21pt %-\rightskip
-%      \parindent #2\relax\@afterindenttrue
+\fontsize{10}{12}\selectfont
+{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
+     % \parindent #2\relax\@afterindenttrue
       \interlinepenalty\@M
       \leavevmode
       \def\@dotsep{1.2}%
       \@tempdima #3\relax
       \rightskip\z@
       \interlinepenalty\@M
       \leavevmode
       \def\@dotsep{1.2}%
       \@tempdima #3\relax
       \rightskip\z@
-      \advance\hsize-\secnumwidth
-      {\fontsize{9.5\p@}{\baselineskip}\selectfont #4
-         \nobreak\leaders\hbox{$\m@th\mkern\@dotsep mu.\mkern\@dotsep mu$}
-\hfill\hbox to 1.5pc{\hfill#5}}
-      \par}\fi}
+%      \advance\hsize-\secnumwidth
+%      \hskip-\secnumwidth
+\if@sevenbyten
+\hangindent\secnumwidth\hsize372pt\else\hangindent\secnumwidth\hsize312pt\fi 
+#4
+        \if@pdf
+          \hfill
+        \else
+          \nobreak\leaders\hbox{$\m@th\mkern\@dotsep mu.\mkern\@dotsep mu$}\hfill\nobreak
+          \hbox to24\p@{\hfil #5}\fi
+      \par}\fi}      
+
+\newcommand\halftitle{\clearpage\thispagestyle{empty}%
+      {\parindent \z@ \raggedright \baselineskip 6\p@ \lineskip \z@ \parskip \z@
+    \vbox{
+    \vskip 22\p@
+    \chap@rule
+    \vskip -1\p@
+    \FMHeadFont Half Title Page
+    \vskip 59\p@}}%
+    }
+    
+    \newcommand\booktitle{\cleardoublepage\thispagestyle{empty}%
+      {\parindent \z@ \raggedright \baselineskip 6\p@ \lineskip \z@ \parskip \z@
+    \vbox{
+    \vskip 22\p@
+    \chap@rule
+    \vskip -1\p@
+    \FMHeadFont Title Page
+    \vskip 59\p@}}%
+    }
+    
+\newcommand\dedication[1]{\clearpage\thispagestyle{empty}
+\vbox{\centering\addvspace{1in}\large #1}}
+
+\newcommand\locpage{\clearpage\thispagestyle{empty}%
+  {\parindent \z@ \raggedright \baselineskip 6\p@ \lineskip \z@ \parskip \z@
+    \vbox{
+    \vskip 22\p@
+    \chap@rule
+    \vskip -1\p@
+    \FMHeadFont LOC Page
+    \vskip 59\p@}}%
+    }
 
 \newcommand\listoffigures{%
     \if@twocolumn
 
 \newcommand\listoffigures{%
     \if@twocolumn
     \@starttoc{lof}%
     \if@restonecol\twocolumn\fi
     }
     \@starttoc{lof}%
     \if@restonecol\twocolumn\fi
     }
-\newcommand*\l@figure{\@dottedtocline{1}{1.5em}{2.8em}}
+\newcommand*\l@figure{\@dottedtocline{1}{1.5em}{2.9em}}
 \newcommand\listoftables{%
     \if@twocolumn
       \@restonecoltrue\onecolumn
 \newcommand\listoftables{%
     \if@twocolumn
       \@restonecoltrue\onecolumn
 \newenvironment{thebibliography}[1]
      {\chapter*{\bibname}%
       \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
 \newenvironment{thebibliography}[1]
      {\chapter*{\bibname}%
       \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
-       \addcontentsline{toc}{section}{\bibname}
+%%%       \addcontentsline{toc}{chapter}{\bibname}
       \list{\@biblabel{\@arabic\c@enumiv}}%
            {\settowidth\labelwidth{\@biblabel{#1}}%
             \leftmargin\labelwidth
       \list{\@biblabel{\@arabic\c@enumiv}}%
            {\settowidth\labelwidth{\@biblabel{#1}}%
             \leftmargin\labelwidth
                 \twocolumn[\@makeschapterhead{\indexname}]%
                 \@mkboth{\MakeUppercase\indexname}%
                         {\MakeUppercase\indexname}%
                 \twocolumn[\@makeschapterhead{\indexname}]%
                 \@mkboth{\MakeUppercase\indexname}%
                         {\MakeUppercase\indexname}%
+                        \markboth{Index}{Index}
                         \pagestyle{headings}
                         \addcontentsline{toc}{chapter}{\indexname}
                         \pagestyle{headings}
                         \addcontentsline{toc}{chapter}{\indexname}
-                \thispagestyle{folio}\parindent\z@
+                \thispagestyle{folio}\parindent\z@\raggedright
                 \parskip\z@ \@plus .3\p@\relax
                 \columnseprule \z@
                 \columnsep 35\p@
                 \parskip\z@ \@plus .3\p@\relax
                 \columnseprule \z@
                 \columnsep 35\p@
   \vskip 0pt plus 12pt
   \gdef\@Tabletitle{}}
 
   \vskip 0pt plus 12pt
   \gdef\@Tabletitle{}}
 
+\def\tch#1{\TableColHeadFont #1\llstrut\hfill}
+\def\tsh#1{\TableSubheadFont #1\hfill}
+\newcommand\llstrut{\rule[-6pt]{0pt}{14pt}}
+\newcommand\flstrut{\rule{0pt}{10pt}}
+\newcommand\tabletitlestrut{\rule{0pt}{20pt}}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newdimen\concolwidth
+\newbox\stempbox
+\def\contributor#1#2#3{\addvspace{10pt}{%
+\setbox\stempbox\hbox{\ContributorAffiliationFont #2}
+\concolwidth\wd\stempbox
+  \noindent{\ContributorNameFont #1}\par
+  \ifdim\concolwidth>\columnwidth \vspace*{3pt} \else \fi
+  \noindent{\vbox{\hangindent12pt\ContributorAffiliationFont #2}}\vskip-1\p@
+  \noindent{\vbox{\hangindent12pt\ContributorAffiliationFont #3}}}}
+
+
 \def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
     \hbox{}\thispagestyle{empty}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
     
 \def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
     \hbox{}\thispagestyle{empty}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
     
 \tolerance=5000    
 \raggedbottom
 
 \tolerance=5000    
 \raggedbottom
 
-\def\tch#1{\TableColHeadFont #1\llstrut\hfill}
-\def\tsh#1{\TableSubheadFont #1\hfill}
-\newcommand\llstrut{\rule[-6pt]{0pt}{14pt}}
-\newcommand\flstrut{\rule{0pt}{10pt}}
-\newcommand\tabletitlestrut{\rule{0pt}{20pt}}
+
 \@centertabletitlefalse
 \HeadingsBookChapter
 %\HeadingsChapterSection
 \endinput
 %%
 %% End of file `sunil.cls'.
 \@centertabletitlefalse
 \HeadingsBookChapter
 %\HeadingsChapterSection
 \endinput
 %%
 %% End of file `sunil.cls'.
-\0\0\0\0\0\0\0\0\0
+\0\0\0\0\0\0\0\0\0
\ No newline at end of file