Pi (π) Calculator
Task 1 – Inspecting the PiCalculator Solution
In this task, you will inspect the PiCalculator solution to see the how the code of the MPI application.
- Open Microsoft Visual Studio 2010 from Start | AllPrograms | MicrosoftVisualStudio2010 | Microsoft Visual Studio 2010.
- Open the PiCalculator.sln solution file located in the MPI\Source\PiCalculator folder.
Examine the project in the Solution Explorer window. The file that contains the MPI application is named PiCalculator.cpp, as shown in Figure 2:
Figure 2
The PiCalculator project tree
- Open the PiCalculator.cpp file and examine its contents. The application calculates the value of pi by using the integral formula of 4/(1+x^2), which is broken down using Riemann sums, and calculated in multiple processes using MPI.
- Continue examining the application code, you will notice that there are several stages for the MPI application:
- Get the number of processes (size) and the id of the current process (rank).
- Broadcast the value of the interval to all the processes.
- Collect the partial sum from all the processes.
- Print the result and terminate the process execution.
Change the solution configuration to Release, as shown in Figure 3, and build the solution.
Figure 3
Changing solution configuration
Task 2 – Deploy the PiCalculator Application to Windows Azure Worker Nodes
In this task, you will deploy the PiCalculator MPI application to your Windows Azure worker nodes.
- Open the command prompt window from Start | All Programs | Accessories | Command Prompt.
- Navigate to the MPI labs folder, and run the following command to create a deployment package (this step is illustrated in step 1 of Figure 1):
hpcpack create source\piCalculator.zip source\piCalculator\release\
- Run the following command to upload the deployment package to the Windows Azure package storage (this step is illustrated in step 2 of Figure 1):
hpcpack upload source\piCalculator.zip /nodetemplate:"Azure node template" /relativePath:piCalculator
Change the value of the nodetemplate parameter to the name of your Windows Azure node template.
- Use the following command to create a c:\app directory on the participating Windows Azure nodes:
clusrun /nodegroup:azurenodes md c:\app\
Change the value of the nodegroup parameter to the name of the group containing your Windows Azure nodes.
- Run the following command to deploy the contents of the deployment package to the Windows Azure nodes (this step is illustrated in step 3 of Figure 1):
clusrun /nodegroup:azurenodes hpcsync c:\app
Change the value of the nodegroup parameter to the name of the group containing your Windows Azure nodes.
- Run the following command to configure the Windows Azure Firewall to allow MPI communication between the Windows Azure nodes (this step is illustrated in step 4 of Figure 1):
clusrun /nodegroup:azurenodes hpcfwutil register piCalculator c:\app\piCalculator\piCalculator.exe
Change the value of the nodegroup parameter to the name of the group containing your Windows Azure nodes.
Task 3 - Execute the PiCalculator Application and View its Result
In this task, you will use the HPC 2008 R2 Cluster Manager to start a job that executes the PiCalculator MPI application. Once the job is completed, you will be able to see the result in the job information window.
- Open the HPC 2008 R2 Cluster Manager application from Start | All Programs | Microsoft HPC Pack 2008 R2 | HPC Cluster Manager.
In the Cluster Manager application, enter the Node Management section and verify that the Windows Azure nodes in the cluster are online, as shown in Figure 4:
Figure 4
Verifying the state of the Windows Azure nodes
In the Cluster Manager application, enter the Job Management section and click New Job… in the Actions pane as shown in Figure 5:
Figure 5
Create a new job
In the New Job dialog, set the Job name to pi calculator, as shown in Figure 6:
Figure 6
Setting the name of the job
Still in the New Job dialog, click the Edit Tasks option, click the arrow next to the Add button, and then click Basic Task …, as shown in Figure 7:
In the Task Details and I/O Redirection window, set the Task name field to piCalculator, enter mpiexec c:\app\piCalculator\piCalculator 10000000 in the Command Line field, and set the maximum number of resources to be used to 9999, as shown in Figure 8:
Figure 8
Creating the MPI task in the job
Click the ResourceSelection option, check the Run this job only on nodes that are members of all the following groups checkbox, and then add a group containing Windows Azure nodes, as shown in Figure 9:
Figure 9
Selecting node groups for the job
In your HPC cluster, the name of the Windows Azure node group may differ.
Click the Environment Variables option, click the Add button, and then add an environment variable named CCP_MPI_NETMASK with the value of 0.0.0.0/0.0.0.0, as shown in Figure 10:
Figure 10
Adding an environment variable
- Click the Submit button to start the job.
- Once the job is complete, locate it in the finished jobs list, and view its information.
In the View Job window, click the View Tasks section, and observe the value of pi calculated by the MPI application, as shown in Figure 11:
Figure 11
Observing the output of the MPI application
To get a more accurate value of pi, run the job with more iterations. You can change the command line parameter in the basic task from its current value of 10 million to 50 million, 100 million, or even 1 billion iterations.
|
|