Share via


Getting Started

To run this sample, you must install the HPC Pack 2008 R2 Client Utilities Redistributable Package with Service Pack 1 (or higher) and the HPC Pack 2008 R2 SDK with Service Pack 1 (or higher). In addition, you need to have administrative access to your HPC cluster’s head node.

To run the CPU Spinner application on Windows Azure nodes, 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 Azure Worker Nodes in Windows HPC Server 2008 R2 SP1 Step-by-Step Guide on TechNet for further information.

Task 1 - Inspecting the CPUSpinner Project

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. Open Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010 | Microsoft Visual Studio 2010.
  2. Open the CPUSpinner.sln solution file located in the CPUSpinner\Source folder.
  3. In the Solution Explorer window, expand the CPUSpinner project node, as shown in Figure 1:

    Figure 1

    The CPUSpinner project

  4. Open the Spinner.cs file and inspect the Spin method:

    C#

    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void Spin(string input) { var sw = Stopwatch.StartNew(); // Spin for some time while (sw.ElapsedMilliseconds < Convert.ToInt64( Environment.GetEnvironmentVariable("SpinDurationMilliseconds"))) ; sw.Stop(); Console.WriteLine("Completed spin for input {0}, duration {1} milliseconds", input, sw.ElapsedMilliseconds); }

    1. The while loop is used to create a load on the CPU. The loop will continue for the period specified by the SpinDurationMilliseconds environment variable.
    2. The MethodImpl attribute is used to suppress any optimizations that are made to the code by the Just-In-Time (JIT) compiler. Without this attribute, the JIT compiler might remove the while loop, since there is no code inside the loop.
  5. Build the CPUSpinner project.