Debugging with the new GEOS-Chem Unit Tester

Size: px
Start display at page:

Download "Debugging with the new GEOS-Chem Unit Tester"

Transcription

1 Debugging with the new GEOS-Chem Unit Tester Bob Yantosca Senior Software Engineer GEOS-Chem Support Team Jacob Group Meeting 27 Nov 2013 with Melissa Payer Sulprizio

2 Contents Overview G-C software development Why benchmarking doesn't catch some bugs What is Unit Testing? GEOS-Chem Unit Tester Interactive demo!!! What types of bugs will it find? Avoiding bugs and numerical issues GEOS-Chem v9-02 status

3 G-C software development G-C is a model w/ an international user base Users are also developers Most updates are submitted by users G-C Support Team (GCST) manages development for the user community Version Control Benchmarking

4 G-C software development We use the Git version control system to keep track of several parallel lines of software development. Code updates made in one branch don t affect the other branches. Branches can later be merged back into the main line of development. Bob Y. IGC6 presentation But sometimes Git is a little too good! It will all grab of the source code updates from a user, even their bugs... Benchmark simulations to validate G-C output

5 G-C benchmark output 1-month and 1-year benchmarks See Budgets Concentrations, differences, ratios Frequency distribution histogram Emission ratios Aerosol scatter plots J-value ratios Seasonal profiles (vertical and surface)

6 G-C benchmark limitations G-C benchmarks are designed to reveal shortcomings in model science algorithms Is chemistry too hot? Do we have too much deposition? Is there a bias w/r/t observations?, etc. Bugs or numerical issues in the code may not always manifest themselves in the benchmarks Effects may be too small to show up on the plots But the code may be still doing something wrong!!!

7 Motivation to be bug-free Bugs waste time and time is $$$ Every minute we spend fixing bugs is a minute that we are not working on something else Bugs can damage our reputation Worst case scenario: Having to issue a retraction because that neat result we found was caused by a bug in the code.

8 Motivation to be bug-free The IGC6 software development discussion group recommended that we implement an automatic debugging scan for G-C. Goal: To remove bugs and numerical issues from the code before we submit benchmark simulations. Thus the G-C Unit Tester was born...

9 What is Unit Testing? Unit Tests are short simulations designed to reveal flaws in software. Unit Tests can be automated and run daily. Many software libraries that we use (ESMF, netcdf, HDF5, etc.) employ Unit Testing as part of their development.

10 Example: ESMF Unit Tests ESMF web site:

11 Example: netcdf unit tests NetCDF unit test site:

12 GEOS-Chem Unit Tester G-C Unit Tester is an external package Downloadable via Git git clone git://git.as.harvard.edu/bmy/geos-chem-unittest UT The Unit Tester package has several subdirs: perl: Contains scripts & input files runs: Contains GEOS-Chem run directories logs: where log file output will get sent jobs: where job files will be created doc: where documentation gets built

13 GEOS-Chem Unit Tester You can perform one or more G-C unit tests Each unit test validates a combination of met field + horizontal grid + simulation type geos5_2x25_co2 merra_4x5_hg geosfp_4x5_fullchem geos5_4x5_soa Etc.

14 Interactive demo! We will start a G-C Unit Test job! While the job runs, we'll examine what types of bugs the Unit Tester scans for.

15 An individual unit test For each combination of met + grid + sim: G-C is run with strict debugging options, twice: Once without OpenMP parallelization (aka sp ) Once with OpenMP parallelization (aka mp ) The debug options will catch common errors. Output files from sp and mp runs are checked. If not identical, there's a problem.

16 Debugging options Each unit test is designed to reveal: Floating-point math exceptions Array out-of-bounds errors Inefficient subroutine calls Parallelization errors Code optimization is disabled (-O0) Optimization can sometimes mask bugs This also facilitates use of a debugger (Totalview)

17 Floating-point math = 53 4-byte (32-bit), aka REAL*4 8-byte (64-bit), aka REAL*8 The bit is the basic computational unit. It represents an on-off switch (0 or 1). A group of 8 bits is called a byte. Each bit in the byte represents a power of 2. With one byte, you can represent values from Negative numbers are obtained by using one of the bits to represent the +/- sign. You have one less power of 2. Available values: -128 to 127. To represent higher numeric values, you string several bytes together.

18 Floating-point math REAL*4 (32-bit) number, IEEE 754 specification: 1 bit for the +/- sign 8 bits for the exponent 23 bits for the mantissa (fractional part) Range: -3.4 x to 3.4 x REAL*8 (64-bit) number, IEEE 754 specification: 1 bit for the +/- sign 11 bits for the exponent 53 bits for the mantissa (fractional part) Range: -1.8 x to 1.8 x

19 Floating-point math Denormal values -Infinity, +Infinity A value that is (smaller,larger) than the (min,max) value that can be represented in REAL*4 or REAL*8. e.g. Result of a division by zero NaN Not a number : Result of an illegal computation. SQRT( -1 ), LOG( 0 ), LOG( -1 ), etc.

20 Floating-point math Denormal values propagate thru code, e.g. Any value + NaN = NaN Any value - NaN = NaN Any value * NaN = NaN Any value / NaN = NaN Any value ** NaN = NaN etc. similarly for -Infinity, +Infinity

21 Example #1. Pretend somebody slipped this into G-C:! Force a div-by-zero error A = 1.0 B = 0.0 PRINT*, 'Result:', A/B If you didn't check for floating-point errors, you would see this: > Result: Infinity But the G-C Unit Tester (using floating-point error checking option FPE=yes) would stop the run w/ an error message: > forrtl: error (65): floating invalid Image PC Routine Line Source geos B1 Unknown Unknown Unknown geos C MAIN 12 main.f geos C Unknown Unknown geos libc.so B2A21A05 Unknown Unknown Unknown geos Unknown Unknown Unknown

