1 Serial Run-time Error Detection and the Fortran Standard Glenn Luecke Professor of Mathematics, and Director, High Performance Computing Group Iowa State.

Slides:



Advertisements
Similar presentations
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Advertisements

Programming Paradigms and languages
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Names and Bindings.
Programming Types of Testing.
Chapter 7:: Data Types Programming Language Pragmatics
Various languages….  Could affect performance  Could affect reliability  Could affect language choice.
Kernighan/Ritchie: Kelley/Pohl:
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming;
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
Application of Fortran 90 to ocean model codes Mark Hadfield National Institute of Water and Atmospheric Research New Zealand.
FORTRAN Short Course Week 2 Kate Thayer-Calder February 23, 2009.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
ISBN Chapter 5 Names, Bindings, Type Checking, and Scopes Names Variables The Concept of Binding Type Checking Strong Typing Type Compatibility.
Fortran 9x HTML version. New F90 features Free source form Modules User-defined data types and operators Generic user-defined procedures Interface blocks.
Chapter 8. 2 Objectives You should be able to describe: One-Dimensional Arrays Array Initialization Arrays as Arguments Two-Dimensional Arrays Common.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Examining the Code [Reading assignment: Chapter 6, pp ]
C Programming Lecture 14 Arrays. What is an Array? b An array is a sequence of data items that are: all of the same typeall of the same type –a sequence.
Fortran- Subprograms Chapters 6, 7 in your Fortran book.
Python quick start guide
Language Evaluation Criteria
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 l Array Basics l Arrays in Classes and Methods l Programming with Arrays.
CENG 311 Machine Representation/Numbers
Fortran: Specification Statements Session Six ICoCSIS.
Introduction to FORTRAN
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
Slides Prepared from the CI-Tutor Courses at NCSA By S. Masoud Sadjadi School of Computing and Information Sciences Florida.
COP4020 Programming Languages
Multi-Dimensional Arrays
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Names Variables Type Checking Strong Typing Type Compatibility 1.
5-1 Chapter 5: Names, Bindings, Type Checking, and Scopes Variables The Concept of Binding Type Checking Strong Typing Type Compatibility Scope and Lifetime.
Support for Debugging Automatically Parallelized Programs Robert Hood Gabriele Jost CSC/MRJ Technology Solutions NASA.
Compiler Construction
Computer Science Detecting Memory Access Errors via Illegal Write Monitoring Ongoing Research by Emre Can Sezer.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Java Script: Arrays (Chapter 11 in [2]). 2 Outline Introduction Introduction Arrays Arrays Declaring and Allocating Arrays Declaring and Allocating Arrays.
Module and Data Sharing. Programming in the Large Software, in general, is large having multiple units Multiple units designed and developed independently.
C# Language Panithan Chandrapatya Agenda C# History C# Goals C# Fixes C# Contribution C# Features C# Success C# Example.
Some Fortran programming tips ATM 562 Fall 2015 Fovell (see also PDF file on class page) 1.
Introduction to Programming
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: One-Dimensional Arrays Array Initialization Arrays.
Structure of Programming Languages Names, Bindings, Type Checking, and Scopes.
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
Pointers. Variable Declarations Declarations served dual purpose –Specification of range of values and operations –Specification of Storage requirement.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
1 Structure of Compilers Lexical Analyzer (scanner) Modified Source Program Parser Tokens Semantic Analysis Syntactic Structure Optimizer Code Generator.
CS 330 Programming Languages 10 / 23 / 2007 Instructor: Michael Eckmann.
1 Recall that... char str [ 8 ]; str is the base address of the array. We say str is a pointer because its value is an address. It is a pointer constant.
Announcements You will receive your scores back for Assignment 2 this week. You will have an opportunity to correct your code and resubmit it for partial.
Names, Scope, and Bindings Programming Languages and Paradigms.
CPE779: Shared Memory and OpenMP Based on slides by Laxmikant V. Kale and David Padua of the University of Illinois.
Euphoria Programming Language CSC 507 Kasilingam Vimalan.
Windows Programming Lecture 06. Data Types Classification Data types are classified in two categories that is, – those data types which stores decimal.
Harvard Mark I Howard Aiken was a pioneer in computing and a creator of conceptual design for IBM in the 1940s. He envisioned an electro-mechanical computing.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Arrays An array is a sequence of objects all of which have the same type. The objects are called the elements of the array and are numbered consecutively.
C++ for Engineers and Scientists Second Edition Chapter 12 Pointers.
A FIRST BOOK OF C++ CHAPTER 7 ARRAYS. OBJECTIVES In this chapter, you will learn about: One-Dimensional Arrays Array Initialization Arrays as Arguments.
UPC-CompilerCheck High Performance Computing Group Iowa State University Ames, Iowa USA July 26, 2012 Marina Kraeva, James Coyle, Glenn Luecke, Indranil.
Secure Coding Rules for C++ Copyright © 2016 Curt Hill
Data Types In Text: Chapter 6.
Implementing Subprograms Chapter 10
Secure Coding Rules for C++ Copyright © Curt Hill
An Overview of C.
Lecture 7: Types (Revised based on the Tucker’s slides) 10/4/2019
Presentation transcript:

