Difference between revisions of "Windows Usage Tips"

From CAC Documentation wiki
Jump to navigation Jump to search
(Deleted transclusion of "Changing Python Version", no longer relevant)
 
Line 1: Line 1:
 +
This page contains information for CAC's former Windows HPC clusters, which are no longer in service.
 +
 
====Compiling and Linking Codes on Windows====
 
====Compiling and Linking Codes on Windows====
 
{{:Compiling Code Windows}}
 
{{:Compiling Code Windows}}
 +
====Changing Python version====
 +
{{:Changing Python Version}}

Latest revision as of 17:26, 18 September 2019

This page contains information for CAC's former Windows HPC clusters, which are no longer in service.

Compiling and Linking Codes on Windows

The Windows login node provides the Microsoft Visual Studio 2005 and 2008 integrated development environments (IDEs) into which the following compilers are integrated: Microsoft C/C++, Intel C/C++ 11.0, and Intel Fortran 11.0, among others. If desired, any one of these compilers can be invoked from the command line in a Windows command shell (cmd) as well. (The command-line compiler names are cl, icl, and ifort.) However, the Visual Studio environment is preferred because it doubles as a debugger.

Getting Started in Visual Studio

In Visual Studio, you begin by creating a solution that builds one or more projects. Roughly speaking, the projects within a solution are equivalent to the targets of a Linux makefile. Each separate project corresponds to one executable or one library that is to be built.

To start a new project that (e.g.) builds an executable, given one or more files of Fortran or C code:

  • First select "File | New | Project...", then
    • either "Intel Fortran | Console Application | Empty Project"
    • or "Visual C++ | Win32 | Win32 Console Application"
  • Next, add files containing source code to the project, using
    • either "Project | Add | New Item..."
    • or "Project | Add | Existing Item..."

A C/C++ project can later be converted to Intel C/C++ if desired.

Compilation is controlled through the Properties dialog, in the Project menu. This dialog is nothing more than a GUI for setting the command-line compiler flags. You can define multiple configurations for each project. The active configuration determines the particular set of flags that are passed to the compiler when the project is built. By default, there are two configurations named Debug and Release that are predefined for the Win32 platform, and Debug is the active configuration.

The problem is we don't generally want to use the Win32 platform; we want the x64 platform. Strangely, this choice does not appear anywhere in the Properties dialog until you click the Configuration Manager button (which is also available from "Build | Configuration Manager"). Under "Active solution platform", choose "New...", then "x64", then "OK" the changes you have made.

(Note: Unexpected problems with the Visual Studio interface can sometimes be cleared by starting it up with "devenv /resetsettings".)

Additional Steps for MPI Codes

For MPI codes, a few more steps are necessary in Properties. Set the Configuration to All Configurations and add the following:

  • For x64 platform -
    • C/C++ or Fortran | General | Additional Include Directories:
          C:\Program Files\Microsoft HPC Pack 2008 SDK\Include
    • Linker | General | Additional Library Directories:
          C:\Program Files\Microsoft HPC Pack 2008 SDK\Lib\amd64
    • Linker | Input | Additional Dependencies:
          msmpi.lib

For Fortran codes, in addition to msmpi.lib, one of the msmpif*c.lib static libraries is required:

  • msmpifec.lib supports Fortran compilers that put the string length of character variables at the very end of the parameter stack (e = end; most common case).
  • msmpifmc.lib supports Fortran compilers that put the string length of character variables immediately after the corresponding string pointers on the parameter stack (m = mixed).

The Intel EM64T processors on the V4 Windows Cluster can run either 64-bit ("amd64") or 32-bit ("i386") applications, so it is possible to compile and link MPI codes for the Win32 platform, as well as x64. To build for Win32, only one minor change must be made to the above Properties:

  • For Win32 platform -
    • Linker | General | Additional Library Directories:
          C:\Program Files\Microsoft HPC Pack 2008 SDK\Lib\i386
Compiling at the Command Prompt

There seems to be no convenient "mpicc" wrapper designed for use with the Microsoft C compiler and msmpi.lib. But if you prefer to compile your MPI code at the command prompt instead of within Visual Studio, it's not hard at all to pass a couple of options to cl.exe. First, fire up a shell in which you can run "cl" (the command-line name of the Microsoft C compiler):

Start > All Programs > Microsoft Visual Studio 2008 > Visual Studio Tools > Visual Studio 2008 x64 Cross Tools Command Prompt

In the shell window that appears, compile your code using "cl", simply supplying it with the include path to the MPI header file via the capital-I flag, and, after the /link flag, the /libpath to msmpi.lib, like this:

cl helloworld.c /I "C:\Program Files\Microsoft HPC Pack 2008 SDK\Include" /link
   /libpath:"C:\Program Files\Microsoft HPC Pack 2008 SDK\Lib\amd64" msmpi.lib

Be sure to pay careful attention to all spaces, colons, quotes, etc. in the above syntax. More information on the various options for cl can be found by typing "cl /?".

Linking Intel's Math Kernel Library

Similar steps to the above are involved for linking libraries other than MPI. For example, should one wish to link any of the LAPACK or BLAS routines in Intel's MKL 10 (with a choice of static linking, rather than dll's), here are the additions to make in the Visual Studio dialogs and tabs:

  • For x64 platform -
    • C/C++ | General | Additional Include Directories (optional for Fortran):
          C:\Program Files\Intel\MKL\10.0.3.021\include
    • Linker | General | Additional Library Directories:
          C:\Program Files\Intel\MKL\10.0.3.021\em64t\lib
    • Linker | Input | Additional Dependencies:
          mkl_intel_lp64.lib mkl_intel_thread.lib mkl_core.lib libguide40.lib

Linking to MKL has become rather complicated due to Intel's decision to maximize MKL's flexibility and multi-platform compatibility by splitting off multithreading into four separate layers of libraries. The four libraries listed above correspond to the four essential layers: interface layer, threading layer, computational layer, and runtime (OpenMP) layer. For more help, including examples of using both static and dynamic linking in various ways, refer to the Intel MKL User Guide, C:\Program Files\Intel\MKL\10.0.3.021\doc\userguide.pdf, Chapter 5.

Changing Python version

We have a few versions of Python on the system.

  • C:\Python25epd - Enthought Python 2.5.4 is the default. It has a large list of helpful libraries that are already tested.
  • C:\Python25 - For anyone who might prefer to use the python.org distribution of Python 2.5.1.
  • C:\Python26 - For those who need 2.6 language features. Popular numeric libraries aren't available for this release.
  • C:\Python30 - For those who need 3.0 language features. This new release changes the language. Most numeric libraries aren't available.

To choose a particular version of Python over the default, in a batch script or interactively, set the PYTHONHOME variable to the appropriate directory, then start up the command-line interpreter:

set PYTHONHOME=C:\Python30
C:\Python30\python myfile.py

If you fail to set PYTHONHOME, the executable will load its libraries from Python25epd.

In order to start IDLE, which is the integrated development environment (IDE) for all of the above versions of Python, enter:

%PYTHONHOME%\pythonw %PYTHONHOME%\Lib\idlelib\idle.pyw