Lecture23 - Last time Chapter 16 Standard library Introduction to Low-Level Programming Concepts CMSC 212 Lecture 23 time timing programs date and

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Low-Level Programming Concepts CMSC 212 ecture 23 1 CMSC 212 Lecture 23 November 17, 2009 Last time c Chapter 16, Standard library – time, timing programs, date and time functions – the gprof utility c Libraries – introduction to libraries – types of libraries 2 CMSC 212 – dynamically loading shared libraries – creating and using static and shared libraries – the dlfcn() functions for dynamically loading shared libraries Reading c c Then read Sections 8.2-8.4 and 8.7, Bryand & O'Hallaron 3 CMSC 212 Libraries, con't. 4 CMSC 212
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Dynamically loading a library, con't. c To compile a program that uses the functions in dlfcn.h to dynamically load a library add the options -rdynamic and –ldl – for example, assume the program in main.c was modified to use the dlfcn functions, and wants to dynamically load functions from the library libavl.so in the current directory: cc dynamic dl ain.x ain.c 5 CMSC 212 gcc –rdynamic –ldl –o main.x main.c c To run a program that dynamically loads a shared library: – the program loader again needs to be told to look in a nonstandard directory for libraries, using setenv LD_LIBRARY_PATH . – then just run main.x and the library is opened when the program calls dlopen() , functions in it are loaded when it calls dlsym() , and can be executed via the returned function pointer Optimizing program performance, 6 CMSC 212 How processors spend their time c Not all instructions take the same amount of time- some are more expensive c Processors have caches to keep copies of recently accessed memory locations in fast storage – recently accessed locations are more likely to be accessed again soon, and nearby locations are more likely to be accessed 7 CMSC 212 – each cache item stores a number of values (called the line size ) – the same instruction may take different amounts of time different times it’s executed – efficiency will be maximized if the same cache items are used multiple times – consider: for (i= 0; i < limit; i++) for (j= 0; j < limit; j++) for (k= 0; k < limit; k++) a[i][j] += b[i][k] * c[k][j]; Understanding modern processors c Some floating point operations take longer than the corresponding integer operations – perhaps 5 to 10 times longer c Superscalar processors can execute two or more instructions at the same time c Pipelining 8 CMSC 212
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/23/2009 for the course CMSC 212 taught by Professor Staff during the Spring '08 term at Maryland.

Page1 / 7

Lecture23 - Last time Chapter 16 Standard library Introduction to Low-Level Programming Concepts CMSC 212 Lecture 23 time timing programs date and

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online