1 Serial Run-time Error Detection and the Fortran Standard Glenn Luecke Professor of Mathematics, and Director, High Performance Computing Group Iowa State University February 2006

2 Outline l HPCS’s for run-time error detection l HPCS’s plan for serial run-time error detection l Iowa State’s serial run-time error detection tests l Examples l Conclusions and future plans

3 HPCS’s Plan for Run-Time Error Detection l Detecting and providing quality error messages for run-time errors will greatly enhance productivity for those using HPC systems. l Phase 1: serial run-time errors l Phase 2: parallel MPI run-time errors l Phase 3: parallel OpenMP run-time errors l Languages: Fortran, C, and C++

4 HPCS’s plan for Serial RTED l For each run-time error and for Fortran, C and C++ develop programs that contain run-time errors. l For each test the expected error message, file name, and line number where the error occurred will be given. l A script will be provided to easily run all tests and compare actual messages with expected messages and assign a grade of A, B, C, D, or F to each test. l Prefer a simple compiler option that will turn on run-time error checking, e.g. –debug. l Before purchasing new machines, DoD may require a specified GPA.

5 Serial Run-time Errors l uninitialized variables l overflows, underflows, and divide by zero l incorrect argument data types and incorrect number of arguments in a procedure l non-conforming use of Fortran 90 arrays l errors with strings l out-of-bounds indexing of statically and dynamically allocated arrays l out-of-bounds pointer references l memory allocation and deallocation errors l file I/O errors l memory leaks l other errors, including new features in Fortran 95

6 Grading Error Messages l Grade A: gave a detailed error message that allows for the quick fixing of the error. l Grade B: gave more information than C and less than A, depends on each test. l Grade C: gave the correct error name, line number where the error occurred, and the name of the file where error occurred. l Grade D: gave the correct error name and line number where error occurred. l Grade F: did not detect an error or gave an incorrect error name or gave no (or incorrect) line number

7 Evaluating Error Messages l For each test and for each grade a Perl grading file has been created. l Error messages are reduced to a canonical form for easy comparison replacing selected phrases with standard phrases. Blanks, hex addresses, and integers longer than 3 are removed to avoid false matches. Grading scripts are applied to the canonical form of error messages to automatically grade them. l

8 Results for Fortran ( 1552 tests) l Cray Unicos/mp (X1) Cray 5.5 Grade: 1.66 l SUN Solaris 10SunONE with bcheck Grade: 1.22 l SUN Solaris 10 SunONE Grade: 1.20 l IBM AIX XLF Grade: 0.82 l SGI IRIX 6.5 MipsPro Grade: 0.71 l Cray Unicos/lc (XT3) PGI 6.0 Grade: 0.67 l RedHat Linux 8.0 Intel 7.1 Grade: 0.61 l RedHat Linux 8.0 GNU Grade: 0.0

