F RANZ I NC. Optimizing and Debugging Programs in Allegro CL By Duane Rettig April, 2007.

Slides:



Advertisements
Similar presentations
Introduction to C++ Templates Speaker: Bill Chapman, C++ developer, financial company in Mid-Manhattan. Can be reached via: ' This.
Advertisements

1 Symbol Tables. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
1 Object Orientation James Brucker. 2 Smalltalk  Ahead of its time: consistent design and rich library.  Dynamic (like Lisp): variables have no specified.
INSTRUCTION SET ARCHITECTURES
1 C and the 8051 EGRE Introduction The Silicon Labs ISE uses the Keil C51 compiler. The code size is limiter to 2K C has replaced PL/M (the original.
1 Allegro CL 9.0 Internals Duane Rettig ILC 2012.
PITCH DETECTION Shaan Patel HoangMinh Nguyen Richard King.
F RANZ I NC. Making Environments Accessible in Common Lisp By Duane Rettig June, 2005.
CPSC Compiler Tutorial 8 Code Generator (unoptimized)
Lisp Recitation (cse471/598 Fall 2007 ) Aravind Kalavagattu.
Introduction to Java Kiyeol Ryu Java Programming Language.
Tutorial 6 & 7 Symbol Table
Instruction Representation II (1) Fall 2007 Lecture 10: Instruction Representation II.
Finding and Debugging Errors
Instruction Representation II (1) Fall 2005 Lecture 10: Instruction Representation II.
Portability CPSC 315 – Programming Studio Spring 2008 Material from The Practice of Programming, by Pike and Kernighan.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
Functional Programming COMP2003 A course on functional programming using Common Lisp Dr Eleni Mangina
Design Synopsys System Verilog API Donations to Accellera João Geada.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
F RANZ I NC. An In-Depth Look at Simple Streams By Duane Rettig October, 2002.
F UNCTIONAL P ROGRAMMING 05 Functions. F UNCTIONS - G LOBAL F UNCTIONS fboundp Tells whether there is a function with a given symbol as its name > (fboundp.
Allegro CL Certification Program Lisp Programming Series Level I Session Overview of Common Lisp.
F RANZ I NC. Optimizing User Code in Allegro CL 5.0 by Duane Rettig.
Review C++ exception handling mechanism Try-throw-catch block How does it work What is exception specification? What if a exception is not caught?
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
Software Performance Analysis Using CodeAnalyst for Windows Sherry Hurwitz SW Applications Manager SRD Advanced Micro Devices Lei.
ITEC 380 Organization of programming languages Lecture 6 – Functional Programming.
Review 1.Lexical Analysis 2.Syntax Analysis 3.Semantic Analysis 4.Code Generation 5.Code Optimization.
1 Intro to Data Structures and ADTs Chapter 2. 2 Goal of Data Structures Organize data Facilitate efficient … –storage –retrieval –manipulation Select.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
Lecture 1-2CS251: Intro to AI/Lisp II “And now for something completely different…”
Lexical Analyzer in Perspective
Macros “How can you get anything done in [other languages], I think, without macros?” - Paul Graham, 2003.
Allegro CL Certification Program Lisp Programming Series Level I Session Basic Lisp Development in the IDE.
1 Introduction to Hashing - Hash Functions Sections 5.1, 5.2, and 5.6.
Prolog Program Style (ch. 8) Many style issues are applicable to any program in any language. Many style issues are applicable to any program in any language.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
11 Speed & Debug.  Lisp is really two languages:  A language for writing fast programs  A language for writing programs fast  In the early stage,
UMBC CMSC Common Lisp II. UMBC CMSC Input and Output Print is the most primitive output function > (print (list 'foo 'bar)) (FOO BAR) The.
Miscellaneous Topics Packages –Provide separable name spaces for functions, constants, macros –We can encapsulate code in packages like classes in Java.
12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt1 Topic 2b High-Level languages and System Software (Languages) Introduction to Computer Systems Engineering.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
Compiling “premature optimization is the root of all evil.” -Donald Knuth.
1 CSCD 326 Data Structures I Hashing. 2 Hashing Background Goal: provide a constant time complexity method of searching for stored data The best traditional.
תרגול 5 תכנות באסמבלי, המשך
Macros and general code walkers in Lisp: how useful! or, how useful? Ernst van Waning
Linking Loader untuk SIC/XE Machine. Lebih Lanjut mengenai Absolute Loader Shortcoming of an absolute loader –Programmer needs to specify the actual address.
Object Oriented Programming Lecture 2: BallWorld.
R Byte Code Optimization Compiler (1) March
Lexical Analyzer in Perspective
Compiler Construction (CS-636)
Data Structures in Lisp
System Programming and administration
Mixing C & Assembly.
CSE 351 Section 1: HW 0 + Intro to C
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
Lecturer PSOE Dan Garcia
Hash Functions Sections 5.1 and 5.2
High Coverage Detection of Input-Related Security Faults
Bare Metal System Software Development
Closure Representations in Higher-Order Programming Languages
Catharine West Bo Aye Saljin LaRocca references
Peter Seibel Practical Common Lisp Peter Seibel
Introduction to Intermediate Code, virtual machine implementation
Bindings, Scope, and Extent
Data Structures in Lisp
Data Structures in Lisp
Common Lisp II.
Presentation transcript:

F RANZ I NC. Optimizing and Debugging Programs in Allegro CL By Duane Rettig April, 2007

F RANZ I NC. Introduction Personal Tutorial will become available via ftp Some things available only in 8.1 Some concepts are from LUGM/1998

F RANZ I NC. Outline Debug Low Level Hacks Optimization

F RANZ I NC. Debug Zoom Niceties –[ run zoom.lisp] gdb/dbx/windbg interface –[ show manual demos]

F RANZ I NC. Low Level Hacks Intro: Structure of Allegro CL “ll” functions Lap code

F RANZ I NC. Structure of Allegro CL src/ c/*.c rs/*.cl code/*.cl compile asm *.s*.o *.fasl cc

F RANZ I NC. Structure (cont) *.o *.so ld *.fasl libacl*.so lisp (dumplisp) running lisp *.dxl

F RANZ I NC. Example rs code (def-runtime-q new-ratio (num den) (let ((rat (q-allocate-heap-other #md-ratio-type-code #md-ratio-size))) (setf (ls md-ratio num rat) num) (setf (ls md-ratio den rat) den) rat))

F RANZ I NC. Example lisp ll code [run “both-fixnum-p.lisp”]

F RANZ I NC. “ll” functions [see ll-doc.html]

F RANZ I NC. Another ll example Some compiler-macros expand to ll funcs –[run char-code.lisp]

F RANZ I NC. Lap code comp::*hack-compiler-output* –[run hack-compiler-output.lisp] comp::*assemble-function-body* –[run assemble-function-body.lisp]

F RANZ I NC. Optimization Compilation Boxing and unboxing Read-line Foreign types Memcpy String manipulation Aligned pointers Hashing Runtime Analyzer

F RANZ I NC. Optimization Methodology Get it right first Profile it –The time macro –The Allegro CL Runtime Analyzer Hit the high cost items –Implementations –Algorithms

F RANZ I NC. Compilation Adding declarations to code (declare (:explain :types :inlining)) –[run inlining-demos.lisp]

F RANZ I NC. Boxing and Unboxing Ensuring optimal unboxability –[run unboxing.lisp] Immediate args –[see immediate-args.html]

F RANZ I NC. read-line What's wrong with it?

F RANZ I NC. read-line It always conses! What to do? –read-line-into Never conses Must deal with overflowing lines –simple-stream-read-line Two modes –implementation for read-line –similar to read-line, handling overflows [see read-line-test.html]

F RANZ I NC. memcpy memcpy-up memcpy-down [see memcpy-demo.html]

F RANZ I NC. String Manipulation string+ and the standard, with concatenate [see string+.cl]

F RANZ I NC. Aligned Pointers Allow cons-free pointer manipulation Pointers look like fixnums Pointers must be aligned to: –32-bit: 4-byte boundaries –64-bit: 8-byte boundaries [see “aligned.html”]

F RANZ I NC. Aligned Pointers (cont) most-positive-fixnum most-negative-fixnum for 32-bit: signed fixnum unsigned 0 #x7ffffffc #x #xfffffffc-1 (fix)

F RANZ I NC. Foreign types (sorry, under construction): Foreign-types aren't just for foreign-functions We can combine disciplines –[run mapped-aligned-ftype.lisp]

F RANZ I NC. Hashing :test extensions :values [t] (may be nil or :weak) :weak-keys [nil] (may be non-nil) :hash-function [nil] (or fboundp symbol) –must return 24 bit value for 32-bit lisps 32 bit value for 64-bit lisps

F RANZ I NC. Hashing Rehash-issues excl::*default-rehash-size* excl::*allocate-large-hash-table-vectors-in-old-space* excl::convert-to-internal-fspec –example of weak-key, sans-value hash-table [run shared-cons-table.lisp]

F RANZ I NC. Hashing Hash tables are very efficient if hash codes are well-distributed excl::hash-table-stats –[run hash-table-stats.lisp]

F RANZ I NC. Runtime Analyzer (explain the name) Always compile top-level test functions Do not use time macro with profiler Avoid simultaneous time/call-count profiles When using time macro, beware of new closures Use prof:disassemble-profile

F RANZ I NC. Time macro: extra closures This driver is not as simple as it looks! (defun test-driver (n) (time (dotimes (i n) (test-it)))

F RANZ I NC. Time macro: avoiding extra closures Use this instead: (defun test-driver (n) (dotimes (i n) (test-it)) (time (test-driver ))

F RANZ I NC. disassemble-profile Provides sample hit counts and percentages Multiple disassembles provide info similar to call-graph [show manual demo]

F RANZ I NC. Thank You.