Raspberry Pi Supercomputing and Scientific Programming.pdf

(4427 KB) Pobierz
Ashwin Pajankar
Raspberry Pi Supercomputing and Scientific
Programming
MPI4PY, NumPy, and SciPy for Enthusiasts
Ashwin Pajankar
Nashik, Maharashtra, India
Any source code or other supplementary materials referenced by the author in this text are available to
readers at www.apress.com . For detailed information about how to locate your book’s source code,
go to www.apress.com/source-code/ . Readers can also access source code at SpringerLink in
the Supplementary Material section for each chapter.
ISBN 978-1-4842-2877-7
e-ISBN 978-1-4842-2878-4
DOI 10.1007/978-1-4842-2878-4
Library of Congress Control Number: 2017943339
© Ashwin Pajankar 2017
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.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even
if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they
are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for
any errors or omissions that may be made. The publisher makes no warranty, express or implied, with
respect to the material contained herein.
Printed on acid-free paper
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring
Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-
ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and
the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM
Finance Inc is a Delaware corporation.
Introduction
“I’m sorry, buddy, you’ve got a C in parallel programming,” my classmate said to me. It was my second
semester at IIIT Hyderabad, where I was pursuing my graduate studies towards an MTech in computer
science and engineering. To be very honest, I was really not expecting an A in parallel programming.
However, I was not expecting a C either. Like most of the folks in my class, I was expecting a B or a B- in
the worst case. As I mentioned earlier, it was my second semester and I was getting used to boring and
rigorous academics at the Institute. I was also getting used to seeing C and C- grades on my scorecard. I
was really starting to wonder if I had what it took to pursue graduate studies at the coveted and hallowed
Institute. Little did I know that the worst was yet to come, because exactly one year after that, I saw two
Ds on my scorecard.
I wondered if there was a way to make scary subjects like parallel programming more interesting and
appealing to undergrad and graduate students. I vividly remember that our prof for the course mentioned
that the US Air Force created a cluster of PS3s ( http://phys.org/news/2010-12-air-
playstation-3s-supercomputer.html ). You can also check the Wikipedia page (
https://en.wikipedia.org/wiki/PlayStation_3_cluster ) for the same. I fancied
owning a small-scale cluster like that. However, the biggest hurdle was and still is the cost associated
with individual unit. A PS3 costs around 250 USD and a PS2 costs 100 USD. Moreover, it is a really
tedious task to install Linux OS on the PS2 and PS3. I have nothing against Sony or the PS2/PS3, as
Playstations are excellent gaming consoles, but I wanted something cheaper and simpler to build the
cluster. So I shelved my plans to build a cluster for the time being and got engrossed in academics at the
Institute.
Fast forward two years: I saw a bunch of kids booting up a strange-looking PCB (printed circuit
board) with Linux and I literally jumped with excitement. When I asked them what it was, they said,
“Raspberry Pi.” This is how I was introduced to Raspberry Pi. The occasion was a Hackathon organized
at my former workplace for specially abled kids. When I saw those lovely and creative kids using a little
computer, I immediately decided to explore it, and after six months my first book on Raspberry Pi (
www.packtpub.com/hardware-and-creative/raspberry-pi-computer-vision-
programming ) got published.
It has been a while since my first book got published. Raspberry Pi underwent major revisions.
Multiple newer and more powerful models of Pi have been introduced. I explored the world of single
board computers in detail as I (correctly) thought that SBCs could be best for cluster. Then I built a
cluster with three units of Raspberry Pis for a proof of concept. I went on building the clusters for various
organizations, T-Schools, and universities all over India.
Raspberry Pi also serves as an excellent learning platform for scientific programming. We can use it
for exploring important concepts in the scientific domains of signal and image processing, or to perform
symbolic computations with SymPy.
I have explored the domain of scientific programming in detail in this book. The book has almost 100
coding examples to demonstrate and explore the world of scientific programming.
I hope that this book will help the scientific community and young researchers to use Raspberry Pi and
Python as tools to explore scientific frontiers.
Why This Book?
As I said earlier, I found learning and exploring the topics in parallel and scientific programming quite
boring and difficult. However, these are some of the most useful areas in computer science, with many
applications in the real world. In my past and current jobs, I routinely used various parallel and scientific
programming libraries for accomplishing various tasks. I want more people to get interested in this
wonderful field. However, when people approach me for guest lectures and talks on this topic, they have
a common complaint. They tell me that it’s difficult to get started with Raspberry Pi, parallel and
scientific programming due to lack of reliable materials and references over the Internet. There are many
tutorials and videos which teach people how to create a small multi-node cluster with Raspberry Pi. But
due to unfamiliarity with the notion of single board computers, they found it difficult to grasp the
information provided. So I decided to combine the topics of Raspberry Pi setup and supercomputers in a
single book. This book teaches readers how to build a Raspberry Pi cluster as well as how to use Python
to exploit its computational power for various scientific tasks. The cluster we will build in this book will
be very basic one. It will be fit to be deployed in academic and research institutions. We will also learn
how to get started with symbolic programming, scientific programming, image processing, and signal
processing in this book. The book has within its scope the following:
Introduction to single board computers, Python 3, and Raspberry Pi
Basic concepts in supercomputing
Preparing a node and building an entire cluster
Parallel programming in Python
Symbolic mathematical programming
Scientific programming
Image processing
Signal processing
Visualization with Matplotlib
Zgłoś jeśli naruszono regulamin