Difference between revisions of "Scientific Computing Course"

From oldwiki.scinet.utoronto.ca
Jump to navigation Jump to search
Line 78: Line 78:
  
 
===HW1===
 
===HW1===
 +
 +
'''''Multi-file C++ program to create a data file'''''
 +
 +
We’ve learned programming in basic C++, use of make and Makefiles to build projects, and local use of git for version control. In this first assignment, you’ll use these to make a multi-file C++ program, built with make, which computes and outputs a data file.
 +
 +
* Start a git repository, and begin writing a C++ program to
 +
:# Get an array size and a standard deviation from user input,
 +
:# Allocate a 2d array,
 +
:# Store a 2d Gaussian with a maximum at the centre of the array \& given standard deviation (in units of grid points),
 +
:# Outputs that array to a text file,
 +
:# Free the array, and exit.
 +
* The output text file should contain just the data in text format, with a row of the file corresponding to a row of the array and with whitespace between the numbers.
 +
* The 2d array creation/freeing routines should be in one file (with an associated header file), the gaussian calculation be in another (ditto), and the output routine be in a third, with the main program calling each of these.
 +
* Use a makefile to build your code (add it to the repository).
 +
* You can start with everything in one file, with hardcoded values for sizes and standard deviation and a static array, then refactor things into multiple files, adding the other features.
 +
* As a test, use the ipython executable that came with your Enthought python distribution to read your data and plot it.<br>If your data file is named ‘data.txt’, running the following:
 +
<pre>
 +
$ ipython --pylab
 +
In [1]: data = numpy.genfromtxt('data.txt')
 +
In [2]: contour(data)
 +
</pre>
 +
should give a nice contour plot of a 2-dimensional gaussian.
 +
* Email in your source code and the git log file of all your commits by email by next Thursday at 9:00 am.
  
 
=Part 2: Numerical Tools for Physical Scientists=
 
=Part 2: Numerical Tools for Physical Scientists=

Revision as of 14:19, 17 January 2013

This wiki page concerns the 2013 installment of SciNet's Scientific Computing course. Material from the previous installment can be found on Scientific Software Development Course, Numerical Tools for Physical Scientists (course), and High Performance Scientific Computing


Syllabus

