Readme

HPCCPUSpinner

Labversion:1.0.0

Last updated:10/8/2018

Contents

Overview

Getting Started

Task 1 - Inspecting the CPUSpinner Project

Deployment

Task 1 – Deploying the Parametric Sweep Application to On-Premises Nodes

Task 2 – Deploying the Parametric Sweep Application to Windows Azure Nodes

Create a Parametric Sweep Job

Task 1 – Verifying Cluster State

Task 2 – Creating a Parametric Sweep Job

Summary

Overview

TheHPCCPUSpinnersampledemonstrateshowtorunanHPCparametricsweepapplicationonWindowsAzurecomputenodes.ThissampleusesabasicCPUspinnerapplicationthatloadstheCPUofthemachineinwhichitruns.

KeyFeatures

Thissampledemonstratesthefollowing:

  • UploadingaparametricsweepapplicationpackagetoWindowsAzurenodes.
  • CreatingandrunningaparametricsweepjobinaWindowsHPC2008R2SP1cluster.

Getting Started

Torunthissample,youmustinstalltheHPCPack2008R2ClientUtilitiesRedistributablePackagewithServicePack1andtheHPCPack2008R2SDKwithServicePack1.Inaddition,youneedtohave administrative accesstoyourHPCcluster’sheadnode.

ToruntheCPUSpinnerapplicationonWindowsAzurenodes,youmusthaveavalidWindowsAzureaccount,aWindowsAzureworkernodetemplatedefinedinyourheadnode,andseveralWindowsAzureworkernodesintheHPCclusterthatarestartedandonline.FollowtheDeployingAzureWorkerNodesinWindowsHPCServer2008R2SP1Step-by-StepGuideonTechNetforfurtherinformation.

Task 1 - Inspecting the CPUSpinnerProject

In this task, you will inspect the CPU Spinner parametric sweep application. The CPU Spinner is a console application that loads the CPU to mimic the running of a lengthy computational algorithm.

  1. OpenMicrosoftVisualStudio2010fromStart|AllPrograms|MicrosoftVisualStudio2010|MicrosoftVisualStudio2010.
  2. OpentheCPUSpinner.slnsolutionfilelocatedintheCPUSpinner\Sourcefolder.
  3. IntheSolutionExplorerwindow,expandtheCPUSpinnerprojectnode,asshowninFigure 1.

Figure 1

TheCPUSpinnerproject

  1. OpentheSpinner.csfileandinspecttheSpinmethod:

C#

[MethodImpl(MethodImplOptions.NoInlining|

MethodImplOptions.NoOptimization)]

publicstaticvoidSpin(stringinput)

{

varsw=Stopwatch.StartNew();

//Spinforsometime

while(sw.ElapsedMillisecondsConvert.ToInt64(

Environment.GetEnvironmentVariable("SpinDurationMilliseconds")));

sw.Stop();

Console.WriteLine("Completedspinforinput{0},duration{1}milliseconds",

input,sw.ElapsedMilliseconds);

}

  1. ThewhileloopisusedtocreatealoadontheCPU.TheloopwillcontinuefortheperiodspecifiedbytheSpinDurationMillisecondsenvironmentvariable.
  2. TheMethodImplattributeisusedtosuppressanyoptimizationsthataremadetothecodebytheJust-In-Time(JIT)compiler.Withoutthisattribute,theJITcompilermightremovethewhileloop,sincethere is no code inside the loop.
  1. BuildtheCPUSpinnerproject.

Deployment

Inordertorunthissample,youwillneedtodeploytheCPUSpinnerparametricsweepapplicationtoyourcomputenodes(bothon-premisesandWindowsAzurenodes).

Task1–DeployingtheParametricSweepApplicationtoOn-PremisesNodes

Inthistask,youwilldeploytheCPUSpinnerparametricsweepapplicationtoyourHPCcluster’son-premisesnodes.Instead of manually copying the application to each on-premises node, you can use the clusruncommand to run the xcopy command in all the nodes.

Note:IfyouaregoingtotestthissampleonWindowsAzurenodesonly,youcanskipthistask.

  1. Inyourheadnodemachine,createasharenamedapps, and inside it create a folder named CPUSpinner.Verifythatalltheon-premisesnodescanaccessthisshare.
  2. In the SolutionExplorer window, right-click the CPUSpinner project and select OpenFolderinWindowsExplorer.
  3. Navigate to the bin\Debug folder, and copy the folders content to the CPUSpinner folder in the shared folder you created in the head node.
  4. OpenthecommandpromptwindowfromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
  5. Runthefollowingcommandlinetoallowtheparametricsweepapplicationtouse the same command line paths whether it runs inon-premisesnodesor WindowsAzurenodes:

C#

cluscfgsetenvs"CCP_PACKAGE_ROOT=c:\apps"