22 Avoiding floating-point errors Make sure divisions are possible! Instead of this... C = A / B! Try this... IF ( ABS( B ) > 0.0 ) THEN C = A / B ELSE C = 0.0! Or some other value ENDIF! Or this... C = SAFE_DIV( A, B, 0.0 )

23 Avoiding floating-point errors Make sure you can take the LOG or SQRT! Instead of this... B = LOG( A ) C = SQRT( A )! Try this... IF ( A > 0.0 ) THEN B = LOG( A ) C = SQRT( A ) ENDIF

24 Array storage in Fortran The following Fortran code declares a 1-dimensional array:! Declare a REAL*4 array w/ 3 elements REAL*4 :: ARRAY(3)! Assign values ARRAY(1) = 1.0 ARRAY(2) = 2.0 ARRAY(3) = 3.0

25 Array storage in Fortran The following Fortran code declares a 1-dimensional array:! Declare a REAL*4 array w/ 3 elements REAL*4 :: ARRAY(3)! Assign values ARRAY(1) = 1.0 ARRAY(2) = 2.0 ARRAY(3) = 3.0 The array is stored into successive bytes in system memory. Recall that each element of ARRAY takes 4 bytes to store. ARRAY(1) ARRAY(2) ARRAY(3) In adjacent memory locations, other arrays or variables are stored. We usually won't know what values get put into a given memory location.

26 Array out-of-bounds error But what happens when we make an illegal array assignment?! Declare a REAL*4 array w/ 3 elements REAL*4 :: ARRAY(3)! Assign values ARRAY(1) = 1.0 ARRAY(2) = 2.0 ARRAY(3) = 3.0 ARRAY(4) = 4.0! This is outside of array bounds!

27 Array out-of-bounds error But what happens when we make an illegal array assignment?! Declare a REAL*4 array w/ 3 elements REAL*4 :: ARRAY(3)! Assign values ARRAY(1) = 1.0 ARRAY(2) = 2.0 ARRAY(3) = 3.0 ARRAY(4) = 4.0! This is outside of array bounds! ARRAY(4) gets placed into the system memory following ARRAY(3), but those bytes may already be occupied by another variable! ARRAY(1) ARRAY(2) ARRAY(3) ARRAY(4)? This clobbers whatever value was stored immediately following ARRAY!! A junk value then will propagate thru your code!

28 Array out-of-bounds error Example #2: Assume somebody slipped this into G-C: REAL*4 :: ARRAY(3) ARRAY(1) = 1.0 ARRAY(2) = 2.0 ARRAY(3) = 3.0 ARRAY(4) = 4.0! This is outside of array bounds! PRINT*, 'Result: ', ARRAY(1:4) Without checking for array out-of-bounds errors, you'd see this: > Result: You may not notice anything wrong at first, but the run may die later on. But the G-C Unit Tester (using the error checking option BOUNDS=yes) would stop the run w/ an error message: > main.f(12): error #5561: Subscript #1 of the array ARRAY has value 4 which is greater than the upper bound of 3 ARRAY(4) = 4.0

29 Avoiding out-of-bounds errors Make sure loop bounds are consistent with the declared size of arrays! Declare variables INTEGER :: N REAL*4 :: ARRAY(3)! Do the loop DO N = 1, 3 ARRAY(N) = N * 1.0 ENDDO The upper loop bound must be the same as the declared dimenison of ARRAY (both = 3).

30 Avoiding out-of-bounds errors Or, even better, use declared parameters for array dimensions:! Declare variables INTEGER :: N INTEGER, PARAMETER :: DIM = 3 REAL*4 :: ARRAY(DIM)! Do the loop! DO N = 1, DIM ARRAY(N) = N * 1.0 ENDDO If you change the value of DIM, it gets updated in all places where it is needed.

31 Efficient subroutine calls The calling routine (or program): System Memory USE CMN_SIZE_MOD, IIPAR, JJPAR, LLPAR REAL*4 :: ARRAY(IIPAR,JJPAR,LLPAR) ARRAY =! Some computation ARRAY (IIPAR x JJPAR x LLPAR) CALL MY_ROUTINE( ARRAY ) The routine that is called: SUBROUTINE MY_ROUTINE( ARRAY ) USE CMN_SIZE_MOD, IIPAR, JJPAR REAL*4, INTENT(INOUT) :: & ARRAY(IIPAR,JJPAR,LLPAR) ARRAY =! Some other computation END SUBROUTINE MY_ROUTINE Under most circumstances, the compiler will NOT have to make a duplicate copy of ARRAY. It will just tell the subroutine where it can find ARRAY in the system memory. This is called passing a pointer reference, which is very computationally efficient.

32 Inefficient subroutine calls The calling routine (or program): System Memory USE CMN_SIZE_MOD, IIPAR, JJPAR, LLPAR REAL*4, ARRAY(IIPAR,JJPAR,LLPAR) ARRAY =! Some computation ARRAY (IIPAR x JJPAR x LLPAR)! Pass a non-contiguous slice CALL MY_ROUTINE( ARRAY(:,1,:) ) The routine that is called:: SUBROUTINE MY_ROUTINE( ARRAY ) USE CMN_SIZE_MOD, IIPAR, LLPAR REAL*4, INTENT(INOUT) :: & ARRAY(IIPAR,LLPAR) ARRAY =! Some other computation END SUBROUTINE MY_ROUTINE Temporary copy of a sub-slice of ARRAY (IIPAR x LLPAR) If we try to pass a noncontiguous array slice to a subroutine, then the compiler has to create an ARRAY TEMPORARY (i.e. a duplicate copy). This can cause a performance bottleneck.

