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.
- OpenMicrosoftVisualStudio2010fromStart|AllPrograms|MicrosoftVisualStudio2010|MicrosoftVisualStudio2010.
- OpentheCPUSpinner.slnsolutionfilelocatedintheCPUSpinner\Sourcefolder.
- IntheSolutionExplorerwindow,expandtheCPUSpinnerprojectnode,asshowninFigure 1.
Figure 1
TheCPUSpinnerproject
- 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);
}
- ThewhileloopisusedtocreatealoadontheCPU.TheloopwillcontinuefortheperiodspecifiedbytheSpinDurationMillisecondsenvironmentvariable.
- TheMethodImplattributeisusedtosuppressanyoptimizationsthataremadetothecodebytheJust-In-Time(JIT)compiler.Withoutthisattribute,theJITcompilermightremovethewhileloop,sincethere is no code inside the loop.
- 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.
- Inyourheadnodemachine,createasharenamedapps, and inside it create a folder named CPUSpinner.Verifythatalltheon-premisesnodescanaccessthisshare.
- In the SolutionExplorer window, right-click the CPUSpinner project and select OpenFolderinWindowsExplorer.
- 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.
- OpenthecommandpromptwindowfromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
- 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.
- 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.
- OpenthecommandpromptwindowfromStart|AllPrograms|MicrosoftVisualStudio2010|VisualStudioTools|VisualStudioCommandPrompt(2010).
- NavigatetotheCPUSpinnersamplefolder,andrunthefollowingcommandtocreateadeploymentpackagefortheservice:
CMD
hpcpackcreateCPUSpinner.zipSource\CPUSpinner\bin\debug\
- 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.
- IfyoualreadyhaveWindowsAzurenodesstartedintheHPCcluster,youneedtocopythenewpackagetothem.TosynctheWindowsAzurenodeswiththenewpackagesstoredintheapplicationpackagesblob,runthefollowingcommand:
CMD
clusrun/nodegroup:AzureWorkerNodeshpcsync
Create a ParametricSweepJob
Task1–VerifyingClusterState
Inthistask,youwillverifythatthenodesinyourclusterareonline.
- OpentheHPC2008R2ClusterManagerapplicationfromStart|AllPrograms|MicrosoftHPCPack2008R2|HPCClusterManager.
- IntheClusterManagerapplication,entertheNodeManagementsectionandverifythattheWindowsAzurenodesintheclusterareonline,asshown inFigure 2
Figure 2
VerifyingtheStateoftheWindowsAzureNodes
Task2–CreatingaParametricSweepJob
Inthistask,youwillcreateaparametricsweepjobfortheCPUSpinnerapplication.
- IntheClusterManagerapplication,entertheJobManagementsectionandclickNewJob…intheActionspaneasshowninFigure 3
Figure3
CreateaNewJob
- IntheNewJobdialog,settheJobnametocpuspinner,asshowninFigure 4
Figure4
SettingstheNameoftheJob
- StillintheNewJobdialog,clicktheEditTasksoption,clickthearrownexttotheAddbutton,andthenclickParametricSweepTask…,asshowninFigure 5
Figure5
NewParametricSweepTask
- IntheParametricSweepTaskdialog,enterthefollowinginformationandthenclickOK:
- Taskname:CPUSpinnertask
- Startvalue:1
- Endvalue:1000
- Commandline:CPUSpinner.exe*
- WorkingDirectory:%CCP_PACKAGE_ROOT%\CPUSpinner
Figure6
SettingtheParametricSweepTaskDetails
- ClicktheResourceSelectionoption,checktheRunthisjobonlyonnodesthataremembersofallthefollowinggroupscheckbox,andthenaddtheAzureWorkerNodesgroup,asshowninFigure 7
Figure7
SelectingNodeGroupsfortheJob
- ClicktheEnvironmentVariablesoption,clicktheAddbutton,fillinthefollowinginformation,andclickOK:
- Name:SpinDurationMilliseconds
- Value:5000
Figure8
AddanEnvironmentVariabletotheJob
- ClicktheSubmitbuttontostarttheparametricsweepjob.
- Whilethejobisrunning,entertheJobManagementsection,selecttheCPUSpinnerjobfromtheactivejobs,andclickonViewJob…intheActionspane,asshowninFigure 9
Figure9
ViewRunningJobInformation
- TheViewJobdialogdisplaysthecurrentstateofthejob,asshowninFigure 10
ClicktheRefreshbuttoneverycoupleofsecondstoseethechangeinthenumberoffinishedtasks.
Figure10
RunningJob’sState
SelecttheViewTasksoption,selectoneofthetasks,andinspecttheoutputoftheCPUSpinnerconsoleapplication,asshowninFigure 11
Figure11
OutputoftheCPUSpinnerApplication
Summary
AfterrunningtheCPUSpinnersampleyoushouldhavelearnedthefollowing:
- HowtopackageanapplicationforWindowsAzure.
- HowtodeployanapplicationtoWindowsAzurenodesandtoon-premisesnodes.
- HowtosubmitaparametricsweepjobfromtheHPC2008R2ClusterManagerapplication.
- Howtocheckarunningjob’sstatusandatask’soutput.