Note:Toruntheparametricsweepapplicationonbothtypesofnodes(on-premisesandWindowsAzure)withthesamecommandline,youneedtouseanenvironmentvariablethatexistsinbothtypesofnodes.TheCCP_PACKAGE_ROOTenvironmentvariableisalreadydefinedinWindowsAzurecomputenodes;therefore,youneedtodefineitfortheon-premisesnodesaswell.

  1. Run the following command line to instruct all the nodes to copy the application from the shared folder:

CMD

clusrun /nodegroup:ComputeNodesxcopy \\MyHeadNode\apps\CPUSpinner\*.* %CCP_PACKAGE_ROOT%\CPUSpinner\ /Y

Task2–DeployingtheParametricSweepApplicationtoWindowsAzureNodes

Inthistask,youwillpackageanddeploytheCPUSpinnerparametricsweepapplicationtoyourWindowsAzurenodes.

  1. OpenthecommandpromptwindowfromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
  2. NavigatetotheCPUSpinnersamplefolder,andrunthefollowingcommandtocreateadeploymentpackagefortheservice:

CMD

hpcpackcreateCPUSpinner.zipSource\CPUSpinner\bin\debug\

  1. Next,runthefollowingcommandtouploadthedeploymentpackagetotheWindowsAzurepackagestorage:

CMD

hpcpackuploadCPUSpinner.zip/nodetemplate:"Azure nodetemplate"/relativePath:CPUSpinner

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

  1. IfyoualreadyhaveWindowsAzurenodesstartedintheHPCcluster,youneedtocopythenewpackagetothem.TosynctheWindowsAzurenodeswiththenewpackagesstoredintheapplicationpackagesblob,runthefollowingcommand:

CMD

clusrun/nodegroup:AzureWorkerNodeshpcsync

Create a ParametricSweepJob

Task1–VerifyingClusterState

Inthistask,youwillverifythatthenodesinyourclusterareonline.

  1. OpentheHPC2008R2ClusterManagerapplicationfromStart|AllPrograms|MicrosoftHPCPack2008R2|HPCClusterManager.
  2. IntheClusterManagerapplication,entertheNodeManagementsectionandverifythattheWindowsAzurenodesintheclusterareonline,asshown inFigure 2

Figure 2

VerifyingtheStateoftheWindowsAzureNodes

Task2–CreatingaParametricSweepJob

Inthistask,youwillcreateaparametricsweepjobfortheCPUSpinnerapplication.

  1. IntheClusterManagerapplication,entertheJobManagementsectionandclickNewJob…intheActionspaneasshowninFigure 3

Figure3

CreateaNewJob

  1. IntheNewJobdialog,settheJobnametocpuspinner,asshowninFigure 4

Figure4

SettingstheNameoftheJob

  1. StillintheNewJobdialog,clicktheEditTasksoption,clickthearrownexttotheAddbutton,andthenclickParametricSweepTask…,asshowninFigure 5

Figure5

NewParametricSweepTask

  1. IntheParametricSweepTaskdialog,enterthefollowinginformationandthenclickOK:
  2. Taskname:CPUSpinnertask
  3. Startvalue:1
  4. Endvalue:1000
  5. Commandline:CPUSpinner.exe*
  6. WorkingDirectory:%CCP_PACKAGE_ROOT%\CPUSpinner

Figure6

SettingtheParametricSweepTaskDetails

  1. ClicktheResourceSelectionoption,checktheRunthisjobonlyonnodesthataremembersofallthefollowinggroupscheckbox,andthenaddtheAzureWorkerNodesgroup,asshowninFigure 7

Figure7

SelectingNodeGroupsfortheJob

  1. ClicktheEnvironmentVariablesoption,clicktheAddbutton,fillinthefollowinginformation,andclickOK:
  2. Name:SpinDurationMilliseconds
  3. Value:5000

Figure8

AddanEnvironmentVariabletotheJob

  1. ClicktheSubmitbuttontostarttheparametricsweepjob.
  2. Whilethejobisrunning,entertheJobManagementsection,selecttheCPUSpinnerjobfromtheactivejobs,andclickonViewJob…intheActionspane,asshowninFigure 9

Figure9

ViewRunningJobInformation

  1. TheViewJobdialogdisplaysthecurrentstateofthejob,asshowninFigure 10

ClicktheRefreshbuttoneverycoupleofsecondstoseethechangeinthenumberoffinishedtasks.

Figure10

RunningJob’sState

SelecttheViewTasksoption,selectoneofthetasks,andinspecttheoutputoftheCPUSpinnerconsoleapplication,asshowninFigure 11

Figure11

OutputoftheCPUSpinnerApplication

Summary

AfterrunningtheCPUSpinnersampleyoushouldhavelearnedthefollowing:

  • HowtopackageanapplicationforWindowsAzure.
  • HowtodeployanapplicationtoWindowsAzurenodesandtoon-premisesnodes.
  • HowtosubmitaparametricsweepjobfromtheHPC2008R2ClusterManagerapplication.
  • Howtocheckarunningjob’sstatusandatask’soutput.