33 Finding inefficient subroutine calls Example #3: Assume somebody slipped this into G-C:! In the calling routine USE CMN_SIZE_MOD, IIPAR, JJPAR, LLPAR REAL*4, ARRAY(IIPAR,JJPAR,LLPAR) ARRAY = CALL MY_ROUTINE( ARRAY(:,1,:) )! In the called subroutine SUBROUTINE MY_ROUTINE( ARRAY ) USE CMN_SIZE_MOD, IIPAR, LLPAR REAL*4, INTENT(INOUT) :: ARRAY(IIPAR,LLPAR) ARRAY = END SUBROUTINE MY_ROUTINE But the G-C Unit Tester (using the error checking option DEBUG=yes (which sets -check arg_temp_created) prints: > forrtl: warning (402): fort: (1): In call to MY_ROUTINE, an array temporary was created for argument #1

34 Avoiding inefficient subroutine calls Pass entire arrays from calling routine to subroutine (and not array slices). Be aware of the types of arrays that you have in the calling routine and called subroutine Passing POINTER arrays can sometimes create array temporaries For more info, see: Passing array arguments efficiently in GEOS-Chem page on the G-C wiki

35 Parallelization with OpenMP Creating a parallel DO-loop:!$OMP PARALLEL DO!$OMP+DEFAULT( SHARED )!$OMP+PRIVATE( I, J, P ) DO J = 1, JJPAR DO I = 1, IIPAR P = A(I,J) * 2.0 B(I,J) = P ENDDO ENDDO!$OMP END PARALLEL DO Each CPU will get its own personal copy of the I, J, and P variables. The A and B arrays have the same scope as the loop (I,J) and thus don't have to be held PRIVATE. I,J,P I,J,P I,J,P I,J,P

36 Parallelization with OpenMP But what if we forget to declare the P variable as PRIVATE?!$OMP PARALLEL DO!$OMP+DEFAULT( SHARED )!$OMP+PRIVATE( I, J ) DO J = 1, JJPAR DO I = 1, IIPAR P = A(I,J) * 2.0 B(I,J) = P ENDDO ENDDO!$OMP END PARALLEL DO I,J I,J I,J I,J Each CPU gets its own copy of I and J, but not P. P gets overwritten by all CPUs simultaneously. This introduces numerical errors into the result.

37 Detecting parallelization errors Example #4: Assume somebody slipped this into G-C:!$OMP PARALLEL DO!$OMP+DEFAULT( SHARED )!$OMP+PRIVATE( I, J ) DO J = 1, JJPAR DO I = 1, IIPAR P = A(I,J) * 2.0 B(I,J) = P ENDDO ENDDO!$OMP END PARALLEL DO But the G-C Unit Tester compares the output of the sp and mp runs. If they are not identical, there is an parallelization error: ### File 1 : trac_avg.geosfp_4x5_fullchem sp ### File 2 : trac_avg.geosfp_4x5_fullchem mp ### Sizes : IDENTICAL ( and ) ### Checksums : DIFFERENT ( and ) ### Diffs : DIFFERENT

38 Avoiding parallelization errors Know what you have to declare PRIVATE within an OpenMP parallel loop See the guidelines posted on the GEOS-Chem wiki page: Parallelizing GEOS-Chem

39 G-C Unit Tester: Wrapup We now have an automatic way to detect common G-C bugs! Since v9-02o, we have caught approximately 20 bugs w/ the G-C Unit Tester. G-C Unit Tester is now being used in conjunction w/ the 1-month and 1-year benchmark simulations.

40 GEOS-Chem v9-02 status v9-02 is in the benchmarking phase Major updates GEOS-FP met (we are examining benchmarks) Merging isoprene species into std mechanism Removal of NOx-Ox partitioning Updated SOA simulation Emissions updates Merging updates from GIGC development

41 GEOS-Chem v9-02 status v9-02 is more efficient than v

42 GEOS-Chem v9-02 status Public release soon Public comment period to allow user to report any further issues. Next version will probably be named v10-01 Updates for consideration (G-C Steering Cmte) UCX strat chem Harvard Emissions component (HEMCO) FlexChem Etc.

43 Thanks and Happy Thanksgiving!

Unit Testing, Difference Testing, Profiling, and Musings on Software Engineering

Unit Testing, Difference Testing, Profiling, and Musings on Software Engineering Unit Testing, Difference Testing, Profiling, and Musings on Software Engineering Bob Yantosca Senior Software Engineer Jacob Group Meeting 06 August 2014 Contents Unit testing, revisited Update since Nov

More information

The Art of Debugging: How to think like a programmer. Melissa Sulprizio GEOS-Chem Support Team

The Art of Debugging: How to think like a programmer. Melissa Sulprizio GEOS-Chem Support Team The Art of Debugging: How to think like a programmer Melissa Sulprizio GEOS-Chem Support Team geos-chem-support@as.harvard.edu Graduate Student Forum 23 February 2017 GEOS-Chem Support Team Bob Yantosca

More information

Getting Started with GCHP v11-02c

Getting Started with GCHP v11-02c Getting Started with GCHP v11-02c Lizzie Lundgren GEOS-Chem Support Team geos-chem-support@as.harvard.edu September 2017 Overview 1) What is GCHP and why use it? 2) Common Misconceptions 3) Useful Tips

More information

Important new structural developments in GEOS-Chem v11

Important new structural developments in GEOS-Chem v11 Important new structural developments in GEOS-Chem v11 Bob Yantosca Senior Software Engineer GEOS-Chem Support Team Jacob Group Meeting 10 Aug 2016 with: Melissa, Matt, Lizzie, Mike Table of Contents Motivation

More information

Getting Started with High Performance GEOS-Chem