9 Results for C ( 716 tests ) l RedHat Linux 8.0 Intel ensure++ Grade: 1.82 l SUN Solaris 10 SunONE with bcheck Grade: 0.40 l Cray Unicos/mp (X1) Cray 5.5 Grade: 0.28 l Cray Unicos/lc (XT3) PGI 6.0 Grade: 0.23 l SGI IRIX 6.5 MipsPro Grade: 0.11 l RedHat Linux 8.0 GNU Grade: 0.0 l SUN Solaris 10 SunONE Grade: 0.0 l RedHat Linux 8.0 Intel 7.1 Grade: 0.0 l IBM AIX XLC Grade: 0.0

10 Results for C++ ( tests ) l RedHat Linux 8.0 Intel ensure++ Grade: 1.75 l SUN Solaris 10 SunONE with bcheck Grade: 0.45 l Cray Unicos/mp (X1) Cray 5.5 Grade: 0.38 l Cray Unicos/lc (XT3) PGI 6.0 Grade: 0.18 l SGI IRIX 6.5 MipsPro Grade: 0.11 l RedHat Linux 8.0 GNU Grade: 0.0 l SUN Solaris 10 SunONE Grade: 0.0 l RedHat Linux 8.0 Intel 7.1 Grade: 0.0 l IBM AIX XLC Grade: 0.0

11 Uninitialized Variable Example ! file name: F_A_3_1_a_d.f program main 35 implicit none 36 double precision :: var, expr 37 double precision :: fct1 38 double precision :: pi 39 integer :: flag pi = 4.0*atan(1.0) 42 flag = int(sin(pi*2.0)) 43 var = 10.d0 44 expr = 1.d0 45 expr = fct1(flag) 46 print *,'var',var,' expr',expr 47 end program main double precision function fct1(flag) 50 implicit none 51 integer, intent(in) :: flag 52 double precision :: tmp ! DECLARE if (flag == 1) then 55 tmp = endif 57 fct1 = tmp**2 + 5 ! read the uninitialized variable. ERROR 58 return 59 end function fct1

12 Current situation –Many compilers report nothing: grade F –Example 1 (incorrect error message): grade F Floating Exception Abort –Example 2 (message is okay, line number correct, file name missing): grade D Run-Time Error: Unassigned variable In Procedure: fct1 Diagnostics Entered From Real Function fct1 Line 57 Grade A error message: ERROR: uninitialized variable At line 57 column 10 of subprogram ‘fct1' in file 'F_A_3_1_a_d.f90' variable 'tmp' is uninitialized. The double precision variable is declared in subprogram ‘fct1' line 52 in file 'F_A_3_1_a_d.f90'. Error messages for uninitialized variables

13 Out-of-bounds array access example ! file name: F_F_3_1_3_a_d.f program tests 30 implicit none 31 integer,parameter :: N=10, m=20 32 double precision :: arr(n,m), var 33 integer :: i,j,indx 34 do j=1,m 35 do i=1,n 36 arr(i,j) = dble(i*j) 37 end do 38 end do 39 var = 0.d0 40 call sub(arr,var,n) 41 print *,var, arr(1,1) 42 end program tests ! file name: F_F_3_1_3_a_d_s.f subroutine sub(arr,var,n) 2 implicit none 3 integer,intent(in) :: n 4 double precision, intent(inout):: arr(n,*), var 5 6 integer :: I,J, bounds 7 double precision :: tmp 8 call random_number(tmp) 9 if (tmp*arr(1,1)<0.d0) then 10 i=1 11 else 12 i=n+1 13 end if 14 j = 1 15 var = arr(i,j) ! read out of bounds ERROR 16 print *,arr(1,1) 17 return 18 end subroutine sub

