MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi)...

26
Readme MPI Samples Lab version: 1.0.0 Last updated: 5/24/2022

Transcript of MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi)...

Page 1: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

ReadmeMPI Samples

Lab version: 1.0.0

Last updated: 5/20/2023

Page 2: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Contents

OVERVIEW................................................................................................................................................. 3

GETTING STARTED................................................................................................................................... 5

PI (Π) CALCULATOR................................................................................................................................. 6Task 1 – Inspecting the PiCalculator Solution......................................................................................6

Task 2 – Deploy the PiCalculator Application to Windows Azure Worker Nodes................................7

Task 3 - Execute the PiCalculator Application and View its Result.......................................................8

TACHYON PARALLEL RAY-TRACER....................................................................................................14Task 1 - Inspecting the tachyon_mpi Folder Contents.......................................................................14

Task 2 - Configure the AzureBlobCopy Utility....................................................................................15

Task 3 - Deploy the Tachyon Application to Windows Azure Worker Nodes.....................................15

Task 4 – Execute the Tachyon Application and View its Result..........................................................16

SUMMARY................................................................................................................................................ 24

Page 3: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Overview

Message Passing Interface (MPI) is a platform-independent standard for messaging between HPC nodes. Microsoft MPI (MS MPI) is the MPI implementation used for MPI applications executed by Windows HPC Server 2008 R2. The following MPI samples demonstrate how to run MPI applications on Windows Azure compute nodes. These samples include two MPI applications:

Tachyon. Tachyon, written by John Stone (http://jedi.ks.uiuc.edu/~johns/raytracer/), is a free ray-tracing library that supports both MPI and thread-based parallel processing.

Pi (π) Calculator. This MPI application calculates the value of pi up to a desired level of accuracy.

Key Features

This sample demonstrates the following:

Uploading and deploying MPI application packages to Windows Azure nodes.

Creating and running jobs for the execution of MPI applications in a Windows HPC Server 2008 R2 Service Pack 2 (SP2) cluster.

The Windows HPC Server 2008 R2 Windows Azure Nodes Deployment Model

Figure 1 illustrates the deployment process of MPI applications to Windows Azure worker nodes.

Page 4: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 1MPI application deployment to Windows Azure nodes in a Windows HPC Server 2008 R2 cluster

Page 5: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Getting Started

The following prerequisites are required for running these samples:

On the HPC cluster’s head node:

◦ HPC Pack 2008 R2 SP2

On the development machine:

◦ HPC Pack 2008 R2 SP2 Client Utilities

◦ Microsoft Visual Studio 2010 (for the pi calculator sample)

◦ HPC Pack 2008 R2 MS-MPI Redistributable Package with Service Pack 2 (for the pi calculator sample)

To run this sample, you need to have administrative access to your HPC cluster’s head node, and you must have a valid Windows Azure account, a Windows Azure worker node template defined in your head node, and several Windows Azure worker nodes in the HPC cluster that are started and online. Follow the Deploying Windows Azure Worker Nodes in Windows HPC Server 2008 R2 Step-by-Step Guide on TechNet for further information.

Page 6: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

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.

1. Open Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010 | Microsoft Visual Studio 2010.

2. Open the PiCalculator.sln solution file located in the MPI\Source\PiCalculator folder.

3. 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 2The PiCalculator project tree

4. 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.

5. Continue examining the application code, you will notice that there are several stages for the MPI application:

a. Get the number of processes (size) and the id of the current process (rank).

b. Broadcast the value of the interval to all the processes.

c. Collect the partial sum from all the processes.

d. Print the result and terminate the process execution.

Note: For more information on building MPI applications for Windows HPC Server 2008 R2, refer to the Windows HPC Server 2008 - Using MS-MPI white paper.

6. Change the solution configuration to Release, as shown in Figure 3, and build the solution.

Page 7: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 3Changing 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.

1. Open the command prompt window from Start | All Programs | Accessories | Command Prompt.

2. 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):

CMD

hpcpack create source\piCalculator.zip source\piCalculator\release\

3. 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):

CMD

hpcpack upload source\piCalculator.zip /nodetemplate:"Azure node template" /relativePath:piCalculator

