Parallel Programming in Contemporary Programming Languages

Slides:



Advertisements
Similar presentations
MPI Message Passing Interface
Advertisements

1 CGICGI Common Gateway Interface Server-side Programming Lecture.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
Go Language * Go - Routines * Channels. New Concepts Do not communicate by sharing memory; instead, share memory by communicating. creating shared memory.
Master/Slave Architecture Pattern Source: Pattern-Oriented Software Architecture, Vol. 1, Buschmann, et al.
JQUERY/AJAX ALIREZA KHATAMIAN DELARAM YAZDANSEPAS.
Google App Engine Cloud B. Ramamurthy 7/11/2014CSE651, B. Ramamurthy1.
DISTRIBUTED AND HIGH-PERFORMANCE COMPUTING CHAPTER 7: SHARED MEMORY PARALLEL PROGRAMMING.
INTERNET DATABASE Chapter 9. u Basics of Internet, Web, HTTP, HTML, URLs. u Advantages and disadvantages of Web as a database platform. u Approaches for.
1: Operating Systems Overview
Scripting Languages For Virtual Worlds. Outline Necessary Features Classes, Prototypes, and Mixins Static vs. Dynamic Typing Concurrency Versioning Distribution.
Client Server Model and Software Design TCP/IP allows a programmer to establish communication between two application and to pass data back and forth.
Chapter 3 Software Two major types of software
CHAPTER 28 INTEGRATING WEB WORKERS. LEARNING OBJECTIVES How a Web worker is essentially a JavaScript routine that performs concurrent processing within.
Client/Server Architectures
INTRODUCTION TO WEB DATABASE PROGRAMMING
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Lecture 4: Parallel Programming Models. Parallel Programming Models Parallel Programming Models: Data parallelism / Task parallelism Explicit parallelism.
1 Developing Native Device for MPJ Express Advisor: Dr. Aamir Shafi Co-advisor: Ms Samin Khaliq.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures.
LOGO OPERATING SYSTEM Dalia AL-Dabbagh
Operating System Review September 10, 2012Introduction to Computer Security ©2004 Matt Bishop Slide #1-1.
ICOM 5995: Performance Instrumentation and Visualization for High Performance Computer Systems Lecture 7 October 16, 2002 Nayda G. Santiago.
Cloud Computing 1. Outline  Introduction  Evolution  Cloud architecture  Map reduce operation  Platform 2.
WEB WORKERS 1 Amitesh Madhur (Exceptional Performance, Bangalore)
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
Accelerator Physics SNS EPICS Integration with Web-based Technologies Presentation by Madhan Sundaram.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
Vitaliy Tarnavskyy Jun 26, 2013 Using Web workers in Javascript.
School of Computing and Information Systems CS 371 Web Application Programming AJAX.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
LabVIEW.com.tw LabVIEW Community Speeding Up Your VIs 參考 NI 官方教材: LabVIEW Intermediate II for 7.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Connecting LabVIEW to EPICS network
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
Node.Js 1. 2 Contents About Node.Js Web requirement latest trends Introduction Simple web server creation in Node.Js Dynamic Web pages Dynamic web page.
Different Microprocessors Tamanna Haque Nipa Lecturer Dept. of Computer Science Stamford University Bangladesh.
EPICS and LabVIEW Tony Vento, National Instruments
GPU Computing for GIS James Mower Department of Geography and Planning University at Albany.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
R Some of these slides are from Prof Frank Lin SJSU. r Minor modifications are made. 1.
Introduction to Node.js® Jitendra Kumar Patel Saturday, January 31, 2015.
Tutorial 2: Homework 1 and Project 1
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Programming in Go(lang)
Applications Active Web Documents Active Web Documents.
Project Target Develop a Web Based Management software suit that will enable users to control Hardware using standard HTTP & Java Applet compatible web.
Node.Js Server Side Javascript
Netscape Application Server
Learning to Program D is for Digital.
CS 371 Web Application Programming
The Mach System Sri Ramkrishna.
Mobile App Development
Google Web Toolkit Tutorial
CSE 775 – Distributed Objects Submitted by: Arpit Kothari
Parallel Programming By J. H. Wang May 2, 2017.
University of Technology
Node.Js Server Side Javascript
Parallel Programming in Contemporary Programming Languages (Part 2)
DWR: Direct Web Remoting
Chapter 4: Threads.
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
Multiple Processor Systems
Google App Engine Ying Zou 01/24/2016.
Multithreaded Programming
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Programming Parallel Computers
Presentation transcript:

Parallel Programming in Contemporary Programming Languages James Hoekzema

Why The optimal environment is not always available. Code needs to run on machines with different specs Operating System does not support certain libraries The environment is a restricted Virtual Machine Licensing for algorithms is not always cheap High end components are expensive “Fast Enough” is better than nothing at all

What JavaScript - Using parallel programming and concepts in the browser Go - Built-in features for parallelism beside and to scale a server LabVIEW - Graphical programming for smart compiler parallelism

JavaScript (in the Browser)