About the course

  • Whole-term graduate course
  • Prerequisite: basic C, C++ or Fortran experience.
  • Will use `C++ light' and Python
  • Topics include: Scientific computing and programming skills, Parallel programming, and Hybrid programming.

There are three parts to this course:

  1. Scientific Software Development: Jan/Feb 2013
    python, C++, git, make, modular programming, debugging
  2. Numerical Tools for Physical Scientists: Feb/Mar 2013
    modelling, floating point, Monte Carlo, ODE, linear algebra,fft
  3. High Performance Scientific Computing: Mar/Apr 2013
    openmp, mpi and hybrid programming

Each part consists of eight one-hour lectures, two per week.

These can be taken separately by astrophysics graduate students at the University of Toronto as mini-courses, and by physics graduate students at the University of Toronto as modular courses.

The first two parts count towards the SciNet Certificate in Scientific Computing, while the third part can count towards the SciNet HPC Certificate. For more info about the SciNet Certificates, see http://www.scinethpc.ca/2012/12/scinet-hpc-certificate-program.

Location and Times

SciNet HeadQuarters
256 McCaul Street, Toronto, ON
Room 229 (Conference Room)
Tuesdays 11:00 am - 12:00 noon
Thursdays 11:00 am - 12:00 noon

Instructors and office hours

  • Ramses van Zon - 256 McCaul Street, Rm 228 - Mondays 3-4pm
  • L. Jonathan Dursi - 256 McCaul Street, Rm 216 - Wednesdays 3-4pm

Grading scheme

Attendence to lectures.

Four home work sets (i.e., one per week), to be returned by email by 9:00 am the next Thursday.

Sign up

Sign up for this graduate course goes through SciNet's course website.
The direct link is https://support.scinet.utoronto.ca/courses/?q=node/99.
If you do not have a SciNet account but wish to register for this course, please email support@scinet.utoronto.ca .


Part 1: Scientific Software Development

Prerequisites

Some programming experience. Some unix prompt experience.

Software that you'll need:

A unix-like environment with the GNU compiler suite (e.g. Cygwin), and Python (Enthought) installed on your laptop.

Dates

January 15, 17, 22, 24, 29, and 31, 2013
February 5 and 7, 2013

Topics (with lecture slides and recordings)

Lecture 1   C++ introduction

Slides  /   Recording

Lecture 2   More C++, build and version control

C++ and Make slides  /   C++ and Make Recording  /   Git slides  /   Homework assigment

Lecture 3   Python and visualization
Lecture 4   Modular programming, refactoring, testing
Lecture 5   Object oriented programming
Lecture 6   ODE, interpolation
Lecture 7   Development tools: debugging and profiling
Lecture 8   Objects in Python, linking C++ and Python

Homework assignments

HW1

Multi-file C++ program to create a data file

We’ve learned programming in basic C++, use of make and Makefiles to build projects, and local use of git for version control. In this first assignment, you’ll use these to make a multi-file C++ program, built with make, which computes and outputs a data file.

  • Start a git repository, and begin writing a C++ program to
  1. Get an array size and a standard deviation from user input,
  2. Allocate a 2d array,
  3. Store a 2d Gaussian with a maximum at the centre of the array \& given standard deviation (in units of grid points),
  4. Outputs that array to a text file,
  5. Free the array, and exit.
  • The output text file should contain just the data in text format, with a row of the file corresponding to a row of the array and with whitespace between the numbers.
  • The 2d array creation/freeing routines should be in one file (with an associated header file), the gaussian calculation be in another (ditto), and the output routine be in a third, with the main program calling each of these.
  • Use a makefile to build your code (add it to the repository).
  • You can start with everything in one file, with hardcoded values for sizes and standard deviation and a static array, then refactor things into multiple files, adding the other features.
  • As a test, use the ipython executable that came with your Enthought python distribution to read your data and plot it.
    If your data file is named ‘data.txt’, running the following:
$ ipython --pylab
In [1]: data = numpy.genfromtxt('data.txt') 
In [2]: contour(data) 

should give a nice contour plot of a 2-dimensional gaussian.

  • Email in your source code and the git log file of all your commits by email by next Thursday at 9:00 am.

Part 2: Numerical Tools for Physical Scientists

Prerequisites

Part 1 or solid c++ programming skills, including make and unix/linux prompt experience.

Software that you'll need

A unix-like environment with the GNU compiler suite (e.g. Cygwin), and Python (Enthought) installed on your laptop.

Dates

February 12, 14, 26, and 28, 2013
March 5, 7, 12, and 14, 2013

Topics

Lecture 9    Numerics
Lecture 10   Random numbers
Lecture 11   Numerical integration and ODEs
Lecture 12   Molecular Dynamics
Lecture 13   Linear Algebra part I
Lecture 14   Linear Algebra part II and PDEs
Lecture 15   Fast Fourier Transform
Lecture 16   FFT for real and multidimensional data


Part 3: High Performance Scientific Computing

Prerequisites

Part 1 or good c++ programming skills, including make and unix/linux prompt experience.

Software that you'll need

You will need to bring a laptop with a ssh facility. Hands-on parts will be done on SciNet's GPC cluster.

For those who don't have a SciNet account yet, the instructions can be found at http://wiki.scinethpc.ca/wiki/index.php/Essentials\#Accounts

Dates

March 19, 21, 26, and 28, 2013
April 2, 4, 9, and 11, 2013

Topics

Lecture 17   Intro to Parallel Computing
Lecture 18   Parallel Computing Paradigms
Lecture 19   Shared Memory Programming with OpenMP, part 1
Lecture 20   Shared Memory Programming with OpenMP part 2
Lecture 21   Distributed Parallel Programming with MPI, part 1
Lecture 22   Distributed Parallel Programming with MPI, part 2
Lecture 23   Distributed Parallel Programming with MPI, part 3
Lecture 24   Hybrid OpenMPI+MPI Programming