Dirk Koch · Frank Hannig Daniel Ziener Editors Fpgas for Software Programmers Fpgas for Software Programmers
Total Page:16
File Type:pdf, Size:1020Kb
Dirk Koch · Frank Hannig Daniel Ziener Editors FPGAs for Software Programmers FPGAs for Software Programmers [email protected] [email protected] Dirk Koch • Frank Hannig • Daniel Ziener Editors FPGAs for Software Programmers 123 [email protected] Editors Dirk Koch Frank Hannig The University of Manchester Friedrich-Alexander-Universität Manchester, United Kingdom Erlangen-Nürnberg (FAU) Erlangen, Germany Daniel Ziener Friedrich-Alexander-Universität Erlangen-Nürnberg (FAU) Erlangen, Germany ISBN 978-3-319-26406-6 ISBN 978-3-319-26408-0 (eBook) DOI 10.1007/978-3-319-26408-0 Library of Congress Control Number: 2015957420 Springer Cham Heidelberg New York Dordrecht London © Springer International Publishing Switzerland 2016 This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, express or implied, with respect to the material contained herein or for any errors or omissions that may have been made. Printed on acid-free paper Springer International Publishing AG Switzerland is part of Springer Science+Business Media (www. springer.com) [email protected] Preface “FPGAs.” — “What?” “Field programmable gate arrays that are cool programmable chips.” — “I see! Programmable. Great. I have programming skills. So, this should be an easy task for me.” “Well, not really, but I can help you.” Dear valued reader, when software engineers and hardware engineers talk about FPGAs, often two worlds are clashing together, each with different mindsets, skills, and expectations. Until recently, FPGA programming was mostly a hardware engi- neering discipline carried out by specially trained people. The design productivity of FPGA design was rather low, and for the time a hardware engineer was fiddling out a few flipping bits, a software engineer might have implemented his new large-scale cloud service application running on a big data center. Please note that we wrote “was rather low!” Like the widespread success of the processor took off with the development of expressive languages and corresponding compilers,thisiscurrently happening for FPGAs. For decades, FPGA programming was carried out at very low abstraction levels (comparable to assembly language), but during recent years several compilers have emerged that can bring an algorithm to an FPGA at a quality far beyond what human handcrafting would be able to do. Currently, the software and hardware worlds are strongly converging. Software is going parallel, which has a long tradition in hardware design and vice versa, hardware gets more and more designed from expressive languages. This book aims at closing the gap between these two worlds. Instead of following a programming model that is tailored to CPUs (following the so-called von Neumann computer architecture model), FPGA programming can be considered rather as molding the liquid silicon [IBEC10] to create a certain desired functionality, and FPGAs allow computing without processors [Sin11]. v [email protected] vi Preface This gives an engineer full control over the machine itself and not only over the program a machine runs. For example, if we want to perform DNA sequencing. Then, let us build a reconfigurable processor which is tailored to small alphabet string matching and achieve 395 million base pairs per second throughput [ALJ15]. Or we need fast AES encryption? Then build a custom compute accelerator on an FPGA, and get 260 Gbps throughput [SS15]. As a reference, the fastest Intel Core i7 Extreme Edition i7-980X CPU does not even yield that memory throughput, and this processor provides three times less AES throughput when using all 12 cores and despite having special hardware support for AES. And if we take an i7 Extreme Edition 975x without AES hardware support, the FPGA would be 52 times faster. Please note that the FPGA delivers its AES throughput on one problem, while the software solutions provide only high aggregated performance for AES on different problems. On the same problem, the FPGA will be significantly faster. And not only that the FPGA is much faster, it will do the job at a fraction of the power consumption. Does implementing AES for an FPGA sound too complicated? Well, tuning the performance for AES on, for example, a GPU (that is optimized for floating-point number-crunching instead of bit-level operations) is likely to be harder, will still be slower than an FPGA implementation, and would burn at least an order of magnitude more power. So why not getting it right in the first place? This is what this book wants to help with. For making this happen, this book brings together leading experts from the industry and academia across the globe to cover: Theoretical foundations and background on computer architectures, program- ming models, and hardware compilation techniques (throughout the first three chapters). Programming languages and compilers for FPGAs from a rather practical point of view with various case studies. This includes six state-of-the-art and emerg- ing commercial approaches (located in Part I, beginning at page 61)aswellas three established academic compilers (located in Part II, beginning at page 173). This shall demonstrate that there is a large ecosystem for FPGA programming that software engineers can choose from to find the best language and compiler environment for virtually any given problem. FPGA runtime environments are needed for building complex systems and for running and managing them. This provides a higher abstraction in the system allowing to focus more on applications while abstracting from many low-level details of the underlying FPGA hardware (as covered in Part III, beginning at page 225). Ready-to-go approaches allow building a complex system on a chip (SoC) and using pre-implemented programmable architectures on an FPGA without any need for hardware programming (as revealed in Part IV, starting from page 259). With all this, we intend making reconfigurable FPGA technology more acces- sible to software programmers and to moderate between hardware and software [email protected] Preface vii engineers. FPGA technology provides maybe the most promising answer for improving performance and energy efficiency of computers at the end of CMOS scaling. To make this happen, it will need hardware and software engineers working harmonically together. Let us start with this today! This book is written for software engineers who want to know more about FPGAs and how to use them. Consequently, we do not assume any hardware engineering background. In a few cases, where further background information is provided, this book is using terms that are common in computer engineering (e.g., “flip- flop”) and compiler construction (e.g., “scheduling”) that might not be thoroughly introduced but that are assumed to be clear from the context for most readers. This was done by intention as we do not want to fill the book with all possible background information while eventually hiding the big picture, which is what are FPGAs good for and how can they be programmed and used by software engineers. Such sections should be seen as optional and should not be seen as essential when reading this book. Those terms are also nicely presented on Wikipedia, if further explanation might be needed. In addition to software engineers, this book can also serve as a textbook in university courses on alternative programming approaches and acceleration techniques. Finally, this book is also relevant for hardware engineers who want to get an overview on how to enhance design productivity with latest languages and tools. We thank all the chapter authors for their outstanding contributions, their feedback, and their will to compile a comprehensive textbook targeting software engineers. We also thank Springer, especially Charles Glaser for his encouragement to develop this book and Hemalatha Gunasekaran for her support. Furthermore, we thank Mikel Luján for his feedback and suggestions to improve this book. Finally, we thank Philippa Ordnung for providing the Index. All editor’s and author’s profit of the book sales will be donated to the United Nations Children’s Fund (UNICEF). Manchester, UK Dirk Koch Erlangen, Germany Frank Hannig Erlangen, Germany Daniel Ziener [email protected] viii Preface Contributors Michael Adler C 14 Intel Corporation, VSSAD Group, Hudson, MA, USA Andreas Agne C 13 University of Paderborn, Paderborn, Germany Stephan Ahrends C 4 National Instruments, Munich, Germany Jason Anderson C 10 Department of Electrical and Computer Engineering, University of Toronto, Toronto, ON, Canada Hugo A. Andrade C 4 National Instruments, Berkeley, CA, USA Oriol Arcas-Abella C 9 Barcelona Supercomputing