The following exercises are the assignment to score points on the HPC Cloud session. After you have attended the presentations and followed the hands-on tutorial (including the extras), you understand all the concepts that will allow you to propose valid solutions to the exercises. You can contact your facilitators if you have any questions.
Access to the HPC Cloud User Interface will remain available until the 10th Feb. 2017. The assignment needs to be deleivered by then via email to the facilitators: email@example.com (cc to firstname.lastname@example.org).
Master chef Oliver needs to cook a π according to a recipe he has found on the Internet. It is a bit special, because the recipe only says:
The traditional way they cook π in Monte Carlo
- On a plane, prepare a square of side length SIDE centered in the origin; i.e.: coordinates (0,0)
- Prepare a circle centered inside the previous square, whose RADIUS is half the SIDE
- Randomly generate N points inside the square, of the form (x, y), where x and y are in the range (−RADIUS, +RADIUS)
- Check whether the points are inside the circle too (a point is within the circle when: x2 + y2 < RADIUS2)
- Count M as the amount of points that are within the circle
- Finish the π as π ≅ 4 × M / N
Oliver has asked you for help. Being a good friend of yours, you are really excited to help! You have just heard about the scalability options that the HPC Cloud has to offer. That is precisely what Oliver needs. It’s great! It’s true!
Cook π fast!
Imagine that, browsing the Internet, you get your hands on a compiled program called
montecarlo, which follows exactly Oliver’s recipe. In other words: it takes N and RADIUS as inputs, and provides M and its estimation of π as outputs.
Describe a system, using the HPC Cloud, that will allow you to estimate π using a naïve Monte Carlo approach distributed among 1-core Virtual Machines, such that:
montecarloprogram with the amount of points, N’, and the RADIUS, that it receives from the master
We split the assignment in different exercises to guide you through the process.
Leaving the bonus exercises aside:
If you answer all exercises (except for the bonus) correctly, then you will get the maximum grade that you can get. We will value creative and smart solutions.
The bonus exercises allow you to score additional points, to complement the rest of the exercises. If you provide nice solutions, we will give you credits when we use them as examples (if you allow us to).
Explain Oliver what your idea is: tell him which features of the HPC Cloud you are going to use to tackle his problem. Tell him how beautiful your answer is because… do you need to change the
Oliver’s recipe is missing pictures. Draw a sketch that Oliver can keep next to his recipe forever, that illustrates what you came up with in the previous exercise.
At least, you should be able to draw some boxes for the master and the workers, depicting how they communicate and where they live. You can use a UML Component diagram and/or a UML Deployment diagram, for example.
Sketch in pseudocode what you think the programs look like:
Imagine that you are given a program that does the master’s work, and the
montecarlo program for the worker. Also, imagine that you have access to the same scripts
makeme_worker.sh that you used in the MPI example.
Write down the relevant steps that you must follow in the HPC Cloud UI to run those programs with 1 master and 3 workers.
We assume all VMs use only 1 core and 1GB of RAM, so you do not need to give details on how you configure the Templates.
Having to create all workers by hand is very tedious. You are so happy that you can show Oliver how to let the master create the workers on demand!!!
Thus, for a solution where the master will create the workers on demand (the master now receives the amount of workers, W, as an extra parameter):
Implement a solution for the master and the worker according to the original description (thus, without the master creating the workers). Send us the code with comments on what you did.
- You may be able to reuse the code for calculating π for the serial version that you get from the OpenMP exercise and both the configuring scripts for the master-workers configuration from the MPI exercise.
montecarloprogram does not actually need to provide M as output, because you can isolate M = π × N / 4
- Some useful information: you can run a command on a remote machine using the
sshcommand, as in:
ssh <username>@<remote-IP> '<command>'(do NOT write the less-than and greater-than signs from that previous line)
Implement a solution where the master creates (and releases) workers.