From 11bf000acddf9ee6b14cf8c3ca3ab2674f686b47 Mon Sep 17 00:00:00 2001 From: couturie Date: Sun, 22 Sep 2013 13:14:06 +0200 Subject: [PATCH] last --- BookGPU/Chapters/chapter18/biblio18.bib | 2 +- BookGPU/Chapters/chapter18/ch18.tex | 6 +++--- BookGPU/Chapters/chapter19/biblio.bib | 2 +- BookGPU/Chapters/chapter19/ch19.tex | 24 +++++++++++++----------- BookGPU/Chapters/chapter9/ch9.tex | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/BookGPU/Chapters/chapter18/biblio18.bib b/BookGPU/Chapters/chapter18/biblio18.bib index 885a3d2..8c9ac95 100644 --- a/BookGPU/Chapters/chapter18/biblio18.bib +++ b/BookGPU/Chapters/chapter18/biblio18.bib @@ -234,7 +234,7 @@ equipe = {and}, classement = {ACTI}, author = {Bahi, J. and Fang, X. and Guyeux, C.}, title = {An optimization technique on pseudorandom generators based on chaotic iterations}, -booktitle = {INTERNET'2012, 4-th Int. Conf. on Evolving Internet}, +booktitle = {INTERNET'2012, 4th Int. Conf. on Evolving Internet}, pages = {31--36}, address = {Venice, Italy}, month = jun, diff --git a/BookGPU/Chapters/chapter18/ch18.tex b/BookGPU/Chapters/chapter18/ch18.tex index 7c2a393..9e92d3e 100755 --- a/BookGPU/Chapters/chapter18/ch18.tex +++ b/BookGPU/Chapters/chapter18/ch18.tex @@ -13,14 +13,14 @@ generated by either a deterministic and reproducible algorithm called a pseudorandom number generator (PRNG)\index{PRNG}, or by a physical nondeterministic process having all the characteristics of a random noise, called a truly random number generator (TRNG). In this chapter, we focus on -reproducible generators, useful for instance in MonteCarlo-based +reproducible generators, useful for instance in Monte Carlo-based simulators. These domains need PRNGs that are statistically irreproachable. In some fields such as in numerical simulations, speed is a strong requirement that is usually attained by using parallel architectures. In that case, a recurrent problem is that a deflation of the statistical qualities is often reported, when the parallelization of a good PRNG is realized. This -is why adhoc PRNGs for each possible architecture must be found to +is why ad hoc PRNGs for each possible architecture must be found to achieve both speed and randomness. On the other hand, speed is not the main requirement in cryptography: the most important point is to define \emph{secure} generators able to withstand malicious @@ -252,7 +252,7 @@ satisfies the Devaney's definition of chaos. In Listing~\ref{algo:seqCIPRNG} a sequential version of the proposed PRNG based on chaotic iterations is presented, which extends the generator family -formerly presented in~\cite{bgw09:ip,guyeux10}. The xor operator is represented by +formerly presented in~\cite{bgw09:ip,guyeux10}. The \texttt{xor} operator is represented by \textasciicircum. This function uses three classical 64-bit PRNGs, namely the \texttt{xorshift}, the \texttt{xor128}, and the \texttt{xorwow}~\cite{Marsaglia2003}. In the following, we call them ``xor-like diff --git a/BookGPU/Chapters/chapter19/biblio.bib b/BookGPU/Chapters/chapter19/biblio.bib index 7b1e2aa..9ec1a28 100644 --- a/BookGPU/Chapters/chapter19/biblio.bib +++ b/BookGPU/Chapters/chapter19/biblio.bib @@ -195,7 +195,7 @@ @InProceedings{ch19:aoki, author = {Aoki, K. and Shimoyama, T. and Ueda, H.}, title = {Experiments on the Linear Algebra Step in the Number Field Sieve}, - booktitle = {Proceedings of the Security 2nd international conference on Advances in information and computer security}, + booktitle = {Proceedings of the Security 2nd International Conference on Advances in Information and Computer Security}, series = {IWSEC'07}, year = {2007}, isbn = {3-540-75650-7, 978-3-540-75650-7}, diff --git a/BookGPU/Chapters/chapter19/ch19.tex b/BookGPU/Chapters/chapter19/ch19.tex index 40912bd..307b851 100755 --- a/BookGPU/Chapters/chapter19/ch19.tex +++ b/BookGPU/Chapters/chapter19/ch19.tex @@ -80,7 +80,7 @@ We can treat $x$, $y$, and $S_i$ as vectors of block width $m$ or $n$. Assuming $Y[i]=0$\; \ForAll {$ind$ $\in$ $c\_index[i]$} { $Y[i] = Y[i] \oplus X[ind]$\; - \CommentSty{$\oplus:$ bitwise xor operation} + \CommentSty{$\oplus:$ bitwise XOR operation} } } % \end{algorithmic} @@ -168,7 +168,7 @@ For each nonzero, both its column and row indices are explicitly stored. The Cus Avg row weight & 95.08 & 93.6 & 143 & 144\\ \hline \end{tabular} - \caption{Properties of some NFS matrices} + \caption{Properties of some NFS matrices.} \label{table:rsa_matrix} \end{table} @@ -189,9 +189,9 @@ As a preprocessing step, we reorder the rows of the matrix by their \emph{row we \subsection{Dense format} The dense format is used for the dense part of the matrix. This format uses 1 bit per matrix entry. Within a column, 32 matrix entries are stored as a 32-bit integer. Thus, 32 rows are stored as $N$ consecutive integers. - Each CUDA thread works on a column. Each thread fetches one element from the input vector in coalesced fashion. Then, each thread checks the 32 matrix entries one by one. When the matrix entry is a nonzero, the thread performs an xor operation between the element from the input vector and the partial result for the row. This means each thread accesses the input vector only once to do work on up to 32 nonzeros. The partial result from each thread needs to be stored and combined to get the final result for the 32 rows. These operations are performed in CUDA shared memory. + Each CUDA thread works on a column. Each thread fetches one element from the input vector in coalesced fashion. Then, each thread checks the 32 matrix entries one by one. When the matrix entry is a nonzero, the thread performs an XOR operation between the element from the input vector and the partial result for the row. This means each thread accesses the input vector only once to do work on up to 32 nonzeros. The partial result from each thread needs to be stored and combined to get the final result for the 32 rows. These operations are performed in CUDA shared memory. - The 32 threads in a warp share 32 shared memory entries to store the partial results from the 32 rows. Since all threads in a warp execute a common instruction at the same time, access to these 32 entries can be made exclusive. The result from each warp in a thread block is combined using p-reduction on shared memory. The result from each thread block is combined using an atomic xor operation on global memory. + The 32 threads in a warp share 32 shared memory entries to store the partial results from the 32 rows. Since all threads in a warp execute a common instruction at the same time, access to these 32 entries can be made exclusive. The result from each warp in a thread block is combined using p-reduction on shared memory. The result from each thread block is combined using an atomic XOR operation on global memory. When the blocking factor is larger than 64, access to the shared memory needs to be reorganized to avoid bank conflicts. Each thread can read/write up to 64-bit data at a time to the shared memory. If a thread is accessing 128-bit data for example, two read/write operations need to be performed. Thus, there will be bank conflicts if we store 128-bit data on contiguous addresses. We can avoid bank conflicts by having the threads in a warp first access consecutive 64-bit elements representing the first halves of the 128-bit elements. Then, the threads again access consecutive 64-bit elements representing the second halves of the 128-bit elements. The same modification can be applied to other formats as well. @@ -212,7 +212,7 @@ As a preprocessing step, we reorder the rows of the matrix by their \emph{row we One thread block works on a slice, one group at a time. Neighboring threads work on neighboring nonzeros in the group in parallel. Each thread works on more than one row of the matrix. Thus, each thread needs some storage to store the partial results and combine them with the results from the other threads to generate the final output. Each entry costs equally as the element of the vector, i.e., the blocking factor in bytes. Shared memory is used as intermediate storage as it has low latency however it is limited to 48 KB per SM in Fermi. The global memory is accessed only once at the end to write the final output. The CUDA kernel for SpMV with Sliced COO format is shown in Listing \ref{ch19:lst:spmv}. - Since neighboring nonzeros may or may not come from the same row (recall that we sorted them by column index), many threads may access the same entry in the shared memory if it is used to store result of the same rows. Thus, shared memory entries are either assigned exclusively to a single thread or shared by using atomic xor operations. Based on the way we allocate the shared memory, we further divide the Sliced COO format into three different subformats: small, medium, and large. + Since neighboring nonzeros may or may not come from the same row (recall that we sorted them by column index), many threads may access the same entry in the shared memory if it is used to store result of the same rows. Thus, shared memory entries are either assigned exclusively to a single thread or shared by using atomic XOR operations. Based on the way we allocate the shared memory, we further divide the Sliced COO format into three different subformats: small, medium, and large. \begin{table} \centering @@ -222,7 +222,7 @@ As a preprocessing step, we reorder the rows of the matrix by their \emph{row we Sliced COO subformats & Small & Medium & Large \\ \hline Memory sharing & No sharing & Among warp & Among block\\ - Access method & Direct & Atomic xor & Atomic xor\\ + Access method & Direct & Atomic XOR & Atomic XOR\\ Bank conflict & No & No & Yes\\ \# Rows per Slice & 12 & 192 & 6144 \\ \hline @@ -237,20 +237,20 @@ As a preprocessing step, we reorder the rows of the matrix by their \emph{row we The maximum number of rows per slice is calculated as \emph{size of shared memory per SM in bits} / \emph{(number of threads per block * blocking factor)}. We use 512 threads per block for 64-bit blocking factor which gives 12 rows, and 256 threads per block for 128 and 256-bit blocking factor, which gives 12 and 6 rows, respectively. Hence, one byte per row index is sufficient for this subformat. \subsubsection*{Medium sliced (MS) COO} - In this subformat, each thread in a warp gets an entry in the shared memory to store the partial result for each row. However, this entry is shared with the threads in other warps. Access to the shared memory uses an atomic xor operation. Each thread in a warp accesses only one bank, avoiding bank conflicts. A p-reduction operation on shared memory is required to combine the 32 partial results. + In this subformat, each thread in a warp gets an entry in the shared memory to store the partial result for each row. However, this entry is shared with the threads in other warps. Access to the shared memory uses an atomic XOR operation. Each thread in a warp accesses only one bank, avoiding bank conflicts. A p-reduction operation on shared memory is required to combine the 32 partial results. The maximum number of rows per slice is calculated as \emph{size of shared memory per SM in bits} / \emph{(32 * blocking factor)} where 32 is the number of threads in a warp. This translates to 192, 96, and 48 rows per slice for blocking factors of 64, 128, and 256-bits, respectively. Hence, one byte per row index is sufficient for this format. \subsubsection*{Large sliced (LS) COO} - In this subformat, the result for each row gets one entry in shared memory, which is shared among all threads in the thread block. Access to shared memory uses an atomic xor operation. Thus, there will be bank conflicts. However, this drawback can be compensated for by a higher texture cache hit rate. There is no p-reduction on shared memory required. + In this subformat, the result for each row gets one entry in shared memory, which is shared among all threads in the thread block. Access to shared memory uses an atomic XOR operation. Thus, there will be bank conflicts. However, this drawback can be compensated for by a higher texture cache hit rate. There is no p-reduction on shared memory required. The maximum number of rows per slice is calculated as \emph{size of shared memory per SM in bits} / \emph{blocking factor}. This translates to 6144, 3072, and 1536 rows per slice for blocking factors of 64, 128, and 256-bits, respectively. We need two bytes for the row index. \noindent Table \ref{table:scoo} summarizes the differences between the three subformats. \begin{itemize} \item[a)] Each thread in a block is allocated one memory entry for the result of a row and works on consecutive 12 rows. A p-reduction to Thread\#1 is needed to get the final result of one row. - \item[b)] Each warp in a block is allocated one memory entry per row and works on 192 consecutive rows, threads in each warp use atomic xor to update the value in a given entry. A p-reduction for each row to memory in Warp\#1 is needed to obtain the final result of that row. - \item[c)] A thread block works on 6144 consecutive rows and shares the memory entry of each row. Any update to the memory has to use atomic xor. + \item[b)] Each warp in a block is allocated one memory entry per row and works on 192 consecutive rows, threads in each warp use atomic XOR to update the value in a given entry. A p-reduction for each row to memory in Warp\#1 is needed to obtain the final result of that row. + \item[c)] A thread block works on 6144 consecutive rows and shares the memory entry of each row. Any update to the memory has to use atomic XOR. \end{itemize} \subsection{Determining the cut-off point of each format} @@ -335,7 +335,7 @@ The speedups compared to the multithreaded CADO-NFS bucket implementation on an Table \ref{table:rsa170} shows the result. The dual-GPU implementation achieves speedups between 1.93 and 1.96 compared to the single-GPU performance. - Table \ref{table:individual} shows the individual performance of each subformat (in \emph{gnnz/s}), the percentage of nonzeros are included in parentheses. The results show that the performance decreases when the matrix gets sparser. The MS-COO and LS-COO performance degrade when the blocking factor is increased from 64 to 128 and 256-bit. This is caused by the increased number of bank conflicts and serialization of atomic xor operations on larger blocking factors. Thus, the SS-COO format gets a higher percentage of nonzeros with 128 and 256-bit blocking factor. + Table \ref{table:individual} shows the individual performance of each subformat (in \emph{gnnz/s}), the percentage of nonzeros are included in parentheses. The results show that the performance decreases when the matrix gets sparser. The MS-COO and LS-COO performance degrade when the blocking factor is increased from 64 to 128 and 256-bit. This is caused by the increased number of bank conflicts and serialization of atomic XOR operations on larger blocking factors. Thus, the SS-COO format gets a higher percentage of nonzeros with 128 and 256-bit blocking factor. More detail results of our full block Wiedemann CUDA implementation as well as a multi-GPU implementation can be found in \cite{ch19:spmv-ccpe} @@ -370,6 +370,7 @@ We compare the performance of our SCOO format to available SpMV implementations \begin{table} \begin{center} +\begin{small} \begin{tabular}{|l|n{8}{0}|n{9}{0}|n{3}{2}|l|} \hline {Name} & row & column & nz/row & Description \\ @@ -403,6 +404,7 @@ rgg\_n\_2\_24\_s0 &16777216&16777216&15.80&undirected random\\ uk-2002 &18520486&18520486&16.10&directed graph\\ \hline \end{tabular} +\end{small} \end{center} \caption{Overview of sparse matrices used for performance evaluation.} \label{table:matrices} diff --git a/BookGPU/Chapters/chapter9/ch9.tex b/BookGPU/Chapters/chapter9/ch9.tex index 2d44381..0ebc446 100644 --- a/BookGPU/Chapters/chapter9/ch9.tex +++ b/BookGPU/Chapters/chapter9/ch9.tex @@ -1026,7 +1026,7 @@ it is sent back to the CPU which selects the best solution (See Figure~\ref{ch1:fig:paradiseoGPU}). \subsection{libCUDAOptimize: an open source library of GPU-based metaheuristics} -\index{GPU-based frameworks!libCudaOptimize} +\index{GPU-based frameworks!libCUDAOptimize} LibCUDAOptimize~\cite{libcuda} is a C++/CUDA open source library for the design and implementation of metaheuristics on GPUs. Until now, the metaheuristics supported by LibCUDAOptimize are: scatter -- 2.39.5