Timing Tutorial #5 CPSC 261. Clocks Most computer systems have a number of clocks – Give time signals to the pipeline and memory Tick at 2.67 GHz (or.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Time Measurement Topics Time scales Interval counting Cycle counters K-best measurement scheme time.ppt CS 105 Tour of Black Holes of Computing.
Microprocessors A Beginning.
System Integration and Performance
COMP375 Computer Architecture and Organization Senior Review.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
ECE 353 ECE 353 Fall 2009 Lab C Pipeline Simulator October 22, 2009.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
Source Control in MATLAB A tool for tracking changes in software development projects. Stuart Nelis & Rachel Sheldon.
File processing with functions H&K Chapter 3 Instructor – Gokcen Cilingir Cpt S 121 (June 27, 2011) Washington State University.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction Data files –Can be created, updated,
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
C Programming Basics Lecture 5 Engineering H192 Winter 2005 Lecture 05
IT Systems Operating System EN230-1 Justin Champion C208 –
Operating Systems. What is an Operating System? A layer of software between users/applications and the hardware. The first program loaded onto a computer.
Time Measurement October 25, 2001 Topics Time scales Interval counting Cycle counters K-best measurement scheme class18.ppt.
Chapter 9_2 Following Instructions: Principles of Computer Operation.
A look at interrupts What are interrupts and why are they needed.
Computer Organization and Architecture
Week 8 - Friday.  What did we talk about last time?  String to int conversions  Users and groups  Password files.
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
Computers in the real world Objectives Understand what is meant by memory Difference between RAM and ROM Look at how memory affects the performance of.
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
Chapter 5 Basic Processing Unit
CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap.
C File Processing. Objectives To be able to create, write and update files. To become familiar with sequential access file processing. To become familiar.
Real-time Systems Lab, Computer Science and Engineering, ASU Linux Input Systems (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
C Programming - Lecture 6 This lecture we will learn: –Error checking in C –What is a ‘wrappered function’? –What is a clean interface? –How to earn your.
CMPE 421 Parallel Computer Architecture
Why does it matter how data is stored on a computer? Example: Perform each of the following calculations in your head. a = 4/3 b = a – 1 c = 3*b e = 1.
What have mr aldred’s dirty clothes got to do with the cpu
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
OSes: 11. FS Impl. 1 Operating Systems v Objectives –discuss file storage and access on secondary storage (a hard disk) Certificate Program in Software.
1. Introduction File Declaration and Initialization Creating and Opening File Closing File EOF Reading from and Writing into a File Extra : Random Access.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
Chapter 8 : Binary Data Files1 Binary Data Files CHAPTER 8.
1 Homework Reading –PAL pp , Continue mp1 –Questions? Continue lab sessions with your section.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Adv. UNIX: Profile/151 Advanced UNIX v Objectives –introduce profiling based on execution times and line counts Special Topics in Comp.
Threads Tutorial #7 CPSC 261. A thread is a virtual processor Each thread is provided the illusion that it owns a core – Copy of the registers – It is.
Computer Hardware. What is Hardware? Hardware is any part of a computer you can touch There are 2 categories: Inside the computer Peripherals connected.
Lecture 2a: Performance Measurement. Goals of Performance Analysis The goal of performance analysis is to provide quantitative information about the performance.
C File Processing. Objectives To be able to create, write and update files. To become familiar with sequential access file processing. To become familiar.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Debugging, bug finding and bug avoidance Part 2 Alan Dix
S -1 Library Functions. S -2 Standard Libraries Any system call is not part of the C language definition Such system calls are defined in libraries, identified.
Advanced loop controls. Loop Controls Recall from last week loop controls Event-controlled loops using sentinels repeats until a control variable takes.
FILES IN C. File Operations  Creation of a new file  Opening an existing file  Reading from a file  Writing to a file  Moving to a specific location.
C Programming Day 2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Union –mechanism to create user defined data types.
UniMAP SemI-11/12EKT120: Computer Programming1 Files.
UniMAP SemI-11/12EKT120: Computer Programming1 Files.
Real Numbers Device driver process within the operating system that interacts with I/O controller logical record 1 logical record 2 logical record 3.
Computer Architecture and Number Systems
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Homework Reading Machine Projects Labs
Timer and Interrupts.
EKT120: Computer Programming
File I/O We are used to reading from and writing to the terminal:
CSE 333 – Section 3 POSIX I/O Functions.
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
Computer Organization
CSE 333 – Section 3 POSIX I/O Functions.
Operating Systems Lecture 3.
Chapter 3: Processes.
CSc 352 File I/O Saumya Debray Dept. of Computer Science
File I/O We are used to reading from and writing to the terminal:
Presentation transcript:

Timing Tutorial #5 CPSC 261

Clocks Most computer systems have a number of clocks – Give time signals to the pipeline and memory Tick at 2.67 GHz (or whatever) – Interrupt generating clocks Interrupt every X ms – Real time clocks Keep track of time in the “real world”

Linux notion of time time() – return the number of seconds since Jan 1, 1970 UTC gettimeofday() – More fine-grained notion of time – Seconds and milliseconds – Stored in a structure called a timeval

How to measure elapsed time? int before = time(0) // do the work int after = time(0) int elapsed = after – before

Problems with using time Coarse granularity Often get an answer of 0 Sometimes get 1 second even for short operations

Try #2 measuring elapsed time struct timeval before, after; gettimeofday(&before) // do the work gettimeofday(&after) elapsed = after - before

Problems with using gettimeofday Overhead of measurement may dwarf small elapsed times struct timevals don’t support subtraction (so you have to write it)

General problems with timing Timing short-lived events – Repeat them a lot of times External factors can affect measurement – Other processes – Hardware interrupts Repeat measurements a few times

Look at timenothing.c Explain all the interesting bits

Special files Linux has a number of special files in /dev – null Reads return EOF Writes disappear into the bit-bucket – zero Reads return 0 bytes Writes disappear into the bit-bucket – random Reads return random bytes Writes affect later reads in a non-obvious way

Throwing stuff away From the command line: – chatty-program > /dev/null

System calls and library calls The lowest level of interaction with the Linux system is via system calls – read, write, open, close – Documented in section 2 of the manual More “user-friendly” interfaces can often be found in the “standard library” – fread, fwrite, fopen, fclose – Documents in section 3 of the manual

issawtooth issawtooth is a function that detects sawtooth patterns – Each value is alternatively bigger or smaller than the one before it – Starting with bigger issawtooth(1) == 1 issawtooth(1, 4, 3, 10, 3, 5) == 1 issawtooth(1, 4, 4, 10, 3, 5) == 0 issawtooth(1, 4, 5, 10, 3, 5) == 0

Look at issawtooth.c long issawtooth(long *p, long n) { long i; long up = 1; for (i = 1; i < n; i++) { if (up && p[i] <= p[i-1]) return 0; if (!up && p[i] >= p[i-1]) return 0; up = !up; } return 1; }

Look at issawtooth.s Explain what it is doing

Make it faster Less memory accesses Less branches Less dependencies

The online scoreboard Each time you check in your lab, the scoreboard will be updated – Your checkin will be a bit slower /scoreboard/index.php /scoreboard/index.php