PYTHON FOR HIGH PERFORMANCE COMPUTING. OUTLINE  Compiling for performance  Native ways for performance  Generator  Examples.

Slides:



Advertisements
Similar presentations
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Advertisements

Software Development Languages and Environments. Programming languages High level languages are problem orientated contain many English words are easier.
Programming Paradigms and languages
Binding python to other languages (Fortran and C).
CPSC Compiler Tutorial 9 Review of Compiler.
Complexity Analysis (Part I)
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
Guide To UNIX Using Linux Third Edition
Chapter 1 Program Design
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Database Management Systems (DBMS)
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Discussion Section: HW1 and Programming Tips GS540.
Language Evaluation Criteria
CIS Computer Programming Logic
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Standard Grade Computing SYSTEM SOFTWARE CHAPTER 19.
Higher Grade Computing Studies 2. Languages and Environments Higher Computing Software Development S. McCrossan 1 Classification of Languages 1. Procedural.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Group 4 Java Compiler Group Members: Atul Singh(Y6127) Manish Agrawal(Y6241) Mayank Sachan(Y6253) Sudeept Sinha(Y6483)
I Power Higher Computing Software Development Development Languages and Environments.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
FOUNDATION IN INFORMATION TECHNOLOGY (CS-T-101) TOPIC : INFORMATION SYSTEM – SOFTWARE.
RUBY by Ryan Chase.
Chapter 4 Software. Chapter 4: Software Generations of Languages Each computer is wired to perform certain operations in response to an instruction. An.
Fortress Aaron Becker Abhinav Bhatele Hassan Jafri 2 May 2006.
Files Tutor: You will need ….
FORTRAN History. FORTRAN - Interesting Facts n FORTRAN is the oldest Language actively in use today. n FORTRAN is still used for new software development.
GROUPING OBJECTS CITS1001. Lecture outline The ArrayList collection Process all items: the for-each loop 2.
C LANGUAGE Characteristics of C · Small size
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Single Node Optimization Computational Astrophysics.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Introduction to Language Programming Hierarchy of programming lang. Based on machine independences: 1. Machine language 2. Assembly language 3. Higher.
The Accumulator Pattern Summing: Add up (“accumulate”), e.g. 1 2 plus 2 2 plus 3 2 plus … plus Variation: Form a product (instead of sum), e.g.
1 HPJAVA I.K.UJJWAL 07M11A1217 Dept. of Information Technology B.S.I.T.
The Functions and Purposes of Translators Translators, Interpreters and Compilers - High Level Languages.
Introduction to Computer Programming using Fortran 77.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
Programming 2 Intro to Java Machine code Assembly languages Fortran Basic Pascal Scheme CC++ Java LISP Smalltalk Smalltalk-80.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
As a general rule you should be using multiple languages these days (except for Java)
Quiz 4 Topics Aid sheet is supplied with quiz. Functions, loops, conditionals, lists – STILL. New topics: –Default and Keyword Arguments. –Sets. –Strings.
Terms: Software  Set of instructions  aka programs  Operating System:  Special software whose job it is to translateinstructions into hardware instructions.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
The Accumulator Pattern Motivating Example: Suppose that you want to add up (“accumulate”) 1 2 plus 2 2 plus 3 2 plus … plus You could use: total.
COMP 2100 From Python to Java
Entry Ticket: High and Low Level Languages
Teaching Computing to GCSE
LING 388: Computers and Language
Unit# 8: Introduction to Computer Programming
Compiler Construction
Topics Introduction to File Input and Output
Introduction to Python
Winter 2018 CISC101 12/1/2018 CISC101 Reminders
Transforming Data (Python®)
Bryan Burlingame 13 February 2019
Topics Introduction to File Input and Output
Matlab Basics Tutorial
Topics Introduction to File Input and Output
Python Basics. Topics Features How does Python work Basic Features I/O in Python Operators Control Statements Function/Scope of variables OOP Concepts.
Introduction to Computer Science
Presentation transcript:

PYTHON FOR HIGH PERFORMANCE COMPUTING

OUTLINE  Compiling for performance  Native ways for performance  Generator  Examples

IMPORTANCE OF COMPILED CODE  When a code (e.g. a for loop) is written in C, the compiler has the opportunity to optimize its use of memory and floating point units.  The Python interpreter, on the other hand, doesn’t have nearly the same ability.  Import a Python module whose implementation is in C or Fortran

NUMPY EXAMPLE  Using NumPy for mathematical operations on arrays and vectors can be hundreds of times faster.  NumPy libraries have been tested, and integrating C or Fortran subroutines you might have written becomes easier.  Tutorial:

CYTHON  An Open-Source project  Almost a Python compiler (almost)  An extended Python language  writing fast Python extension modules  interfacing Python with C libraries Credit: Behnal

NATIVE WAYS TO GAIN PERFORMANCE  Python is not as strong in memory management  Using the del keyword to delete a variable  Using the feature called generators: greatly reduces memory usage and simplify programming when used in a particular design pattern

GENERATOR  A generator is a function that produces a sequence of results instead of a single value  Calling a generator function creates an generator object  When the generator returns, iteration stops  A generator function is a more convenient way of writing an iterator  A generator is a one-time operation – different than a list, need to call again for another iteration

GENERATOR EXPRESSIONS  General Syntax: Expression for i in s if condition for i in s: if condition: yield expression E.g. generated version of a list comprehension

EXAMPLE: PROCESSING DATA FILES  Summing up the last column of data in a log file  Non-generator solution  Generator solution

GENERATORS AS A PIPELINE  Each step is defined by iteration/generation  Instead of focusing on the problem at a line-by-line level, we just break it down into big operations that operate on the whole file.  The iteration that occurs in each step holds the pipeline together.

EXAMPLE FURTHER DEVELOPED  Developed from the last program to read hundreds of logs across various directories.  Using the function “os.walk” for searching the file system.

 Open a sequence of filenames  Concatenate items from one or more source into a single sequence of items

 Generate a sequence of lines that contain a given regular expression

 Call Generator Functions

REFERENCES  Behnel, S. Using the Cython Compiler to write fast Python code  Generator Tricks for Systems Programmers by David M. Beazley