Presentation is loading. Please wait.

Presentation is loading. Please wait.

Parallel Programming in Contemporary Programming Languages (Part 2)

Similar presentations


Presentation on theme: "Parallel Programming in Contemporary Programming Languages (Part 2)"— Presentation transcript:

1 Parallel Programming in Contemporary Programming Languages (Part 2)
James Hoekzema

2 Why Particular Environments leave little choice in the matter (Browsers) Less code, more work Less time learning the ins and outs, more time being productive Don’t reinvent the wheel

3 What JavaScript - Differences between browsers and the languages they allow Go - Goroutines versus threads: what’s the difference? LabVIEW - What’s under the hood and more on using multicore programming

4 JavaScript and Alternatives

5 Why JavaScript is not type checked, but some browsers can boost speed when it is written like it is. Always using callbacks for asynchronous tasks like requests and messaging can stack up. If a browser is setup to use another language, it can be faster due to the strictness of the language.

6 What Dart - A JS alternative by Google. Object oriented language with particular directives for asynchronous tasks. Can be run in Dartium (Fork of Chrome) and translated to JavaScript for cross-platform use. Also has it’s own VM and can be used to create Android and iOS apps. TypeScript - A JS alternative by Microsoft. Focuses on static type checking and easier object-oriented programming. Can be run in Internet Explorer / Edge (Sort of). Strong emphasis on scalability. Web Assembly - A new standard met to run beside JavaScript for significant speed improvements in areas that need it (heavy processing tasks such as image processing, etc.). Significant advantages: can program for it in “any” language (C/C++ currently supported) and can be run as it is streamed.

7 What - Web Workers Workers are OS level threads that run in a light JavaScript environment (no access to DOM mainly) Data passed between the page and the worker is deep copied, except for buffers. Buffers are a special data type in JS that represent byte arrays that can be interpreted as sized integers (signed and unsigned), or floats. Access to a buffer is only granted to the controlling thread, meaning a worker has to give back control to the page for the page to use the altered data.

8 What are Web Workers Good For?
Working. Offloading processes such as data crunching, data storage, etc. Safe Environment. Any script can be loaded into a worker, including scripts from other websites. This allows advanced number crunching scripts to be imported without risking an unsafe DOM for your website. Parallelization. You can spin up multiple workers and send them different data to work on.

9 Web Worker Measurements

10 The Future Since JavaScript is interpreted, the interpreter can always be improved to use more parallel algorithms. Web Assembly - a binary standard for the web that allows very fast execution as well as execution while streaming Smart “loop” parallelising (for functional concepts like mapping, filtering, etc.) Better latency hiding (HTTP Requests, Blobbing, etc.) Stream and Execute Stream (JS) Execution Complete Execution Start Server Client Server Client Server Client Client

11 Go (goroutines vs. threads)

12 Why Most programs and languages rely on pthreads underneath as well as operating systems. This means that scheduling is outside the control of the program. Goroutines are internally managed and much smaller by default compared to a default thread, meaning many more can be created and managed by Go. This is not that simple!

13 Where Goroutines Differ
Default Size of Thread: 2MB Default Size of Goroutine: 8KB Switching between goroutines occurs when Go thinks it’s best, not the operating system.

14 Performance Measure Go is MUCH faster than scripted languages (JavaScript, Python, etc.) Go is on par with Java and C++ in certains areas, and slower in others. Go is garbage collected like Java, but since it is a much younger, less invested in language, its collector is nowhere near as sophisticated. This does make it safer than C++ and C though. Benefits over Java: Compiled to machine code, not a VM. Several syntactic sugars. Less memory intensive, especially with arrays/lists. Internal concurrency management.

15 LabVIEW

16 The Process First Step: Type Propagation - Choosing correct nodes based off type (different int sizes, int vs. float, etc.), casting types when necessary, etc. Second Step: Convert to DFIR graph. Then transform for optimization and code generation. Third Step: Translated into LLVM (Low Level Virtual Machine)

17 Parallelism in Action Multicore Programming in LabVIEW

18 Questions?


Download ppt "Parallel Programming in Contemporary Programming Languages (Part 2)"

Similar presentations


Ads by Google