Note: Change the value of the nodetemplate parameter to the name of your Windows Azure node template.

4. Use the following command to create a c:\app directory on the participating Windows Azure nodes:

CMD

clusrun /nodegroup:azurenodes md c:\app\

Note: Change the value of the nodegroup parameter to the name of the group containing your Windows Azure nodes.

5. 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):

CMD

clusrun /nodegroup:azurenodes hpcsync c:\app

Page 8: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Note: Change the value of the nodegroup parameter to the name of the group containing your Windows Azure nodes.

6. 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):

CMD

clusrun /nodegroup:azurenodes hpcfwutil register piCalculator c:\app\piCalculator\piCalculator.exe

Note: 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.

1. Open the HPC 2008 R2 Cluster Manager application from Start | All Programs | Microsoft HPC Pack 2008 R2 | HPC Cluster Manager.

2. 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:

Page 9: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 4Verifying the state of the Windows Azure nodes

3. In the Cluster Manager application, enter the Job Management section and click New Job… in the Actions pane as shown in Figure 5:

Page 10: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 5Create a new job

4. In the New Job dialog, set the Job name to pi calculator, as shown in Figure 6:

Figure 6Setting the name of the job

5. 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:

Page 11: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 7New basic task

6. 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 8Creating the MPI task in the job

7. Click the Resource Selection 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:

Page 12: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 9Selecting node groups for the job

Note: In your HPC cluster, the name of the Windows Azure node group may differ.

8. 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 10Adding an environment variable

9. Click the Submit button to start the job.

10. Once the job is complete, locate it in the finished jobs list, and view its information.

11. 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:

Page 13: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 11Observing the output of the MPI application

Note: 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.

Page 14: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Tachyon Parallel Ray-Tracer

Task 1 - Inspecting the tachyon_mpi Folder Contents

In this task, you will inspect the contents of the tachyon_mpi folder that contains the Tachyon MPI application and some essential utilities needed to execute it on Windows Azure nodes.

1. Open the labs folder, navigate to the MPI\source\tachyon_mpi folder, and review its contents, as shown in Figure 12:

Figure 12The contents of the tachyon_mpi folder

The folder contains the following:

a. AzureBlobCopy. This folder contains a command-line utility for uploading files to Windows Azure blob storage.

b. tachyon.exe. This is the MPI application that will be executed in the Windows Azure nodes.

c. tachyon.bat. This is a batch file that runs the MPI application on the HPC cluster.

d. Input.dat files. These files will be processed by the tachyon.exe MPI application.

2. Open the tachyon.bat file located in the tachyon_mpi folder, and review its contents.

CMD

mpiexec C:\app\tachyon\tachyon.exe -aasamples 4 -trans_vmd C:\app\tachyon\stmvao-white.dat -o C:\app\tachyon\stmvao-white_short.bmp -format BMP -rescale_lights 0.4 -add_skylight 0.9 -skylight_samples 32 -res 2000 2000

C:\app\tachyon\AzureBlobCopy\AzureBlobCopy.exe -Action Upload -BlobContainer tachyonout -LocalDir C:\app\tachyon -FileName stmvao-white_short.bmp

a. The first line uses the mpiexec command to start the tachyon.exe MPI application.

Page 15: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

b. The second line uses the AzureBlobCopy.exe utility to upload the output of the MPI application to Windows Azure blob storage.

Task 2 - Configure the AzureBlobCopy Utility

In this task, you will configure the AzureBlobCopy to upload the result of the tachyon execution to a Windows Azure storage account accessible by you.

1. Open the tachyon_mpi\AzureBlobCopy folder and review its contents, as shown in Figure 13:

Figure 13The contents of the AzureBlobCopy folder

2. Open the AzureBlobCopy.exe.config file and review its contents:

XML

<?xml version="1.0"?><configuration> <appSettings> <add key="StorageAccountName" value="accountName"/> <add key="StorageKey" value="storageKey" /> </appSettings> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup></configuration>

3. Update the configuration StorageAccountName and StorageKey application settings with a valid Windows Azure storage account name and key.

Task 3 - Deploy the Tachyon Application to Windows Azure Worker Nodes

