Advanced Programming Issues JAI and Threads Courtesy ndanger at

Slides:



Advertisements
Similar presentations
Computer Science 320 Clumping in Parallel Java. Sequential vs Parallel Program Initial setup Execute the computation Clean up Initial setup Create a parallel.
Advertisements

Threads, SMP, and Microkernels
Digital Images in Java Java’s imaging classes. Java imaging library  Java has good support for image processing  Must master a handful of classes and.
Processes Management.
Threads Relation to processes Threads exist as subsets of processes Threads share memory and state information within a process Switching between threads.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Modified from Silberschatz, Galvin and Gagne ©2009 Lecture 7 Chapter 4: Threads (cont)
CS 180 Problem Solving and Object Oriented Programming Fall 2011 Notes for the Final Lecture Dec 7, 2011 Aditya Mathur Department of Computer Science Purdue.
1 Chapter 4 Threads Threads: Resource ownership and execution.
Multithreading in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Multithreading in Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Threads Chapter 4. Modern Process & Thread –Process is an infrastructure in which execution takes place  (address space + resources) –Thread is a program.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
Threading in Java – a Tutorial QMUL IEEE SB. Why Threading When we need to run two tasks concurrently So multiple parts (>=2) of a program can run simultaneously.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
1 Advanced Computer Programming Concurrency Multithreaded Programs Copyright © Texas Education Agency, 2013.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Computer Science 320 Load Balancing for Hybrid SMP/Clusters.
Data Compression1 File Compression Huffman Tries ABRACADABRA
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
CHEN Ge CSIS, HKU March 9, Jigsaw W3C’s Java Web Server.
Multithreading in Java Project of COCS 513 By Wei Li December, 2000.
1 Concurrent Languages – Part 1 COMP 640 Programming Languages.
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
Games Development 2 Concurrent Programming CO3301 Week 9.
GPU Architecture and Programming
OPERATING SYSTEM SUPPORT DISTRIBUTED SYSTEMS CHAPTER 6 Lawrence Heyman July 8, 2002.
Multithreading in Java Sameer Singh Chauhan Lecturer, I. T. Dept., SVIT, Vasad.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
Thinking in Parallel – Implementing In Code New Mexico Supercomputing Challenge in partnership with Intel Corp. and NM EPSCoR.
CS- 492 : Distributed system & Parallel Processing Lecture 7: Sun: 15/5/1435 Foundations of designing parallel algorithms and shared memory models Lecturer/
CUDA Basics. Overview What is CUDA? Data Parallelism Host-Device model Thread execution Matrix-multiplication.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
A Memory-hierarchy Conscious and Self-tunable Sorting Library To appear in 2004 International Symposium on Code Generation and Optimization (CGO ’ 04)
1 OS Review Processes and Threads Chi Zhang
Computer Science 320 Load Balancing. Behavior of Parallel Program Why do 3 threads take longer than two?
Image Processing A Study in Pixel Averaging Building a Resolution Pyramid With Parallel Computing Denise Runnels and Farnaz Zand.
Computer Science 320 A First Program in Parallel Java.
Threads. Thread A basic unit of CPU utilization. An Abstract data type representing an independent flow of control within a process A traditional (or.
Multithreading & Synchronized Algoritma Pemrograman 3 Sistem Komputer – S1 Universitas Gunadarma 1.
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,
Concurrency and Performance Based on slides by Henri Casanova.
Concurrency in Java MD. ANISUR RAHMAN. slide 2 Concurrency  Multiprogramming  Single processor runs several programs at the same time  Each program.
INTRODUCTION TO HADOOP. OUTLINE  What is Hadoop  The core of Hadoop  Structure of Hadoop Distributed File System  Structure of MapReduce Framework.
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Mergesort example: Merge as we return from recursive calls Merge Divide 1 element 829.
A thread is a basic unit of CPU utilization within a process Each thread has its own – thread ID – program counter – register set – stack It shares the.
Lecture 3 – MapReduce: Implementation CSE 490h – Introduction to Distributed Computing, Spring 2009 Except as otherwise noted, the content of this presentation.
Introduction to threads
Kai Li, Allen D. Malony, Sameer Shende, Robert Bell
Auburn University
Processes and threads.
Process concept.
Processes and Threads Processes and their scheduling
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing Mapping Techniques Dr. Xiao Qin Auburn University.
Operating System (013022) Dr. H. Iwidat
Process Management Presented By Aditya Gupta Assistant Professor
Computer Engg, IIT(BHU)
PRG 421 MART Education for Service-- prg421mart.com.
Definitions Concurrent program – Program that executes multiple instructions at the same time. Process – An executing program (the running JVM for Java.
Chapter 2: The Linux System Part 3
Threads Chapter 4.
Multithreaded Programming
FUNDAMENTAL CONCEPTS OF PARALLEL PROGRAMMING
Operating System Overview
Lecture 19 Threads CSE /6/2019.
Java Chapter 3 (Estifanos Tilahun Mihret--Tech with Estif)
Threads and concurrency / Safety
Presentation transcript:

Advanced Programming Issues JAI and Threads Courtesy ndanger at distributed under CC license

Concurrency Concurrency (parallelization) occurs when more than one process is executing at the same time. Computing systems often have multiple cores (or cpus) which can function simultaneously. Many of the filters presented in this text can be made much more efficient through the use of concurrency. Java uses threads as parallel processes within a program.

Thread Thread is a Java class that represents a thread The Thread class contains three primary methods void run() – the code that should be executed in parallel with others void join() – block and wait for the thread to complete its run void start() – allocate system resources for the Thread and execute the

Image processing filters Common technique is to divide an image into tiles. The tiles are assigned to threads that process the tile. Must control the tiling such that a tile is never assigned to multiple threads and that all tiles are assigned. Construct an ImageTiler object. The tiler accepts a BufferedImage and dimensions of the tiles. It then serves as a synchronized (thread save) iterator that dispenses tiles via the next method.

Construct a Thread Must author a thread that applies a BufferedImageOp to tiles of an image.

Notes The getSubimage method returns a BufferedImage that shares the same databuffer as the source. Modification of the subimage is a modification of the source The OpThread applies the same operation to each tile The OpThread gets tiles from the tiler. It doesnt matter which tiles are being operated on.

Can even write a ConcurrentOp How about writing a BufferedImageOp that applies another BufferedImageOp in a concurrent fashion! The ConcurrentOp accepts a BufferedImageOp and Creates a single image tiler Creates an OpThread for each available processor in the system. Each OpThread uses the same tiler Starts the OpThreads and then waits for them to finish via the join.

Using the ConcurrentOp Here is some client code that makes use of the concurrent filter class. BufferedImage source = ImageIO.read(new File(file.jpg)); BufferedImageOp invertor = new InvertOp(); ConcurrentOp op2 = new ConcurrentOp(invertor, 100, 100); BufferedImage dest = op2.filter(source, null); BufferedImage source = ImageIO.read(new File(file.jpg)); BufferedImageOp invertor = new InvertOp(); ConcurrentOp op2 = new ConcurrentOp(invertor, 100, 100); BufferedImage dest = op2.filter(source, null); Not all ops are threadable. Any thread that relies on the location of a sample or the order of sample processing will not work properly.

JAI Java Advanced Imaging (JAI) is a sophisticated image processing library. Provides full support for floating point images Larger range of image encoders/decoders Larger range of color models Multiple source filters Deferred execution Direct support for distributed and threaded applications Can be executed in either Accelerated mode by using optimized native libraries (DLLs) Native mode by using straight Java (slower).

JAI A JAI filter is viewed as a directed graph Each node is an operation Each edge shows the input/output Each node is also the result of the operation

JAI Classes Three main classes RenderedOp – a node in a JAI chain ParameterBlockJAI – a set of parameters for an operation JAI – a set of static methods for creating chains.