Why Networking is slow and unpredictable. Different providers, different regions, different services levels Connection is outside of your control Scaling servers is costly. On a server, more people connecting means slower service all around The user is providing computation power to you, use it! Much wider support than plugins like Java or Flash. Plugins require downloading, updating, loading up different virtual machines Browsers are less prone to versioning that affects performance

What Asynchronous Single-thread JS only runs when needed, so networking is nonblocking Tasks are put into a queue for execution during “downtime” Web Workers Simplified JS environment on another thread, uses message passing interface Can be bound to a webpage or to a domain (Shared Worker) Data is deep copied unless a buffer is specified which then transfers control WebGL Essentially OpenGL for a web page, runs on the Canvas Element Allows access to GPU computing (or at least accelerated Graphics Computing)

Example (Asynchronous) var fact = []; function ajax(method, url, callback) { //create request var xhr = new XMLHttpRequest(); //set callback function xhr.onload = function(){ callback(JSON.parse(xhr.responseText)); }; //specify request xhr.open(method, url); //send request xhr.send(); } function factorial(n) { if(n > 1){ return n * factorial(n - 1); }else{ return 1; ajax('GET', 'primes.json', function(primes){ //executes after factorial var result = 0; var len = Math.min(primes.length, fact.length); for(var i = 0; i < len; i++){ result += primes[i] / fact[i]; } console.log(result); }); //executes after request, before response for(var i = 0; i < 20; i++){ fact.push(factorial(i + 1)); primes: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, ...] fact: [1, 2, 6, 24, 120, 720, 5040, 40320, ...] ------------------------------------------------- result: 4.73863870268622

Example (Web Workers) Polynate var worker1 = new Worker('worker.js'); worker1.postMessage({ type: 'sum', data: [2, 3, 5, 7, 11, 13, 17, 19, 23] }); worker2.postMessage({ data: [29, 31, 37, 41, 43, 47, 53, 59] var sum = 0, count = 0; worker1.onmessage = worker2.onmessage = function(event) { count++; sum += event.data; if(count == 2){ console.log(sum); } //worker.js onmessage = function(event) { if(event.data.type == 'sum'){ postMessage(sum(event.data.data)); } //other parallel methods function sum(arr) { var len = arr.length, sum = 0; for(var i = 0; i < arr.length; i++){ sum += arr[i]; return sum; result: 440 Polynate

Example (WebGL)

Go (Golang)

Why Golang is built for Concurrency (and thus parallelism) Simply prefixing a function call with “go” spins up a new goroutine You can compile for different number of processors Many of the standard library features already support concurrency Golang’s Standard Library is well-suited for servers A simple server can be written in less than 10 lines of code Go makes JSON easily translatable into and out of data structures Go provides an intuitive templating engine

What “go <function call>” This call spins up a goroutine that can run on any processor or concurrently Not the same as MPI as it is not made for distributed computing Channels Channels allow you to pass data around between functions and routines Channels can have multiple access points, so you can have several routines “listening” on a channel and when data comes through, one will grab it and switch to being busy

Channels Routine 3 Routine 3 Routine 3 Routine 3 Main Routine 2 2. Main makes routines and passes them both channels 6. Routine 3 claims third piece of data, no longer listening 1. Main makes 2 channels, data and result Routine 3 Routine 3 Routine 3 Routine 3 data Main Routine 2 Routine 2 Routine 2 Routine 2 3. Main sends data over channel and listens to result channel Routine 1 Routine 1 Routine 1 Routine 1 4. Routine 1 claims first piece of data, no longer listening 5. Routine 2 claims second piece of data, no longer listening 8. Main receives and processes the results 7. The routines finish and send their results back on the result channel result

Example Code 1 4 27 package main import "fmt" func main() { data := make(chan int, 3) result := make(chan int, 3) go nToTheN(data, result) for n := 1; n < 4; n++ { data <- n } fmt.Println(<-result) func nToTheN(data chan int, result chan int) { n := <-data res := 1 for i := 0; i < n; i++ { res *= n } result <- res 1 4 27

LabVIEW

Why LabVIEW automatically parallelizes your code If you put two loops next to each other, LabVIEW runs them in parallel You can force parallelism in some places like for loops LabVIEW is built for instrumentation (particularly signal processing) You can read signals and process them at the same time without having to worry about delays or order LabVIEW comes with a graphical interface builder By default, every subVI has a “Front Panel” that shows controls and views

What Graph/Flowchart Based Programming Graphical programming where subVIs are connected by wires Independent parts of the graph/flowchart can thus be run simultaneously Physical Hardware Integration LabVIEW provides FPGA, GPU (CUDA), etc. subVIs to use in your code You can literally “draw” the structure, like a systolic array (grid)

Front Panel

Examples (Basic Parallelism) Execution of independent tasks Execution of independent branches Execution of parallel data operations

Example (Parallel loops and FPGA)

Example (Pipelining)

Questions? What languages would you like to see next time? Mobile/Tablet? Cloud? GPU? Go deeper on these 3?