In this task, you will deploy the Tachyon MPI application to your Windows Azure worker nodes.

1. Open the command prompt window from Start | All Programs | Accessories | Command Prompt.

2. 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):

CMD

Page 16: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

hpcpack create source\tachyon.zip source\tachyon_mpi\

3. 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):

CMD

hpcpack upload source\tachyon.zip /nodetemplate:"Azure node template" /relativePath:tachyon

Note: Change the value of the nodetemplate parameter to the name of your Windows Azure node template.

4. Use the following command to create a c:\app directory on the participating Windows Azure nodes:

CMD

clusrun /nodegroup:azurenodes md c:\app\

Note: Change the value of the nodegroup parameter to the name of the group containing your Windows Azure nodes.

5. 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):

CMD

clusrun /nodegroup:azurenodes hpcsync c:\app

Note: Change the value of the nodegroup parameter to the name of the group containing your Windows Azure nodes.

6. 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):

CMD

clusrun /nodegroup:azurenodes hpcfwutil register tachyon c:\app\tachyon\tachyon.exe

Note: Change the value of the nodegroup parameter to the name of the group containing your Windows Azure nodes.

Task 4 – Execute the Tachyon Application and View its Result

In this task, you will use the HPC 2008 R2 Cluster Manager to start a job that executes the Tachyon MPI application via tachyon.bat. Once the job is completed, you will access the Windows Azure blob storage via a URL and view the resulting image.

1. Open the HPC 2008 R2 Cluster Manager application from Start | All Programs | Microsoft HPC Pack 2008 R2 | HPC Cluster Manager.

Page 17: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

2. 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 14:

Figure 14Verifying the state of the Windows Azure nodes

3. In the Cluster Manager application, enter the Job Management section and click New Job… in the Actions pane as shown in Figure 15:

Page 18: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 15Create a new job

4. In the New Job dialog, set the Job name to tachyon, and in the Job resources, set the type of resources to Node, as shown in Figure 16:

Page 19: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 16Setting the name and resource type for the job

Note: The Tachyon application can span several threads on multi-core machines. Rather than running several instances of the application on each node, one per core, it is preferable to run one instance of the application on each node, allowing that instance to take advantage of all the cores. This will reduce the number of running processes as well as the total amount of memory consumed by the Tachyon application.

5. 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 17:

Figure 17

Page 20: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

New basic task

6. In the Task Details and I/O Redirection window, set the Task name field to tachyon.bat, and in the Command Line field enter C:\app\tachyon\tachyon.bat. Finally, set the maximum number of resources to use to 9999, as shown in Figure 18:

Figure 18Creating the MPI task in the job

7. Click the Resource Selection 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 19:

Page 21: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 19Selecting node groups for the job

Note: In your HPC cluster, the name of the Windows Azure node group may differ.

8. 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 20:

Figure 20Adding an environment variable

9. Click the Submit button to start the job.

10. While the job is running, enter the Job Management section, select the tachyon job from the list of active jobs, and click on View Job… in the Actions pane, as shown in Figure 21:

Page 22: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 21Viewing the tachyon job

11. Once the job is complete, open Internet Explorer and browse to the output file in your blob storage. The URL for the file should be as follows: http://YourStorageAccount.blob.core.windows.net/tachyonout/stmvao-white_short.bmp (replace the YourStorageAccount prefix with the name of your storage account, as you defined it in the AzureBlobCopy configuration file).

12. You should now see the generated image from the job, as shown in Figure 22:

Page 23: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Figure 22The BMP image result of tachyon.exe, as viewed from a Windows Azure blob account via Internet Explorer

Page 24: MPI (tachyon, pi)az12722.vo.msecnd.net/.../labs/mpi1-0/MPI.docx · Web viewMPI (tachyon, pi) Description This sample demonstrates how to run MPI applications on Windows Azure nodes

Summary

After running the MPI samples, you should have learned the following:

How to package an MPI application for Windows Azure.

How to deploy an MPI application to Windows Azure nodes.

How to submit an MPI job from the HPC 2008 R2 Cluster Manager application.

How to check a running job’s status and output.