paper.tex 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. \documentclass{JINST}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage{lineno}
  4. \usepackage{ifthen}
  5. \usepackage{caption}
  6. \usepackage{subcaption}
  7. \usepackage{textcomp}
  8. \usepackage{booktabs}
  9. \newboolean{draft}
  10. \setboolean{draft}{true}
  11. \newcommand{\figref}[1]{Figure~\ref{#1}}
  12. \title{A high-throughput readout architecture based on PCI-Express Gen3 and DirectGMA technology}
  13. \author{
  14. L.~Rota$^a$,
  15. M.~Vogelgesang$^a$,
  16. L.E.~Ardila Perez$^a$,
  17. M.~Caselle$^a$,
  18. S.~Chilingaryan$^a$,
  19. T.~Dritschler$^a$,
  20. N.~Zilio$^a$,
  21. A.~Kopmann$^a$,
  22. M.~Balzer$^a$,
  23. M.~Weber$^a$\\
  24. \llap{$^a$}Institute for Data Processing and Electronics,\\
  25. Karlsruhe Institute of Technology (KIT),\\
  26. Herrmann-von-Helmholtz-Platz 1, Karlsruhe, Germany \\
  27. E-mail: \email{lorenzo.rota@kit.edu}, \email{matthias.vogelgesang@kit.edu}
  28. }
  29. \abstract{% Modern physics experiments have reached multi-GB/s data rates.
  30. Fast data links and high performance computing stages are required for
  31. continuous data acquisition and processing. Because of their intrinsic
  32. parallelism and computational power, GPUs emerged as an ideal solution to
  33. process this data in high performance computing applications. In this paper
  34. we present a high-throughput platform based on direct FPGA-GPU
  35. communication. The architecture consists of a Direct Memory Access (DMA)
  36. engine compatible with the Xilinx PCI-Express core, a Linux driver for
  37. register access, and high-level software to manage direct memory transfers
  38. using AMD's DirectGMA technology. Measurements with a Gen\,3\,x8 link show a
  39. throughput of up to 6.4 GB/s. We also evaluated DirectGMA performance for low
  40. latency applications: preliminary results show a round-trip latency of 2
  41. \textmu s for data sizes up to 4 kB. Our implementation is suitable for real-
  42. time DAQ system applications ranging from photon science and medical imaging
  43. to High Energy Physics (HEP) trigger systems. }
  44. \keywords{FPGA; GPU; PCI-Express; OpenCL; DirectGMA}
  45. \begin{document}
  46. \ifdraft
  47. \setpagewiselinenumbers
  48. \linenumbers
  49. \fi
  50. \section{Introduction}
  51. GPU computing has become the main driving force for high performance computing
  52. due to an unprecedented parallelism and a low cost-benefit factor. GPU
  53. acceleration has found its way into numerous applications, ranging from
  54. simulation to image processing. Recent years have also seen an increasing
  55. interest in GPU-based systems for High Energy Physics (HEP) (\emph{e.g.}
  56. ATLAS~\cite{atlas_gpu}, ALICE~\cite{alice_gpu}, Mu3e~\cite{mu3e_gpu},
  57. PANDA~\cite{panda_gpu}) and photon science experiments.
  58. In a typical scenario, data are acquired by back-end readout systems and then
  59. transmitted in short bursts or in a continuous streaming mode to a computing
  60. stage.
  61. The data rates of bio-imaging or beam-monitoring experiments running in
  62. current generation photon science facilities have reached tens of
  63. GB/s~\cite{panda_gpu, atlas_gpu}. In order to collect data over long
  64. observation times, the readout architecture must be able to save. The
  65. throughput data transmission link may partially limit the overall system
  66. performance.
  67. Latency becomes the most stringent requirement for time-deterministic
  68. applications, \emph{e.g.} in Low/High-level trigger systems.
  69. Due to its high bandwidth and modularity, PCIe quickly became the commercial
  70. standard for connecting high-throughput peripherals such as GPUs or solid
  71. state disks. Moreover, optical PCIe networks have been demonstrated a decade
  72. ago~\cite{optical_pcie}, opening the possibility of using PCIe as a
  73. communication link over long distances.
  74. Several solutions for direct FPGA/GPU communication based on PCIe are reported
  75. in literature, and all of them are based on NVIDIA's GPUdirect technology. In
  76. the implementation of bittnerner and Ruf ~\cite{bittner} the GPU acts as
  77. master during an FPGA-to-GPU data transfer, reading data from the FPGA. This
  78. solution limits the reported bandwidth and latency to 514 MB/s and 40~\textmu
  79. s, respectively.
  80. %LR: FPGA^2 it's the name of their thing...
  81. %MV: best idea in the world :)
  82. When the FPGA is used as a master, a higher throughput can be achieved. An
  83. example of this approach is the \emph{FPGA\textsuperscript{2}} framework by Thoma
  84. et~al.\cite{thoma}, which reaches 2454 MB/s using a 8x Gen2.0 data link.
  85. Lonardo et~al.\ achieved low latencies with their NaNet design, an FPGA-based
  86. PCIe network interface card~\cite{lonardo2015nanet}. The Gbe link however
  87. limits the latency performance of the system to a few tens of \textmu s. If
  88. only the FPGA-to-GPU latency is considered, the measured values span between
  89. 1~\textmu s and 6~\textmu s, depending on the datagram size. Moreover, the
  90. bandwidth saturates at 120 MB/s. Nieto et~al.\ presented a system based on a
  91. PXIexpress data link that makes use of four PCIe 1.0
  92. links~\cite{nieto2015high}. Their system (as limited by the interconnect)
  93. achieves an average throughput of 870 MB/s with 1 KB block transfers.
  94. In order to achieve the best performance in terms of latency and bandwidth, we
  95. developed a high-performance DMA engine based on Xilinx's PCIe Gen3 Core.To
  96. process the data, we encapsulated the DMA setup and memory mapping in a plugin
  97. for our scalable GPU processing framework~\cite{vogelgesang2012ufo}. This
  98. framework allows for an easy construction of streamed data processing on
  99. heterogeneous multi-GPU systems. Because the framework is based on OpenCL,
  100. integration with NVIDIA's CUDA functions for GPUDirect technology is not
  101. possible at the moment. Thus, we used AMD's DirectGMA technology to integrate
  102. direct FPGA-to-GPU communication into our processing pipeline. In this paper we
  103. report the performance of our DMA engine for FPGA-to-CPU communication and some
  104. preliminary measurements about DirectGMA's performance in low-latency
  105. applications.
  106. \section{Architecture}
  107. As shown in \figref{fig:trad-vs-dgpu} (a), traditional FPGA-GPU systems route
  108. data through system main memory by copying data from the FPGA into
  109. intermediate buffers and then finally into the GPU's main memory. Thus, the
  110. total throughput and latency of the system is limited by the main memory
  111. bandwidth. NVIDIA's GPUDirect and AMD's DirectGMA technologies allow direct
  112. communication between GPUs and auxiliary devices over PCIe. By combining this
  113. technology with DMA data transfers (see \figref{fig:trad-vs-dgpu} (b)), the
  114. overall latency of the system is reduced and total throughput increased.
  115. Moreover, the CPU and main system memory are relieved from processing because
  116. they are not directly involved in the data transfer anymore.
  117. \begin{figure}[t]
  118. \centering
  119. \includegraphics[width=1.0\textwidth]{figures/transf}
  120. \caption{%
  121. In a traditional DMA architecture (a), data are first written to the main
  122. system memory and then sent to the GPUs for final processing. By using
  123. GPUDirect/DirectGMA technology (b), the DMA engine has direct access to
  124. the GPU's internal memory.
  125. }
  126. \label{fig:trad-vs-dgpu}
  127. \end{figure}
  128. \subsection{DMA engine implementation on the FPGA}
  129. We have developed a DMA architecture that minimizes resource utilization while
  130. maintaining the flexibility of a Scatter-Gather memory
  131. policy~\cite{rota2015dma}. The engine is compatible with the Xilinx PCIe
  132. Gen2/3 IP-Core~\cite{xilinxgen3} for Xilinx FPGA families 6 and 7. DMA
  133. transmissions to main system memory and GPU memory are both supported. Two
  134. FIFOs, with a data width of 256 bits and operating at 250 MHz, act as user-
  135. friendly interfaces with the custom logic with an input bandwidth of 7.45
  136. GB/s. The user logic and the DMA engine are configured by the host through PIO
  137. registers.
  138. \begin{figure}[t]
  139. \centering
  140. \includegraphics[width=0.5\textwidth]{figures/fpga-arch}
  141. \caption{%
  142. FPGA AAA
  143. }
  144. \label{fig:fpga-arch}
  145. \end{figure}
  146. The physical addresses of the host's memory buffers are stored into an internal
  147. memory and are dynamically updated by the driver or user, allowing highly
  148. efficient zero-copy data transfers. The maximum size associated with each
  149. address is 2 GB. The resource utilization
  150. on a Virtex 7 device is reported in \ref{table:utilization}.
  151. \begin{table}[]
  152. \centering
  153. \caption{Resource utilization on a Virtex7 device X240VT}
  154. \label{table:utilization}
  155. \begin{tabular}{@{}llll@{}}
  156. \toprule
  157. Resource & Utilization & Available & Utilization \% \\
  158. \midrule
  159. LUT & 5331 & 433200 & 1.23 \\
  160. LUTRAM & 56 & 174200 & 0.03 \\
  161. FF & 5437 & 866400 & 0.63 \\
  162. BRAM & 20.50 & 1470 & 1.39 \\
  163. \bottomrule
  164. \end{tabular}
  165. \end{table}
  166. \subsection{OpenCL management on host side}
  167. \label{sec:host}
  168. On the host side, AMD's DirectGMA technology, an implementation of the bus-
  169. addressable memory extension for OpenCL 1.1 and later, is used to write from
  170. the FPGA to GPU memory and from the GPU to the FPGA's control registers.
  171. \figref{fig:opencl-setup} illustrates the main mode of operation: to write
  172. into the GPU, the physical bus addresses of the GPU buffers are determined
  173. with a call to \texttt{clEnqueue\-Make\-Buffers\-Resident\-AMD} and set by the
  174. host CPU in a control register of the FPGA (1). The FPGA then writes data
  175. blocks autonomously in DMA fashion (2). Due to hardware restrictions the
  176. largest possible GPU buffer sizes are about 95 MB but larger transfers can be
  177. achieved by using a double buffering mechanism.
  178. Because the GPU provides a flat memory address space and our DMA engine allows
  179. multiple destination addresses to be set in advance, we can determine all
  180. addresses before the actual transfers thus keeping the CPU out of the transfer
  181. loop for data sizes less than 95 MB.
  182. To signal events to the FPGA (4), the control registers can be mapped into the
  183. GPU's address space passing a special AMD-specific flag and passing the
  184. physical BAR address of the FPGA configuration memory to the
  185. \texttt{cl\-Create\-Buffer} function. From the GPU, this memory is seen
  186. transparently as regular GPU memory and can be written accordingly (3). In our
  187. setup, trigger registers are used to notify the FPGA on successful or failed
  188. evaluation of the data.
  189. Using the \texttt{cl\-Enqueue\-Copy\-Buffer} function call it is possible to
  190. write entire memory regions in DMA fashion to the FPGA. In this case, the GPU
  191. acts as bus master and pushes data to the FPGA.
  192. \begin{figure}
  193. \centering
  194. \includegraphics[width=0.75\textwidth]{figures/opencl-setup}
  195. \caption{The FPGA writes to GPU memory by mapping the physical address of a
  196. GPU buffer and initating DMA transfers. Signalling happens in reverse order by
  197. mapping the FPGA control registers into the address space of the GPU.}
  198. \label{fig:opencl-setup}
  199. \end{figure}
  200. To process the data, we encapsulated the DMA setup and memory mapping in a
  201. plugin for our scalable GPU processing framework~\cite{vogelgesang2012ufo}.
  202. This framework allows for an easy construction of streamed data processing on
  203. heterogeneous multi-GPU systems. For example, to read data from the FPGA,
  204. decode from its specific data format and run a Fourier transform on the GPU as
  205. well as writing back the results to disk, one can run the following on the
  206. command line:
  207. \begin{verbatim}
  208. ufo-launch direct-gma ! decode ! fft ! write filename=out.raw
  209. \end{verbatim}
  210. The framework takes care of scheduling the tasks and distributing the data
  211. items to one or more GPUs. High throughput is achieved by the combination of
  212. fine- and coarse-grained data parallelism, \emph{i.e.} processing a single
  213. data item on a GPU using thousands of threads and by splitting the data stream
  214. and feeding individual data items to separate GPUs. None of this requires any
  215. user intervention and is solely determined by the framework in an automatized
  216. fashion. A complementary application programming interface allows users to
  217. develop custom applications written in C or high-level languages such as
  218. Python.
  219. \section{Results}
  220. We carried out performance measurements on two different setups, described in
  221. table~\ref{table:setups}. In Setup 2, a low-end Supermicro X7SPA-HF-D525
  222. system was connected to a Netstor NA255A external PCIe enclosure. In both
  223. cases, a Xilinx VC709 evaluation board was plugged into a PCIe 3.0 x8 slots.
  224. In case of FPGA-to-CPU data transfers, the software implementation is the one
  225. described in~\cite{rota2015dma}.
  226. \begin{table}[b]
  227. \centering
  228. \caption{Hardware used for throughput and latency measurements}
  229. \label{table:setups}
  230. \begin{tabular}{@{}llll@{}}
  231. \toprule
  232. Component & Setup 1 & Setup 2 \\
  233. \midrule
  234. CPU & Intel Xeon E5-1630 at 3.7 GHz & Intel Atom D525 \\
  235. Chipset & Intel C612 & Intel ICH9R Express \\
  236. GPU & AMD FirePro W9100 & AMD FirePro W9100 \\
  237. PCIe link (FPGA-System memory) & x8 Gen3 & x4 Gen1 \\
  238. PCIe link (FPGA-GPU) & x8 Gen3 & x8 Gen3 \\
  239. \bottomrule
  240. \end{tabular}
  241. \end{table}
  242. \subsection{Throughput}
  243. % We repeated the FPGA-to-GPU measurements on a low-end Supermicro X7SPA-HF-D525
  244. % system based on an Intel Atom CPU. The results showed no significant difference
  245. % compared to the previous setup. Depending on the application and computing
  246. % requirements, this result makes smaller acquisition system a cost-effective
  247. % alternative to larger workstations.
  248. \begin{figure}
  249. \includegraphics[width=\textwidth]{figures/throughput}
  250. \caption{%
  251. Measured results for data transfers from FPGA to main memory
  252. (CPU) and from FPGA to the global GPU memory (GPU).
  253. }
  254. \label{fig:throughput}
  255. \end{figure}
  256. The measured results for the pure data throughput is shown in
  257. \figref{fig:throughput} for transfers from the FPGA to the system's main
  258. memory as well as to the global memory as explained in \ref{sec:host}.
  259. % Must ask Suren about this
  260. In the case of FPGA-to-GPU data transfers, the double buffering solution was
  261. used. As one can see, in both cases the write performance is primarily limited
  262. by the PCIe bus. Up until 2 MB data transfer size, the throughput to the GPU
  263. is approaching slowly 100 MB/s. From there on, the throughput increases up to
  264. 6.4 GB/s when PCIe bus saturation sets in at about 1 GB data size. The CPU
  265. throughput saturates earlier but the maximum throughput is 6.6 GB/s.
  266. % \begin{figure}
  267. % \includegraphics[width=\textwidth]{figures/intra-copy}
  268. % \caption{%
  269. % Throughput in MB/s for an intra-GPU data transfer of smaller block sizes
  270. % (4KB -- 24 MB) into a larger destination buffer (32 MB -- 128 MB). The lower
  271. % performance for smaller block sizes is caused by the larger amount of
  272. % transfers required to fill the destination buffer. The throughput has been
  273. % estimated using the host side wall clock time. The raw GPU data transfer as
  274. % measured per event profiling is about twice as fast.
  275. % }
  276. % \label{fig:intra-copy}
  277. % \end{figure}
  278. In order to write more than the maximum possible transfer size of 95 MB, we
  279. repeatedly wrote to the same sized buffer which is not possible in a real-
  280. world application. As a solution, we motivated the use of multiple copies in
  281. Section \ref{sec:host}. To verify that we can keep up with the incoming data
  282. throughput using this strategy, we measured the data throughput within a GPU
  283. by copying data from a smaller sized buffer representing the DMA buffer to a
  284. larger destination buffer. At a block size of about 384 KB the throughput
  285. surpasses the maximum possible PCIe bandwidth, and it reaches 40 GB/s for
  286. blocks bigger than 5 MB. Double buffering is therefore a viable solution for
  287. very large data transfers, where throughput performance is favoured over
  288. latency.
  289. % \figref{fig:intra-copy} shows the measured throughput for
  290. % three sizes and an increasing block size.
  291. \subsection{Latency}
  292. \begin{figure}[t]
  293. \centering
  294. \begin{subfigure}[b]{.8\textwidth}
  295. \centering
  296. \includegraphics[width=\textwidth]{figures/latency}
  297. \caption{Latency }
  298. \label{fig:latency_vs_size}
  299. \end{subfigure}
  300. \begin{subfigure}[b]{.8\textwidth}
  301. \includegraphics[width=\textwidth]{figures/latency-hist}
  302. \caption{Latency distribution.}
  303. \label{fig:latency_hist}
  304. \end{subfigure}
  305. \label{fig:latency}
  306. \end{figure}
  307. For HEP experiments, low latencies are necessary to react in a reasonable time
  308. frame. In order to measure the latency caused by the communication overhead we
  309. conducted the following protocol: 1) the host issues continuous data transfers
  310. of a 4 KB buffer that is initialized with a fixed value to the FPGA using the
  311. \texttt{cl\-Enqueue\-Copy\-Buffer} call. 2) when the FPGA receives data in its
  312. input FIFO it moves it directly to the output FIFO which feeds the outgoing DMA
  313. engine thus pushing back the data to the GPU. 3) At some point, the host enables
  314. generation of data different from initial value which also starts an internal
  315. FPGA counter with 4 ns resolution. 4) When the generated data is received again
  316. at the FPGA, the counter is stopped. 5) The host program reads out the counter
  317. values and computes the round-trip latency. The distribution of 10000
  318. measurements of the one-way latency is shown in \figref{fig:latency-hist}.
  319. [\textbf{REWRITE THIS PART}] The GPU latency has a mean value of 84.38 \textmu s
  320. and a standard variation of 6.34 \textmu s. This is 9.73 \% slower than the CPU
  321. latency of 76.89 \textmu s that was measured using the same driver and measuring
  322. procedure. The non-Gaussian distribution with two distinct peaks indicates a
  323. systemic influence that we cannot control and is most likely caused by the
  324. non-deterministic run-time behaviour of the operating system scheduler.
  325. \section{Conclusion and outlook}
  326. We developed a hardware and software solution that enables DMA transfers
  327. between FPGA-based readout systems and GPU computing clusters. The software
  328. solution that we proposed allows seamless multi-GPU processing of the incoming
  329. data, due to the integration in our streamed computing framework. This allows
  330. straightforward integration with different DAQ systems and introduction of
  331. custom data processing algorithms.
  332. The net throughput is primarily limited by the PCIe link, reaching 6.4 GB/s
  333. for a FPGA-to-GPU data transfer and 6.6 GB/s for a FPGA-to-CPU data transfer.
  334. By writing directly into GPU memory instead of routing data through system
  335. main memory, the overall latency of the system can be reduced, thus allowing
  336. close massively parallel computation on GPUs. Optimization of the GPU DMA
  337. interfacing code is ongoing with the help of technical support by AMD. With a
  338. better understanding of the hardware and software aspects of DirectGMA, we
  339. expect a significant improvement in the latency performance.
  340. In order to increase the total throughput, a custom FPGA evaluation board is
  341. currently under development. The board mounts a Virtex-7 chip and features two
  342. fully populated FMC connectors, a 119 Gb/s DDR memory interface and a PCIe x16
  343. Gen3 connection. Two x8 Gen3 cores, instantiated on the board, will be mapped
  344. as a single x16 device by using an external PCIe switch. With two cores
  345. operating in parallel, we foresee an increase in the data throughput by a
  346. factor of 2 (as demonstrated in~\cite{rota2015dma}).
  347. Support for NVIDIA's GPUDirect technology is also foreseen in the next months
  348. to lift the limitation of one specific GPU vendor and compare the performance
  349. of hardware by different vendors. Further improvements are expected by
  350. generalizing the transfer mechanism and include Infiniband support besides the
  351. existing PCIe connection.
  352. %% Where do we get this values? Any reference?
  353. %This allows
  354. %speeds of up to 290 Gb/s and latencies as low as 0.5 \textmu s.
  355. Our goal is to develop a unique hybrid solution, based on commercial standards,
  356. that includes fast data transmission protocols and a high performance GPU
  357. computing framework.
  358. \acknowledgments
  359. This work was partially supported by the German-Russian BMBF funding programme,
  360. grant numbers 05K10CKB and 05K10VKE.
  361. \bibliographystyle{JHEP}
  362. \bibliography{literature}
  363. \end{document}