PETSc and Neuronal Networks Toby Isaac VIGRE Seminar, Wednesday, November 15, 2006.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Introduction to Algorithms Quicksort
COSC513 Operating System Research Paper Fundamental Properties of Programming for Parallelism Student: Feng Chen (134192)
M AT L AB Programming: scripts & functions. Scripts It is possible to achieve a lot simply by executing one command at a time on the command line (even.
CSC321: 2011 Introduction to Neural Networks and Machine Learning Lecture 7: Learning in recurrent networks Geoffrey Hinton.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
GridRPC Sources / Credits: IRISA/IFSIC IRISA/INRIA Thierry Priol et. al papers.
Strings and Arrays The objectives of this chapter are:  To discuss the String class and some of its methods  To discuss the creation and use of Arrays.
Lecture 14 – Neural Networks
Homework Any Questions?. Statements / Blocks, Section 3.1 An expression becomes a statement when it is followed by a semicolon x = 0; Braces are used.
Reference: Message Passing Fundamentals.
Parallel Mesh Refinement with Optimal Load Balancing Jean-Francois Remacle, Joseph E. Flaherty and Mark. S. Shephard Scientific Computation Research Center.
Chapter 15 Strings String::Concat String::CompareTo, Equals, == If( string1 == S”Hello”) String1->Equals(S”Hello”) String1->CompareTo(S”Hello”) CompareTo.
Pipelined Computations Divide a problem into a series of tasks A processor completes a task sequentially and pipes the results to the next processor Pipelining.
Chapter 6 C Arrays Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc. Arrays are data structures.
CS1061 C Programmuing Lecture 12 Arrays A. O’Riordan, 2004.
 Pearson Education, Inc. All rights reserved Arrays.
The hybird approach to programming clusters of multi-core architetures.
CIT 590 Unit testing. Agenda Debugging attempt 2 (because I am stubborn) What is unit testing Why? Unit testing framework in Python.
Subroutines Just like C, PERL offers the ability to use subroutines for all the same reasons – Code that you will use over and over again – Breaking large.
EPSII 59:006 Spring Topics Using TextPad If Statements Relational Operators Nested If Statements Else and Elseif Clauses Logical Functions For Loops.
CS 591x – Cluster Computing and Programming Parallel Computers Parallel Libraries.
MOV,MOVM,COP,FLL,BSL,BSR, FRD,TOD
Programming Languages -1 (Introduction to C) arrays Instructor: M.Fatih AMASYALI
Copyright © 2012 Pearson Education, Inc. Chapter 8 Two Dimensional Arrays.
Artificial Neural Networks
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Scientific Computing Division A tutorial Introduction to Fortran Siddhartha Ghosh Consulting Services Group.
 2005 Pearson Education, Inc. All rights reserved. 1 Arrays.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
Arrays An array is a data structure that consists of an ordered collection of similar items (where “similar items” means items of the same type.) An array.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
Exception Handling Unit-6. Introduction An exception is a problem that arises during the execution of a program. An exception can occur for many different.
Parallel Algorithms & Distributed Computing Matt Stimmel Matt White.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
 2006 Pearson Education, Inc. All rights reserved Arrays.
Loops (cont.). Loop Statements  while statement  do statement  for statement while ( condition ) statement; do { statement list; } while ( condition.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
 2007 Pearson Education, Inc. All rights reserved C Arrays.
Software testing techniques Software testing techniques Interface Testing Presentation on the seminar Kaunas University of Technology.
Radix Sort and Hash-Join for Vector Computers Ripal Nathuji 6.893: Advanced VLSI Computer Architecture 10/12/00.
Function Overloading Two different functions may have the same name as long as they differ in the number or types of arguments: int max(int x, int y) and.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
Lecture 15: Course Review BJ Furman ME 30 16MAY2011.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
Slides prepared by Rose Williams, Binghamton University Chapter 16 Collections and Iterators.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
Mehdi Ghayoumi MSB rm 132 Ofc hr: Thur, a Machine Learning.
COSC 1P02 Introduction to Computer Science 5.1 Cosc 1P02 Week 5 Lecture slides Psychiatrist to patient "You have nothing to worry about - anyone who can.
C++ Array 1. C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used.
Chapter 5: Arrays in Java. The objectives of this chapter are:  1. To discuss the creation and use of Arrays.   2. To continue to use the String class.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
 2005 Pearson Education, Inc. All rights reserved Arrays.
ITM 3521 ITM 352 Functions. ITM 3522 Functions  A function is a named block of code (i.e. within {}'s) that performs a specific set of statements  It.
LESSON 8: INTRODUCTION TO ARRAYS. Lesson 8: Introduction To Arrays Objectives: Write programs that handle collections of similar items. Declare array.
TransAT Tutorial Backward Step May 2015 ASCOMP
CIT 590 Unit testing.
Loops BIS1523 – Lecture 10.
Neural Network Implementations on Parallel Architectures
In-situ Visualization using VisIt
Introduction to parallel algorithms
Scripts & Functions Scripts and functions are contained in .m-files
MATLAB: Structures and File I/O
ENGG 1801 Engineering Computing
Multivector and SIMD Computers
Instruction encoding We’ve already seen some important aspects of processor design. A datapath contains an ALU, registers and memory. Programmers and compilers.
Introduction to parallel algorithms
Instruction encoding We’ve already seen some important aspects of processor design. A datapath contains an ALU, registers and memory. Programmers and compilers.
Testing & Security Dr. X.
Introduction to parallel algorithms
Presentation transcript:

PETSc and Neuronal Networks Toby Isaac VIGRE Seminar, Wednesday, November 15, 2006

Tips for general ODEs

Recall: have an input program to convert to PETSc binary format

Tips for general ODEs Recall: have an input program to convert to PETSc binary format e.g.: Vec for initial values, Mat for linear ODE, adjacency/connectivity Mat

Tips for general ODEs Recall: have an input program to convert to PETSc binary format e.g.: Vec for initial values, Mat for linear ODE, adjacency/connectivity Mat PetscBinaryView for arrays of scalars (see exampleinput.c)

Tips for general ODEs To keep scalar parameters organized (end time, dt, # cells, etc.) use a PetscBag:

Tips for general ODEs To keep scalar parameters organized (end time, dt, # cells, etc.) use a PetscBag: Allows you to save a struct in binary and read in to all processors

Tips for general ODEs To keep scalar parameters organized (end time, dt, # cells, etc.) use a PetscBag: Allows you to save a struct in binary and read in to all processors No need to keep track of order in which scalars are written/read

Tips for general ODEs Recall: using “Load” functions, parallel layout is specified at read in…

Tips for general ODEs Recall: using “Load” functions, parallel layout is specified at read in… Except for arrays: only go to first processor

Tips for general ODEs Recall: using “Load” functions, parallel layout is specified at read in… Except for arrays: only go to first processor Use MPI_Bcast to send those arrays to all processors

Tips for general ODEs Recall: using “Load” functions, parallel layout is specified at read in… Except for arrays: only go to first processor Use MPI_Bcast to send those arrays to all processors e.g.: piecewise constant inj. current

Tips for general ODEs A TS object keeps track of the settings for time-stepping

Tips for general ODEs A TS object keeps track of the settings for time-stepping Same old song: TSCreate and TSDestroy

Tips for general ODEs A TS object keeps track of the settings for time-stepping Same old song: TSCreate and TSDestroy TSSetType: forward Euler, backward Euler, “ode45”, (pseudo-timestepping)

Tips for general ODEs A TS object keeps track of the settings for time-stepping Same old song: TSCreate and TSDestroy TSSetType: forward Euler, backward Euler, “ode45”, (pseudo-timestepping) TSSetProblemType: linear, nonlinear

Tips for general ODEs TSSetSolution: set initial conditions

Tips for general ODEs TSSetSolution: set initial conditions TSSetRHSFunction/TSSetRHSMatrix:

Tips for general ODEs TSSetSolution: set initial conditions TSSetRHSFunction/TSSetRHSMatrix: Specified functions has format rhsfunc(ts, t, u, du, void *additional arguments)

Tips for general ODEs TSSetSolution: set initial conditions TSSetRHSFunction/TSSetRHSMatrix: Specified functions has format rhsfunc(ts, t, u, du, void *additional arguments) Create a struct for passing additional arguments

Tips for general ODEs TSSetRHSJacobian, if method calls for it

Tips for general ODEs TSSetRHSJacobian, if method calls for it TSSetInitialTimeStep (that is, initial time and initial time step)

Tips for general ODEs TSSetRHSJacobian, if method calls for it TSSetInitialTimeStep (that is, initial time and initial time step) TSSetDuration

Tips for general ODEs TSSetRHSJacobian, if method calls for it TSSetInitialTimeStep (that is, initial time and initial time step) TSSetDuration TSRKSetTolerance:

Tips for general ODEs TSSetRHSJacobian, if method calls for it TSSetInitialTimeStep (that is, initial time and initial time step) TSSetDuration TSRKSetTolerance: Control absolute error over whole time of integration: a bit sketchy

Tips for general ODEs If only interested in final state, run TSStep to execute

Tips for general ODEs If only interested in final state, run TSStep to execute If interested in progress along the way, you need a monitor function:

Tips for general ODEs If only interested in final state, run TSStep to execute If interested in progress along the way, you need a monitor function: Runs after every time step, can output, plot, change parameters, change time- step etc.

Tips for general ODEs Multiple monitor functions can run: e.g. one for parameter changes, one for output

Tips for general ODEs Multiple monitor functions can run: e.g. one for parameter changes, one for output Attention IAF modelers: you can change the state vector too!

Tips for general ODEs Multiple monitor functions can run: e.g. one for parameter changes, one for output Attention IAF modelers: you can change the state vector too! Syntax: TSSetMonitor, monitor(ts, iter#, t, u, void *args)

Tips for Homogeneous Nets

Most dependency occurs within cell: bad to have one cell divided across processors

Tips for Homogeneous Nets Most dependency occurs within cell: bad to have one cell divided across processors No guarantee that PETSC_DECIDE won’t split your vector this way

Tips for Homogeneous Nets Have a vector y of length = # cells

Tips for Homogeneous Nets Have a vector y of length = # cells PETSc evenly distributes this vector

Tips for Homogeneous Nets Have a vector y of length = # cells PETSc evenly distributes this vector nlocal = VecGetLocalSize(y)

Tips for Homogeneous Nets Have a vector y of length = # cells PETSc evenly distributes this vector nlocal = VecGetLocalSize(y) VecCreateMPI(…, neqns*nlocalcells, PETSC_DETERMINE,&x);

Tips for Homogeneous Nets VecSetBlockSize: set this to the number of equations per cell

Tips for Homogeneous Nets VecSetBlockSize: set this to the number of equations per cell VecStrideGather: send value from same index for each block to another vector

Tips for Homogeneous Nets VecSetBlockSize: set this to the number of equations per cell VecStrideGather: send value from same index for each block to another vector VecStrideScatter: send values from a vector to the same index for each block

Tips for Homogeneous Nets Paradigm for ease/simplicity: gather like indices, make changes, scatter back

Tips for Homogeneous Nets Paradigm for ease/simplicity: gather like indices, make changes, scatter back VecStrideGatherAll/VecStrideScatterAll: take the state vector, break it up into an array of vectors, one for each equivalent index

Tips for Homogeneous Nets In RHSFunction: Vec U and Vec DU are inputs

Tips for Homogeneous Nets In RHSFunction: Vec U and Vec DU are inputs Declare arrays Vec u[neqns], du[neqns]

Tips for Homogeneous Nets In RHSFunction: Vec U and Vec DU are inputs Declare arrays Vec u[neqns], du[neqns] VecStrideGatherAll at the start

Tips for Homogeneous Nets In RHSFunction: Vec U and Vec DU are inputs Declare arrays Vec u[neqns], du[neqns] VecStrideGatherAll at the start Set du[i] in terms of u[] for each i

Tips for Homogeneous Nets In RHSFunction: Vec U and Vec DU are inputs Declare arrays Vec u[neqns], du[neqns] VecStrideGatherAll at the start Set du[i] in terms of u[] for each I VecStrideScatterAll at the end

Tips for Homogeneous Nets For very large networks, large number of processors: message passing will take its toll

Tips for Homogeneous Nets For very large networks, large number of processors: message passing will take its toll Order cells so that connections occur between close numbers

Tips for Homogeneous Nets For very large networks, large number of processors: message passing will take its toll Order cells so that connections occur between close numbers MatGetOrdering, MATORDERING_RCM, MatPermute

Tips for Inhomogeneous Nets

VecSetBlockSize no longer an option

Tips for Inhomogeneous Nets VecSetBlockSize no longer an option Can be reproduced with more generic VecGather/VecScatter

Tips for Inhomogeneous Nets VecSetBlockSize no longer an option Can be reproduced with more generic VecGather/VecScatter Requires the creation of arrays of VecScatter objects: one for each state

Tips for Inhomogeneous Nets VecSetBlockSize no longer an option Can be reproduced with more generic VecGather/VecScatter Requires the creation of arrays of VecScatter objects: one for each state VecScatter created from two IS index objects: TO Vec and FROM Vec

Tips for Inhomogeneous Nets Different types: gathered on separate processors or mixed?

Tips for Inhomogeneous Nets Different types: gathered on separate processors or mixed? Gathered is easiest to implement: specify which processor, treat like the homogeneous case

Tips for Inhomogeneous Nets Different types: gathered on separate processors or mixed? Gathered is easiest to implement: specify which processor, treat like the homogeneous case Mixed is faster: balance processor load, potentially less message passing

Tips for Inhomogeneous Nets If there are ODEs for each connection, then the need for mixed distribution is greater

Tips for Inhomogeneous Nets If there are ODEs for each connection, then the need for mixed distribution is greater Ideally (if disparity in # eqns isn’t great):

Tips for Inhomogeneous Nets If there are ODEs for each connection, then the need for mixed distribution is greater Ideally (if disparity in # eqns isn’t great): Lump all cells together, RCM permute, equal # cells per processor

Tips for Adaptive Time Step

PETSc RK45 < ode45

Tips for Adaptive Time Step PETSc RK45 < ode45 Will not integrate across discontinuities

Tips for Adaptive Time Step PETSc RK45 < ode45 Will not integrate across discontinuities For discontinuities you know of (e.g. time dependent forcing function):

Tips for Adaptive Time Step PETSc RK45 < ode45 Will not integrate across discontinuities For discontinuities you know of (e.g. time dependent forcing function): Loop: TSSetDuration to discontinuity, TSStep