Reader small image

You're reading from  Raspberry Pi Super Cluster

Product typeBook
Published inNov 2013
Reading LevelBeginner
PublisherPackt
ISBN-139781783286195
Edition1st Edition
Languages
Right arrow
Author (1)
Andrew K. Dennis
Andrew K. Dennis
author image
Andrew K. Dennis

Andrew K. Dennis is a full stack and cybersecurity architect with over 17 years' experience who currently works for Modus Create in Reston, VA. He holds two undergraduate degrees in software engineering and creative computing and a master's degree in information security. Andy has worked in the US, Canada, and the UK in software engineering, e-learning, data science, and cybersecurity across his career, and has written four books on IoT, the Raspberry Pi, and supercomputing. His interests range from the application of pataphysics in computing to security threat modeling. Andy lives in New England and is an organizer of Security BSides CT.
Read more about Andrew K. Dennis

Right arrow

Chapter 7. Going Further

In this chapter, we will bring together what we have learned throughout this book and look at some next-step projects that build upon the work from the previous chapters. The projects located here include booting up your Raspberry Pi to use a USB HDD, creating a Lego enclosure, and writing an MPI-based application using Fortran.

Let's start by looking at the USB HDD project.

Booting from an external USB HDD


Booting the Raspberry Pi up to use a USB HDD will give you extra storage capacity and also provide you with a device that is faster and more robust when it comes to accessing data repeatedly. This is especially useful when running large MapReduce applications with Hadoop. The USB HDD should contain external power, if possible, as the max recommended current on the USB ports is 100 mA.

Follow the listed steps to set up your USB HDD and configure your SD card:

  1. Plug in the USB device to one of your Raspberry Pi's USB port's; remember to leave the keyboard attached.

  2. Using the Linux instructions from Chapter 2, Setting Up your Raspberry Pi Software and Hardware for Parallel Computing, grab the disk name and unmount the USB device. You can use the instruction at the following eLinux page to format your USB drive:

    Note

    You can use ls /dev/ | grep "sd" to list connected devices and then to mount the device use sudo mount /dev...

Building a Lego enclosure


Building a case for your device helps to protect it from getting damaged. One fun, popular, and cheap method of doing this is to use Lego bricks.

For those of you who don't have them, these can be purchased from most toy stores, Amazon, or can be ordered directly from the following Lego website:

http://shop.lego.com/en-US/#shopxlink

Lego also allows custom brick ordering; for example, you can order all red, green, or white bricks for your case at the following link:

http://shop.lego.com/en-US/Customized-Items-ByCategory

For each Raspberry Pi case you will need the following:

  • Flat Lego panels to make a 13 x 9 stud rectangle.

  • Bricks to go around the edges of this rectangle. These should be two-studs wide.

  • Four flat tiles. These have no studs on top and cover an area of 1 x 2 studs when connected.

  • Pieces to make a wall, three bricks high and one stud wide, to ring the 13 x 9 dimensions.

So let's get started with building our Lego enclosure. The steps for this are as follows...

Experimenting with MPI and Fortran


The following Fortran program is an adaptation of the hello_rpi.c application from Chapter 3, Parallel Computing – MPI on the Raspberry Pi .

Create a new file called hello_rpi.f in the Fortran directory that you created earlier as follows:

vim /home/pi/Fortran/hello_rpi.f

Next add the following code to the file:

  program hellorpi
  include 'mpif.h'

  integer rpi, totalrpi, ierr

  call MPI_INIT(ierr)
  call MPI_COMM_RANK(MPI_COMM_WORLD, rpi, ierr)
  call MPI_COMM_SIZE(MPI_COMM_WORLD, totalrpi, ierr)

  print *, 'This is Raspberry Pi ',(rpi+1),' of ',totalrpi

  call MPI_FINALIZE(ierr)
  end

You can see this program is very similar to the C one.

To start with, we include the mpif.h header. Following this we declare a number of integer variables to store the current Raspberry Pi executing the program, the total number of RPi's in the cluster, and an additional variable for an error code.

After this are the three MPI calls we made in the hello_rpi.c application...

Power for multiple devices


In this section we take a brief look at some alternatives to using standard micro-USB phone-style chargers or desktop-mounted USB ports for powering your Raspberry Pi.

Each of the following suggestions should provide you with some ideas for future projects and provide some links to further reading. Remember, when working with mains electricity, to always make sure you take the necessary safety precautions and refer to a licensed professional.

USB wall plates

One alternative to the standard USB hubs is to install a wall mounted USB plate.

For running a small number of Raspberry Pis you can eliminate the need to use a USB hub or to use a desk-mounted multi adapter with USB ports.

Wall plates are directly wired into your mains electric as with a standard electricity socket.

These can be found at most home DIY stores. It is recommended that you have them installed by a certified electrician due to the risk of electric shock posed by working with mains electricity. Some plugs...

Summary


This chapter concludes the projects presented in this book. Here we learned how to use the Raspberry Pi with a USB HDD. We also explored building a case using Lego. As a follow up to this, the Appendix provides you with a number of resources for purchasing Raspberry Pi cases or 3D-printing custom cases.

Following building a case, we explored writing another MPI-based application, this time using the Fortran programming language.

Finally we provided some ideas for alternative power sources for your Raspberry Pi cluster and some links to resources that discuss those.

The projects from this chapter, combined with those from across the rest of this book, have provided you with the basic tools needed to explore the topic of Parallel Computing further. You should now be familiar with MPI and Hadoop. You have also gained a solid understanding of how to build a new node and how to add it to your cluster.

We now leave it to you, the reader, to take the next steps in this exciting area of computing...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Raspberry Pi Super Cluster
Published in: Nov 2013Publisher: PacktISBN-13: 9781783286195
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Andrew K. Dennis

Andrew K. Dennis is a full stack and cybersecurity architect with over 17 years' experience who currently works for Modus Create in Reston, VA. He holds two undergraduate degrees in software engineering and creative computing and a master's degree in information security. Andy has worked in the US, Canada, and the UK in software engineering, e-learning, data science, and cybersecurity across his career, and has written four books on IoT, the Raspberry Pi, and supercomputing. His interests range from the application of pataphysics in computing to security threat modeling. Andy lives in New England and is an organizer of Security BSides CT.
Read more about Andrew K. Dennis