Getting Started with High Performance GEOS-Chem Getting Started with High Performance GEOS-Chem Lizzie Lundgren GEOS-Chem Support Team geos-chem-support@as.harvard.edu June 2017 Overview 1) What is GCHP and why use it? 2) Common Misconceptions 3) Useful

More information

GEOS-Chem Model IGC8

GEOS-Chem Model IGC8 GEOS-Chem Model Clinic @ IGC8 Part 2: Advanced Topics GEOS-Chem Unit Tester HEMCO / Emissions FlexChem / KPP chemistry solver GEOS-Chem Species Database GEOS-Chem Support Team 01 May 2017 Note This presentation

More information

APPENDIX B. Fortran Hints

APPENDIX B. Fortran Hints APPENDIX B Fortran Hints This appix contains hints on how to find errors in your programs, and how to avoid some common Fortran errors in the first place. The basics on how to invoke the Fortran compiler

More information

Problems and Solutions to the January 1994 Core Examination

Problems and Solutions to the January 1994 Core Examination Problems and Solutions to the January 1994 Core Examination Programming Languages PL 1. Consider the following program written in an Algol-like language: begin integer i,j; integer array A[0..10]; Procedure

More information

MPI in ROMS. Kate Hedstrom Dan Schaffer, NOAA Tom Henderson, NOAA January 2011

MPI in ROMS. Kate Hedstrom Dan Schaffer, NOAA Tom Henderson, NOAA January 2011 1 MPI in ROMS Kate Hedstrom Dan Schaffer, NOAA Tom Henderson, NOAA January 2011 2 Outline Introduction to parallel computing ROMS grids Domain decomposition Picky details Debugging story 3 Parallel Processing

More information

IEEE Floating Point Numbers Overview

IEEE Floating Point Numbers Overview COMP 40: Machine Structure and Assembly Language Programming (Fall 2015) IEEE Floating Point Numbers Overview Noah Mendelsohn Tufts University Email: noah@cs.tufts.edu Web: http://www.cs.tufts.edu/~noah

More information

The Perl Debugger. Avoiding Bugs with Warnings and Strict. Daniel Allen. Abstract

The Perl Debugger. Avoiding Bugs with Warnings and Strict. Daniel Allen. Abstract 1 of 8 6/18/2006 7:36 PM The Perl Debugger Daniel Allen Abstract Sticking in extra print statements is one way to debug your Perl code, but a full-featured debugger can give you more information. Debugging

More information

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n)

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n) Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Module 10A Lecture - 20 What is a function?

More information

15 Answers to Frequently-

15 Answers to Frequently- 15 Answers to Frequently- Asked Questions In this chapter, we provide answers to some commonly asked questions about ARPS. Most of the questions are collected from the users. We will continue to collect

More information

Bindel, Fall 2011 Applications of Parallel Computers (CS 5220) Tuning on a single core

Bindel, Fall 2011 Applications of Parallel Computers (CS 5220) Tuning on a single core Tuning on a single core 1 From models to practice In lecture 2, we discussed features such as instruction-level parallelism and cache hierarchies that we need to understand in order to have a reasonable

More information

Memory. From Chapter 3 of High Performance Computing. c R. Leduc

Memory. From Chapter 3 of High Performance Computing. c R. Leduc Memory From Chapter 3 of High Performance Computing c 2002-2004 R. Leduc Memory Even if CPU is infinitely fast, still need to read/write data to memory. Speed of memory increasing much slower than processor

More information

NAN propagation versus fault trapping in floating point code

NAN propagation versus fault trapping in floating point code NAN propagation versus fault trapping in floating point code By Agner Fog. Technical University of Denmark. Copyright 2018. Last updated 2018-05-24. Contents 1 Introduction... 1 2 Fault trapping... 1 3

More information

Floating Point. What can be represented in N bits? 0 to 2N-1. 9,349,398,989,787,762,244,859,087, x 1067

Floating Point. What can be represented in N bits? 0 to 2N-1. 9,349,398,989,787,762,244,859,087, x 1067 MIPS Floating Point Operations Cptr280 Dr Curtis Nelson Floating Point What can be represented in N bits? Unsigned 2 s Complement 0 to 2N-1-2N-1 to 2N-1-1 But, what about- Very large numbers? 9,349,398,989,787,762,244,859,087,678

More information

Review Functions Subroutines Flow Control Summary

Review Functions Subroutines Flow Control Summary OUTLINE 1 REVIEW 2 FUNCTIONS Why use functions How do they work 3 SUBROUTINES Why use subroutines? How do they work 4 FLOW CONTROL Logical Control Looping 5 SUMMARY OUTLINE 1 REVIEW 2 FUNCTIONS Why use

More information

Optimising for the p690 memory system

Optimising for the p690 memory system Optimising for the p690 memory Introduction As with all performance optimisation it is important to understand what is limiting the performance of a code. The Power4 is a very powerful micro-processor

More information

Numerical computing. How computers store real numbers and the problems that result

Numerical computing. How computers store real numbers and the problems that result Numerical computing How computers store real numbers and the problems that result The scientific method Theory: Mathematical equations provide a description or model Experiment Inference from data Test

More information

Fixed-Point Math and Other Optimizations

Fixed-Point Math and Other Optimizations Fixed-Point Math and Other Optimizations Embedded Systems 8-1 Fixed Point Math Why and How Floating point is too slow and integers truncate the data Floating point subroutines: slower than native, overhead

More information

AMath 483/583 Lecture 8

AMath 483/583 Lecture 8 AMath 483/583 Lecture 8 This lecture: Fortran subroutines and functions Arrays Dynamic memory Reading: class notes: Fortran Arrays class notes: Fortran Subroutines and Functions class notes: gfortran flags

More information

Digital Design and Computer Architecture Harris and Harris, J. Spjut Elsevier, 2007

