\begin{algorithm}
\SetNlSty{}{}{:}
- allocate and populate CPU memory \textbf{h\_in}\;\\
- allocate CPU pinned-memory \textbf{h\_out}\;\\
- allocate GPU global memory \textbf{d\_out}\;\\
- declare GPU texture reference \textbf{tex\_img\_in}\;\\
- allocate GPU array in global memory \textbf{array\_img\_in}\;\\
- bind GPU array \textbf{array\_img\_in} to texture \textbf{tex\_img\_in}\;\\
- copy data from \textbf{h\_in} to \textbf{array\_img\_in}\label{algo:memcopy:H2D}\;\\
- kernel\kl gridDim,blockDim\kr()\tcc*[f]{outputs to d\_out}\label{algo:memcopy:kernel}\;\\
- copy data from \textbf{d\_out} to \textbf{h\_out} \label{algo:memcopy:D2H}\;\\
+ allocate and populate CPU memory \textbf{h\_in}\;
+ allocate CPU pinned-memory \textbf{h\_out}\;
+ allocate GPU global memory \textbf{d\_out}\;
+ declare GPU texture reference \textbf{tex\_img\_in}\;
+ allocate GPU array in global memory \textbf{array\_img\_in}\;
+ bind GPU array \textbf{array\_img\_in} to texture \textbf{tex\_img\_in}\;
+ copy data from \textbf{h\_in} to \textbf{array\_img\_in}\label{algo:memcopy:H2D}\;
+ kernel\kl gridDim,blockDim\kr()\tcc*[f]{outputs to d\_out}\label{algo:memcopy:kernel}\;
+ copy data from \textbf{d\_out} to \textbf{h\_out} \label{algo:memcopy:D2H}\;
\caption{Global memory management on CPU and GPU sides.}
\label{algo:memcopy}
\end{algorithm}
%\SetNlSty{}{}{:}
% \SetLine
%\linesnumbered
- copy data from CPU to GPU texture memory\label{algoMedianGeneric:memcpyH2D}\;\\
+ copy data from CPU to GPU texture memory\label{algoMedianGeneric:memcpyH2D}\;
\ForEach(\tcc*[f]{in parallel}){pixel at position $(x, y)$}{
- Read gray-level values of the n$\times$n neighborhood\label{algoMedianGeneric:cptstart}\;\\
- Selects the median value among those n$\times$n values\;\\
- Outputs the new gray-level value \label{algoMedianGeneric:cptend}\;\\
+ Read gray-level values of the n$\times$n neighborhood\label{algoMedianGeneric:cptstart}\;
+ Selects the median value among those n$\times$n values\;
+ Outputs the new gray-level value \label{algoMedianGeneric:cptend}\;
}
-copy data from GPU global memory to CPU memory\label{algoMedianGeneric:memcpyD2H}\;\\
+copy data from GPU global memory to CPU memory\label{algoMedianGeneric:memcpyD2H}\;
\caption{\label{algoMedianGeneric}generic n$\times$n median filter}
\end{algorithm}