-\lstset{language=C,caption={C code of the sequential PRNG based on chaotic iterations},label={algo:seqCIPRNG}}
-\begin{small}
-\begin{lstlisting}
-
-unsigned int CIPRNG() {
- static unsigned int x = 123123123;
- unsigned long t1 = xorshift();
- unsigned long t2 = xor128();
- unsigned long t3 = xorwow();
- x = x^(unsigned int)t1;
- x = x^(unsigned int)(t2>>32);
- x = x^(unsigned int)(t3>>32);
- x = x^(unsigned int)t2;
- x = x^(unsigned int)(t1>>32);
- x = x^(unsigned int)t3;
- return x;
-}
-\end{lstlisting}
-\end{small}
-
+\lstinputlisting[label=algo:seqCIPRNG,caption={C code of the sequential PRNG based on chaotic iterations}]{Chapters/chapter18/code2.cu}
In Listing~\ref{algo:seqCIPRNG} a sequential version of the proposed PRNG based
more local memory is used, and the less branching instructions are
used (if, while, etc.) and so, the better the performances on GPU are.
Obviously, having these requirements in mind, it is possible to build
-a program similar to the one presented in Listing
-\ref{algo:seqCIPRNG}, which computes pseudorandom numbers on GPU. To
+a program similar to the one presented in Listing~\ref{algo:seqCIPRNG}, which computes pseudorandom numbers on GPU. To
do so, we must first recall that in the CUDA~\cite{Nvid10}
environment, threads have a local identifier called
\texttt{ThreadIdx}, which is relative to the block containing
\If{threadIdx is concerned by the computation} {
retrieve data from InternalVarXorLikeArray[threadIdx] in local variables\;
\For{i=1 to n} {
- compute a new PRNG as in Listing\ref{algo:seqCIPRNG}\;
+ compute a new PRNG as in Listing~\ref{algo:seqCIPRNG}\;
store the new PRNG in NewNb[NumThreads*threadIdx+i]\;
}
store internal variables in InternalVarXorLikeArray[threadIdx]\;