Digital Design and Computer Architecture Harris and Harris, J. Spjut Elsevier, 2007 Digital Design and Computer Architecture Harris and Harris, J. Spjut Elsevier, 2007 Lab 8: MIPS ARM Assembly Language Programming Introduction In this lab, you will learn to write ARM assembly language

More information

IEEE Standard 754 Floating Point Numbers

IEEE Standard 754 Floating Point Numbers IEEE Standard 754 Floating Point Numbers Steve Hollasch / Last update 2005-Feb-24 IEEE Standard 754 floating point is the most common representation today for real numbers on computers, including Intel-based

More information

Error Code. GO Software Pty Limited Map: 27 Tacoma Blvd, Pasadena SA 5042 ABN: ACN:

Error Code. GO Software Pty Limited Map: 27 Tacoma Blvd, Pasadena SA 5042 ABN: ACN: GO Software Pty Limited Map: 27 Tacoma Blvd, Pasadena SA 5042 Phn: 0403-063-991 Fax: none ABN: 54-008-044-906 ACN: 008-044-906 Eml: support@gosoftware.com.au Web: www.gosoftware.com.au Error Code GW-Basic

More information

Exceptions! Users can t live with em Programmers can t live without em. i want stress-free IT. i want control. i want an i IBM Corporation

Exceptions! Users can t live with em Programmers can t live without em. i want stress-free IT. i want control. i want an i IBM Corporation Exceptions! Users can t live with em Programmers can t live without em Barbara Morris IBM i want stress-free IT. i want control. Agenda Why exceptions are good for you (yes, they are) Exception handling

More information

Professor Terje Haukaas University of British Columbia, Vancouver C++ Programming

Professor Terje Haukaas University of British Columbia, Vancouver  C++ Programming C++ Programming C++ code is essentially a collection of statements terminated by a semicolon, such as (spaces not needed): a = b + c; Most C++ code is organized into header files and cpp files, i.e., C++

More information

Project 3: RPN Calculator

Project 3: RPN Calculator ECE267 @ UIC, Spring 2012, Wenjing Rao Project 3: RPN Calculator What to do: Ask the user to input a string of expression in RPN form (+ - * / ), use a stack to evaluate the result and display the result

More information

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 5 2/22/2018

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 5 2/22/2018 ECE 331 Hardware Organization and Design Professor Jay Taneja UMass ECE - jtaneja@umass.edu Discussion 5 2/22/2018 Today s Discussion Topics Program Concepts Floating Point Floating Point Conversion Floating

More information

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8 Data Representation At its most basic level, all digital information must reduce to 0s and 1s, which can be discussed as binary, octal, or hex data. There s no practical limit on how it can be interpreted

More information

Scripting Languages. Diana Trandabăț

Scripting Languages. Diana Trandabăț Scripting Languages Diana Trandabăț Master in Computational Linguistics - 1 st year 2017-2018 Today s lecture What is Perl? How to install Perl? How to write Perl progams? How to run a Perl program? perl

More information

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill 12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring Chris Hill Review of Lecture 5 Looked at Fortran commands in more detail Control through if and do statements. Logical

More information

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right. Floating-point Arithmetic Reading: pp. 312-328 Floating-Point Representation Non-scientific floating point numbers: A non-integer can be represented as: 2 4 2 3 2 2 2 1 2 0.2-1 2-2 2-3 2-4 where you sum

More information

Hands-on Workshop on How To Debug Codes at the Institute

Hands-on Workshop on How To Debug Codes at the Institute Hands-on Workshop on How To Debug Codes at the Institute H. Birali Runesha, Shuxia Zhang and Ben Lynch (612) 626 0802 (help) help@msi.umn.edu October 13, 2005 Outline Debuggers at the Institute Totalview

More information

Outline. MPI in ROMS ROMS. Sample Grid. ROMS and its grids Domain decomposition Picky details Debugging story

Outline. MPI in ROMS ROMS. Sample Grid. ROMS and its grids Domain decomposition Picky details Debugging story 1 2 Outline MPI in ROMS Kate Hedstrom Dan Schaffer, NOAA Tom Henderson, NOAA November 2012 ROMS and its grids Domain decomposition Picky details Debugging story 3 4 ROMS Regional Ocean Modeling System

More information

Floating Point Numbers

Floating Point Numbers Floating Point Numbers Summer 8 Fractional numbers Fractional numbers fixed point Floating point numbers the IEEE 7 floating point standard Floating point operations Rounding modes CMPE Summer 8 Slides

More information

Skill 1: Multiplying Polynomials

Skill 1: Multiplying Polynomials CS103 Spring 2018 Mathematical Prerequisites Although CS103 is primarily a math class, this course does not require any higher math as a prerequisite. The most advanced level of mathematics you'll need

More information

EXAMINING THE CODE. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist:

EXAMINING THE CODE. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist: EXAMINING THE CODE CONTENTS I. Static White Box Testing II. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist: Dynamic White Box Testing

More information

Floating Point Numbers. Lecture 9 CAP

Floating Point Numbers. Lecture 9 CAP Floating Point Numbers Lecture 9 CAP 3103 06-16-2014 Review of Numbers Computers are made to deal with numbers What can we represent in N bits? 2 N things, and no more! They could be Unsigned integers:

More information

COS 140: Foundations of Computer Science

COS 140: Foundations of Computer Science COS 140: Foundations of Computer Science Variables and Primitive Data Types Fall 2017 Introduction 3 What is a variable?......................................................... 3 Variable attributes..........................................................

More information

COS 140: Foundations of Computer Science

COS 140: Foundations of Computer Science COS 140: Foundations of Variables and Primitive Data Types Fall 2017 Copyright c 2002 2017 UMaine School of Computing and Information S 1 / 29 Homework Reading: Chapter 16 Homework: Exercises at end of

