SECTION 6 Performance Tuning.

Slides:



Advertisements
Similar presentations
Introduction to C++ An object-oriented language Unit - 01.
Advertisements

Computer Science 320 Clumping in Parallel Java. Sequential vs Parallel Program Initial setup Execute the computation Clean up Initial setup Create a parallel.
Threads Cannot be Implemented As a Library Andrew Hobbs.
SCIP Optimization Suite
CS Lecture 4 Programming with Posix Threads and Java Threads George Mason University Fall 2009.
Chapter 6: Process Synchronization
Concurrent Programming Introducing the principles of reentrancy, mutual exclusion and thread-synchronication.
Computer Architecture II 1 Computer architecture II Programming: POSIX Threads OpenMP.
1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
Modified from Silberschatz, Galvin and Gagne Lecture 13 Chapter 7: Deadlocks.
ISP – 5 th Recitation Mutexes Code example. Mutex Wikipedia definition: Mutual exclusion (often abbreviated to mutex) algorithms are used in concurrent.
CS444/CS544 Operating Systems Synchronization 2/21/2007 Prof. Searleman
8-1 JMH Associates © 2004, All rights reserved Windows Application Development Chapter 10 - Supplement Introduction to Pthreads for Application Portability.
1 MATERI PENDUKUNG SINKRONISASI Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
CS510 Concurrent Systems Class 5 Threads Cannot Be Implemented As a Library.
Threads© Dr. Ayman Abdel-Hamid, CS4254 Spring CS4254 Computer Network Architecture and Programming Dr. Ayman A. Abdel-Hamid Computer Science Department.
Guide To UNIX Using Linux Third Edition
Threads CNS What is a thread?  an independent unit of execution within a process  a "lightweight process"  an independent unit of execution within.
CSE 380 – Computer Game Programming Render Threading Portal, by Valve,
1 Copyright © 2010, Elsevier Inc. All rights Reserved Chapter 5 Shared Memory Programming with OpenMP An Introduction to Parallel Programming Peter Pacheco.
Multithreading Allows application to split itself into multiple “threads” of execution (“threads of execution”). OS support for creating threads, terminating.
Solution to Dining Philosophers. Each philosopher I invokes the operations pickup() and putdown() in the following sequence: dp.pickup(i) EAT dp.putdown(i)
Atomic Operations David Monismith cs550 Operating Systems.
The HDF Group Multi-threading in HDF5: Paths Forward Current implementation - Future directions May 30-31, 2012HDF5 Workshop at PSI 1.
The University of Adelaide, School of Computer Science
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Threads and Thread Control Thread Concepts Pthread Creation and Termination Pthread synchronization Threads and Signals.
CS345 Operating Systems Threads Assignment 3. Process vs. Thread process: an address space with 1 or more threads executing within that address space,
Sharing Objects  Synchronization  Atomicity  Specifying critical sections  Memory visibility  One thread’s modification seen by the other  Visibility.
Lecture 8 Page 1 CS 111 Online Other Important Synchronization Primitives Semaphores Mutexes Monitors.
Threads CSCE Thread Motivation Processes are expensive to create. Context switch between processes is expensive Communication between processes.
1 Pthread Programming CIS450 Winter 2003 Professor Jinhua Guo.
IT 325 Operating systems Chapter6.  Threads can greatly simplify writing elegant and efficient programs.  However, there are problems when multiple.
Concurrency Control 1 Fall 2014 CS7020: Game Design and Development.
Shan Gao Fall 2007 Department of Computer Science Georgia State University.
Barriers and Condition Variables
Practice Chapter Five.
C Programming Chapters 11, . . .
3/12/2013Computer Engg, IIT(BHU)1 OpenMP-1. OpenMP is a portable, multiprocessing API for shared memory computers OpenMP is not a “language” Instead,
1 Fall 2009ACS-1903 Ch 4 Loops and Files while loop do-while loop for loop Other topics later on …
Distributed Mutual Exclusion Synchronization in Distributed Systems Synchronization in distributed systems are often more difficult compared to synchronization.
1/46 PARALLEL SOFTWARE ( SECTION 2.4). 2/46 The burden is on software From now on… In shared memory programs: Start a single process and fork threads.
Function PrototypetMyn1 Function Prototype We can declare a function before we use or define it by means of a function prototype. A function prototype.
3/17/2016cse synchronization-p2 © Perkins, DW Johnson and University of Washington1 Synchronization Part 2 CSE 410, Spring 2008 Computer.
CSE 451: Operating Systems Section 6 Project 2b. Midterm  Scores will be on Catalyst and midterms were handed back on Friday(?) in class  Talk to Ed,
Mutual Exclusion -- Addendum. Mutual Exclusion in Critical Sections.
Chapter 4: Threads Modified by Dr. Neerja Mhaskar for CS 3SH3.
SPiiPlus Training Class
Chapter 3: Windows7 Part 5.
Process Synchronization
Outline Other synchronization primitives
PThreads.
Boost String API & Threads
Multithreading Tutorial
Other Important Synchronization Primitives
Computer Engg, IIT(BHU)
Section 10: Last section! Final review.
C-language Lecture By B.S.S.Tejesh, S.Neeraja Asst.Prof.
Functional Programming with Java
Chapter 3: Windows7 Part 5.
Chapter 26 Concurrency and Thread
PTHREADS AND SEMAPHORES
Lecture 22 Syed Mansoor Sarwar
CSC 253 Lecture 7.
CSE 451 Autumn 2003 Section 3 October 16.
Dr. Mustafa Cem Kasapbaşı
Multithreading Tutorial
“The Little Book on Semaphores” Allen B. Downey
POSIX Threads(pthreads)
Threads and concurrency / Safety
Presentation transcript:

SECTION 6 Performance Tuning

WHAT IS IN THIS SECTION? Threadsafe Overview Shared Data, Mutex Locks Mutex Example

Threadsafe Overview By default all subroutine computations are executed serially. This is done to avoid conflicts arising from the use of global variables or common data structures. For extensive/lengthy subroutines it can make sense to code subroutines for threadsafe execution. Significant performance gains (wall clock times) are possible. A subroutine declares itself threadsafe via a call to the utility function ADAMS_DECLARE_THREADSAFE()

Shared Data, Mutex Locks Threads & Shared Data: Avoid all situations where data could be shared such as: global/COMMON variables file access Etc. Mutex Locks: Mutex = Mutual Exclusion lock on a global variable. Modern compilers have libraries with mutex functionality: Windows: windows.h provides access to functions like CreateMutex() and WaitForSingleObject() Linux: pthreads.h contains similar functions

Mutex Example Example: modifying a global variable: #include <windows.h> /* use pthreads.h for Linux */ HANDLE ghMutex; /* handle to mutex object */ int gCounter; /* global variable to be shared */ … /* Update global variable using mutex lock: */ WaitForSingleObject(ghMutex, INFINITE); gCounter += 1; ReleaseMutex(ghMutex);