14 Error messages for out-of-bounds array access Current situation –Example 1 ( missing file name, subscript value, and dimension information): grade D Run-Time Error: Array bounds exceeded In Procedure: sub Diagnostics Entered From Subroutine sub Line 15 Entered From MAIN PROGRAM Line 40 –Example 2 (missing dimension information): grade C ****** FORTRAN RUN-TIME SYSTEM ****** Subscript out of range. Location: line 15 column 12 of 'F_F_3_1_3_a_d_s.f90‘ Subscript number 1 has value 11 in array 'ARR‘ Abort –Example 3 (missing line number for array declaration): grade B WARNING Subscript 11 is out of range for dimension 1 for array 'ARR‘ at line 15 in file 'F_F_3_1_3_a_d_s.f90' with bounds 1:10. Grade A error message: ERROR: out of bounds At line 15 column 12 of subprogram 'sub' in file 'F_F_3_1_3_a_d_s.f90' subscript value 11 is out of bounds for dimension 1 of array 'arr' with bounds 1:10 declared in subprogram 'sub' line 4 in file 'F_F_3_1_3_a_d_s.f90'.

15 Incorrect number of arguments ! file name: F_C_1_1_a.f program tests 32 implicit none 33 double precision :: pi 34 double precision, allocatable :: array(:) 35 integer :: n,i,flag 36 double precision :: var pi = 4.0*atan(1.0) 39 flag = int(cos(pi))*(-1) 40 n = sin(pi*0.1)* allocate(array(N)) 42 do i=1,n 43 array(i) = cos(dble(i)/dble(n)*pi) 44 end do call sub1(array,n,flag,var) ! CALLING ERROR print *, var, flag 49 deallocate(array) 50 end program tests ! file name: F_C_1_1_a_s.f subroutine sub1(arr,n,flag,aout,bout) ! CALLED ERROR 2 implicit none 3 integer, intent(in) :: n, flag 4 double precision, intent(inout) :: arr(*) 5 double precision, intent(inout) :: aout, bout 6 7 integer :: iloc 8 9 if (flag == 1) then 10 do iloc = 1,n 11 arr(iloc) = arr(iloc)+log(dble(iloc)) 12 end do 13 end if 14 iloc = n 15 aout = arr(iloc-n/2) 16 bout = aout/dble(n) 17 end subroutine sub1

16 Error messages for incorrect number of arguments Current state of the affair –Many compilers report nothing: Grade F –Example 1 (missing file name and the number of arguments): Grade D Run-Time Error: Not enough arguments specified Diagnostics Entered From MAIN PROGRAM Line 46 End of diagnostics –Example 2 ( missing file name): Grade D For the entry 'SUB1', called from 'TESTS' at line 46: Number of arguments for call, 4, does not equal expected number of arguments 5. An example of good error message: Grade A ERROR: incorrect number of arguments For the entry 'SUB1' defined in line 1 of file 'F_C_1_1_a_s.f90', called from 'TESTS' at line 46 of file 'F_C_1_1_a.f90', the actual number of arguments, 4, does not equal the expected number of arguments, 5.

17 Current Status for Detecting Serial Run-Time Errors l Most compilers/run-time systems provide little or no detection of run-time errors. l Currently, there is little incentive to develop such tools. l DoD is considering requiring a certain GPA. l We are submitting a proposal to the Fortran standards committee requiring RTED as part of the standard. l Iowa State’s serial RTED tests provide a good way of evaluating the quality of the compiler and run-time system for detecting run-time errors.

18Proposal In the Fortran standard, the term “processor” means the combination of a Fortran compiler and the computing system that executes the code. It is important for Fortran to not only have syntax that allows for easy program development but to also facilitate rapid detection and correction of program errors. A processor is said to conform to the Fortran standard when it has the capability of detecting run-time errors and provides a correct error message containing the file name and line number where the error occurred. To aid in producing a processor that conforms to the Fortran standard for run-time error detections, run-time error tests can be found at These tests include tests for the following run-time errors:

19 Proposal – page 2 l uninitialized variables l overflows, underflows, and divide by zero l incorrect argument data types and incorrect number of arguments in a procedure l non-conforming use of Fortran 90 arrays l errors with strings l out-of-bounds indexing of statically and dynamically allocated arrays l out-of-bounds pointer references l memory allocation and deallocation errors l memory leaks

20 Conclusions and Future Plans l Detection and quality reporting of run-time errors will greatly enhance productivity. l We are proposing that RTED be part of the Fortran standard. l The run-time error tests being developed at Iowa State are a good evaluation method. l We plan to propose to the C and C++ standards committees to include RTED in their standard.