More information

Matrix Multiplication

Matrix Multiplication Matrix Multiplication CPS343 Parallel and High Performance Computing Spring 2013 CPS343 (Parallel and HPC) Matrix Multiplication Spring 2013 1 / 32 Outline 1 Matrix operations Importance Dense and sparse

More information

HPCC - Hrothgar. Getting Started User Guide TotalView. High Performance Computing Center Texas Tech University

HPCC - Hrothgar. Getting Started User Guide TotalView. High Performance Computing Center Texas Tech University HPCC - Hrothgar Getting Started User Guide TotalView High Performance Computing Center Texas Tech University HPCC - Hrothgar 2 Table of Contents *This user guide is under development... 3 1. Introduction...

More information

ECE 353 Lab 3. (A) To gain further practice in writing C programs, this time of a more advanced nature than seen before.

ECE 353 Lab 3. (A) To gain further practice in writing C programs, this time of a more advanced nature than seen before. ECE 353 Lab 3 Motivation: The purpose of this lab is threefold: (A) To gain further practice in writing C programs, this time of a more advanced nature than seen before. (B) To reinforce what you learned

More information

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3 Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Instructor: Nicole Hynes nicole.hynes@rutgers.edu 1 Fixed Point Numbers Fixed point number: integer part

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 11: Floating Point & Floating Point Addition Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Last time: Single Precision Format

More information

Programming Assignments

Programming Assignments ELEC 486/586, Summer 2017 1 Programming Assignments 1 General Information 1.1 Software Requirements Detailed specifications are typically provided for the software to be developed for each assignment problem.

More information

AMath 483/583 Lecture 2

AMath 483/583 Lecture 2 AMath 483/583 Lecture 2 Outline: Binary storage, floating point numbers Version control main ideas Client-server version control, e.g., CVS, Subversion Distributed version control, e.g., git, Mercurial

More information

3.5 Floating Point: Overview

3.5 Floating Point: Overview 3.5 Floating Point: Overview Floating point (FP) numbers Scientific notation Decimal scientific notation Binary scientific notation IEEE 754 FP Standard Floating point representation inside a computer

More information

AMath 483/583 Lecture 2. Notes: Notes: Homework #1. Class Virtual Machine. Notes: Outline:

AMath 483/583 Lecture 2. Notes: Notes: Homework #1. Class Virtual Machine. Notes: Outline: AMath 483/583 Lecture 2 Outline: Binary storage, floating point numbers Version control main ideas Client-server version control, e.g., CVS, Subversion Distributed version control, e.g., git, Mercurial

More information

Matrix Multiplication

Matrix Multiplication Matrix Multiplication CPS343 Parallel and High Performance Computing Spring 2018 CPS343 (Parallel and HPC) Matrix Multiplication Spring 2018 1 / 32 Outline 1 Matrix operations Importance Dense and sparse

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS CST.2000.1.1 COMPUTER SCIENCE TRIPOS Part IA Monday 5 June 2000 1.30 to 4.30 Paper 1 Answer two questions from Section A, and one question from each of Sections B, C, D and E. Submit the answers in six

More information

AHHHHHHH!!!! NOT TESTING! Anything but testing! Beat me, whip me, send me to Detroit, but don t make me write tests!

AHHHHHHH!!!! NOT TESTING! Anything but testing! Beat me, whip me, send me to Detroit, but don t make me write tests! NAME DESCRIPTION Test::Tutorial - A tutorial about writing really basic tests AHHHHHHH!!!! NOT TESTING! Anything but testing! Beat me, whip me, send me to Detroit, but don t make me write tests! *sob*

More information

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill 12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring Chris Hill Review of Lecture 2 Examined computer hardware Computer basics and the main features of programs Program design:

More information

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example Appendix F Number Systems Binary Numbers Decimal notation represents numbers as powers of 10, for example 1729 1 103 7 102 2 101 9 100 decimal = + + + There is no particular reason for the choice of 10,

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic Clark N. Taylor Department of Electrical and Computer Engineering Brigham Young University clark.taylor@byu.edu 1 Introduction Numerical operations are something at which digital

More information

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point. CSE 351 Autumn Instructor: Justin Hsia Floating Point CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan Administrivia Lab

More information

New coding practices for LSDALTON

New coding practices for LSDALTON New coding practices for LSDALTON Simen Reine Centre for Theoretical and Computational Chemistry (CTCC), Department of Chemistry, University of Oslo, Norway November 20th, 2015 Simen Reine (CTCC, University

More information

CS 390 Software Engineering Lecture 3 Configuration Management

CS 390 Software Engineering Lecture 3 Configuration Management CS 390 Software Engineering Lecture 3 Configuration Management Includes slides from the companion website for Sommerville, Software Engineering, 10/e. Pearson Higher Education, 2016. All rights reserved.

More information

8/30/2016. In Binary, We Have A Binary Point. ECE 120: Introduction to Computing. Fixed-Point Representations Support Fractions

8/30/2016. In Binary, We Have A Binary Point. ECE 120: Introduction to Computing. Fixed-Point Representations Support Fractions University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Fixed- and Floating-Point Representations In Binary, We Have A Binary Point Let

More information

Jim Lambers ENERGY 211 / CME 211 Autumn Quarter Programming Project 4

Jim Lambers ENERGY 211 / CME 211 Autumn Quarter Programming Project 4 Jim Lambers ENERGY 211 / CME 211 Autumn Quarter 2008-09 Programming Project 4 This project is due at 11:59pm on Friday, October 31. 1 Introduction In this project, you will do the following: 1. Implement

More information

Can Accelerators Really Accelerate Harmonie?

Can Accelerators Really Accelerate Harmonie? Can Accelerators Really Accelerate Harmonie? Enda O Brien, Adam Ralph Irish Centre for High-End Computing Motivation There is constant demand for more performance Conventional compute cores not getting

More information

Programming with Haiku

Programming with Haiku Programming with Haiku Lesson 4 Written by DarkWyrm All material 2010 DarkWyrm Source Control: What is It? In my early days as a developer on the Haiku project I had troubles on occasion because I had

More information

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI. CSCI 402: Computer Architectures Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI 3.5 Today s Contents Floating point numbers: 2.5, 10.1, 100.2, etc.. How

More information

Programming Studio #9 ECE 190

Programming Studio #9 ECE 190 Programming Studio #9 ECE 190 Programming Studio #9 Concepts: Functions review 2D Arrays GDB Announcements EXAM 3 CONFLICT REQUESTS, ON COMPASS, DUE THIS MONDAY 5PM. NO EXTENSIONS, NO EXCEPTIONS. Functions

More information

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University Computer Architecture Chapter 3 Fall 2005 Department of Computer Science Kent State University Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point

More information

At the end of this module, the student should be able to:

At the end of this module, the student should be able to: INTRODUCTION One feature of the C language which can t be found in some other languages is the ability to manipulate pointers. Simply stated, pointers are variables that store memory addresses. This is

More information

7. Compiling and Debugging Parallel Fortran

7. Compiling and Debugging Parallel Fortran Chapter 7 7. Compiling and Debugging Parallel Fortran This chapter gives instructions on how to compile and debug a parallel Fortran program and contains the following sections: Compiling and Running explains

More information

without too much work Yozo Hida April 28, 2008

without too much work Yozo Hida April 28, 2008 Yozo Hida without too much Work 1/ 24 without too much work Yozo Hida yozo@cs.berkeley.edu Computer Science Division EECS Department U.C. Berkeley April 28, 2008 Yozo Hida without too much Work 2/ 24 Outline

More information

SGI Altix Getting Correct Code Reiner Vogelsang SGI GmbH

SGI Altix Getting Correct Code Reiner Vogelsang SGI GmbH SGI Altix Getting Correct Code Reiner Vogelsang SGI GmbH reiner@sgi.com Module Objectives After completing the module, you will able to Find caveats and hidden errors in application codes Handle debuggers

More information

Why C? Because we can t in good conscience espouse Fortran.

Why C? Because we can t in good conscience espouse Fortran. C Tutorial Why C? Because we can t in good conscience espouse Fortran. C Hello World Code: Output: C For Loop Code: Output: C Functions Code: Output: Unlike Fortran, there is no distinction in C between

More information

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

Compiling and Interpreting Programming. Overview of Compilers and Interpreters Copyright R.A. van Engelen, FSU Department of Computer Science, 2000 Overview of Compilers and Interpreters Common compiler and interpreter configurations Virtual machines Integrated programming environments

More information

EPSRC Vision Summer School Vision Algorithmics

EPSRC Vision Summer School Vision Algorithmics EPSRC Vision Summer School Vision Algorithmics Adrian F. Clark alien@essex.ac.uk VASE Laboratory, Comp Sci & Elec Eng University of Essex Introduction Roughly 50% of your PhD time will be spent on practical

More information

CS354 gdb Tutorial Written by Chris Feilbach

CS354 gdb Tutorial Written by Chris Feilbach CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that

More information

CSCI-1200 Data Structures Spring 2016 Lecture 6 Pointers & Dynamic Memory

CSCI-1200 Data Structures Spring 2016 Lecture 6 Pointers & Dynamic Memory Announcements CSCI-1200 Data Structures Spring 2016 Lecture 6 Pointers & Dynamic Memory There will be no lecture on Tuesday, Feb. 16. Prof. Thompson s office hours are canceled for Monday, Feb. 15. Prof.

More information

Interfacing With Other Programming Languages Using Cython

Interfacing With Other Programming Languages Using Cython Lab 19 Interfacing With Other Programming Languages Using Cython Lab Objective: Learn to interface with object files using Cython. This lab should be worked through on a machine that has already been configured

More information

Written Homework 3. Floating-Point Example (1/2)

Written Homework 3. Floating-Point Example (1/2) Written Homework 3 Assigned on Tuesday, Feb 19 Due Time: 11:59pm, Feb 26 on Tuesday Problems: 3.22, 3.23, 3.24, 3.41, 3.43 Note: You have 1 week to work on homework 3. 3 Floating-Point Example (1/2) Q:

More information

2015 HSC Software Design and Development Marking Guidelines

2015 HSC Software Design and Development Marking Guidelines 2015 HSC Software Design and Development Marking Guidelines Section I Multiple-choice Answer Key Question Answer 1 C 2 A 3 B 4 D 5 B 6 C 7 B 8 C 9 C 10 A 11 B 12 D 13 A 14 A 15 C 16 D 17 B 18 D 19 B 20

More information

CS 61C: Great Ideas in Computer Architecture Performance and Floating-Point Arithmetic

CS 61C: Great Ideas in Computer Architecture Performance and Floating-Point Arithmetic CS 61C: Great Ideas in Computer Architecture Performance and Floating-Point Arithmetic Instructors: Nick Weaver & John Wawrzynek http://inst.eecs.berkeley.edu/~cs61c/sp18 3/16/18 Spring 2018 Lecture #17

More information

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation Course Schedule CS 221 Computer Architecture Week 3: Information Representation (2) Fall 2001 W1 Sep 11- Sep 14 Introduction W2 Sep 18- Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25- Sep

More information

IRIX is moving in the n32 direction, and n32 is now the default, but the toolchain still supports o32. When we started supporting native mode o32 was

IRIX is moving in the n32 direction, and n32 is now the default, but the toolchain still supports o32. When we started supporting native mode o32 was Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2002 Handout 23 Running Under IRIX Thursday, October 3 IRIX sucks. This handout describes what

More information

Project Data: Manipulating Bits

Project Data: Manipulating Bits CSCI0330 Intro Computer Systems Doeppner Project Data: Manipulating Bits Due: September 26, 2018 at 11:59pm 1 Introduction 1 2 Assignment 1 2.1 Collaboration 3 2.2 TA Hours 3 3 The Puzzles 3 3.1 Bit Manipulations

More information

The Perils of Floating Point

The Perils of Floating Point The Perils of Floating Point by Bruce M. Bush Copyright (c) 1996 Lahey Computer Systems, Inc. Permission to copy is granted with acknowledgement of the source. Many great engineering and scientific advances

More information

DelphiScript Keywords

DelphiScript Keywords DelphiScript Keywords Old Content - visit altium.com/documentation Modified by on 13-Sep-2017 This reference covers the DelphiScript keywords used for the Scripting System in Altium Designer. The scripting

More information

VBA Handout. References, tutorials, books. Code basics. Conditional statements. Dim myvar As <Type >

VBA Handout. References, tutorials, books. Code basics. Conditional statements. Dim myvar As <Type > VBA Handout References, tutorials, books Excel and VBA tutorials Excel VBA Made Easy (Book) Excel 2013 Power Programming with VBA (online library reference) VBA for Modelers (Book on Amazon) Code basics

More information

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That 1. Introduction You have seen situations in which the way numbers are stored in a computer affects a program. For example, in the

More information

September, 2003 Saeid Nooshabadi

September, 2003 Saeid Nooshabadi COMP3211 lec21-fp-iii.1 COMP 3221 Microprocessors and Embedded Systems Lectures 21 : Floating Point Number Representation III http://www.cse.unsw.edu.au/~cs3221 September, 2003 Saeid@unsw.edu.au Overview

More information

Introduction to Astronomical Computing with IDL

Introduction to Astronomical Computing with IDL Introduction to Astronomical Computing with IDL Version updated 25 August 2016 by G. Chartas. Adapted from versions by J. Carson and J. Neff. Exercise #1 Getting Started With IDL This is an exercise to

More information

The Design Process. General Development Issues. C/C++ and OO Rules of Thumb. Home

The Design Process. General Development Issues. C/C++ and OO Rules of Thumb. Home A l l e n I. H o l u b & A s s o c i a t e s Home C/C++ and OO Rules of Thumb The following list is essentially the table of contents for my book Enough Rope to Shoot Yourself in the Foot (McGraw-Hill,

More information

Floating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.

Floating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers. class04.ppt 15-213 The course that gives CMU its Zip! Topics Floating Point Jan 22, 2004 IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Floating Point Puzzles For

More information

Post Experiment Interview Questions

Post Experiment Interview Questions Post Experiment Interview Questions Questions about the Maximum Problem 1. What is this problem statement asking? 2. What is meant by positive integers? 3. What does it mean by the user entering valid

More information

CS367 Test 1 Review Guide

CS367 Test 1 Review Guide CS367 Test 1 Review Guide This guide tries to revisit what topics we've covered, and also to briefly suggest/hint at types of questions that might show up on the test. Anything on slides, assigned reading,

More information

CS 220: Introduction to Parallel Computing. Input/Output. Lecture 7

CS 220: Introduction to Parallel Computing. Input/Output. Lecture 7 CS 220: Introduction to Parallel Computing Input/Output Lecture 7 Input/Output Most useful programs will provide some type of input or output Thus far, we ve prompted the user to enter their input directly

More information

Compiler Options. Linux/x86 Performance Practical,

Compiler Options. Linux/x86 Performance Practical, Center for Information Services and High Performance Computing (ZIH) Compiler Options Linux/x86 Performance Practical, 17.06.2009 Zellescher Weg 12 Willers-Bau A106 Tel. +49 351-463 - 31945 Ulf Markwardt

More information

DDMD AND AUTOMATED CONVERSION FROM C++ TO D

DDMD AND AUTOMATED CONVERSION FROM C++ TO D 1 DDMD AND AUTOMATED CONVERSION FROM C++ TO D Daniel Murphy (aka yebblies ) ABOUT ME Using D since 2009 Compiler contributor since 2011 2 OVERVIEW Why convert the frontend to D What s so hard about it

More information

CMPSCI 201 Fall 2005 Midterm #2 Solution

CMPSCI 201 Fall 2005 Midterm #2 Solution CMPSCI 201 Fall 2005 Midterm #2 Solution Professor William T. Verts 10 Points Convert the decimal number -47.375 into (a) binary scientific notation (i.e., ±1.xxxx 2 Y ), and (b) the equivalent binary

More information

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic 1 EE 109 Unit 19 IEEE 754 Floating Point Representation Floating Point Arithmetic 2 Floating Point Used to represent very small numbers (fractions) and very large numbers Avogadro s Number: +6.0247 * 10

More information

Department of Computer Science COMP The Programming Competency Test

Department of Computer Science COMP The Programming Competency Test The Australian National University Faculty of Engineering & Information Technology Department of Computer Science COMP1120-2003-01 The Programming Competency Test 1 Introduction The purpose of COMP1120

More information

C++ PROGRAMMING LANGUAGE: DYNAMIC MEMORY ALLOCATION AND EXCEPTION IN C++. CAAM 519, CHAPTER 15

C++ PROGRAMMING LANGUAGE: DYNAMIC MEMORY ALLOCATION AND EXCEPTION IN C++. CAAM 519, CHAPTER 15 C++ PROGRAMMING LANGUAGE: DYNAMIC MEMORY ALLOCATION AND EXCEPTION IN C++. CAAM 519, CHAPTER 15 This chapter introduces the notion of dynamic memory allocation of variables and objects in a C++ program.

More information