• No results found

High-Level Multicore Programming with XJava

N/A
N/A
Protected

Academic year: 2021

Share "High-Level Multicore Programming with XJava"

Copied!
20
0
0

Loading.... (view fulltext now)

Full text

(1)

Universität Karlsruhe (TH)

Forschungsuniversität · gegründet 1825

High-Level Multicore Programming

with XJava

Frank Otto

, Victor Pankratius, Walter F. Tichy

31st International Conference on Software Engineering (ICSE)

New Ideas and Emerging Results (NIER)

(2)

The Problem

Clock rates are stagnating

„The free lunch is over“

Multicore processors enter the mainstream

Multicore processors enter the mainstream

(3)

Motivation: A Parallelized

Object-Oriented Real-World Application

(4)

Multithreading and OO

Create and manage

threads manually

Synchronization is

difficult an error-prone

Deadlocks

difficult an error-prone

We need abstractions

for parallelism!

(5)

XJava‘s Goal

„What you see is what you get“ parallelism

More predictable

High-level programming

High-level programming

(6)

Idea

Combine the concepts from

object-orientation

,

parallel design patterns

, and

stream languages

Stream programs

Stream programs

Interconnected filters

Input: data stream of arbitrary length

(7)

XJava Tasks

Specialized methods that are concurrently

executable

Typed input and output ports for receiving and

Typed input and output ports for receiving and

generating streams of data

public Object => String foo() {

/* task body */

(8)

Task Declarations

public

void

=>

Block

read(File f) {

Iterator i = f.blockIterator();

while(i.hasNext()) {

push (Block) i.next();

}

}

(9)

Task Declarations

public

void

=>

Block

read(File f) {

Iterator i = f.blockIterator();

while(i.hasNext()) {

push (Block) i.next();

}

}

public

Block

=>

Block

compress() {

work(

Block b

) {

push b.compressBlock();

}

work(

Block b

) {

push b.compressBlock();

}

}

public

Block

=>

void

write(File f) {

work(

Block b

) { f.add(b);

/* no push */

}

}

A

work

-Block is repeatedly executed for each

incoming element of the input data stream

(10)

Pipe Statements

public

void

=>

Block

read(File f) {

Iterator i = f.blockIterator();

while(i.hasNext()) {

push (Block) i.next();

}

}

public

Block

=>

Block

compress() {

work(

Block b

) {

push b.compressBlock();

}

read(inFile) => compress() => write(outFile);

work(

Block b

) {

push b.compressBlock();

}

}

public

Block

=>

void

write(File f) {

work(

Block b

) { f.add(b);

/* no push */

}

}

(11)

Concurrent Statements

public void => void compress(File in, File out) {

read(in) => compress() => write(out);

compress(f1, f1out) ||| compress (f2, f2out);

read(in) => compress() => write(out);

}

(12)

Master/Worker

public void =>

Item

master() {

while (moreWork) { Item item = …

push item; }

}

public

Item

=> void worker() {

work(Item item) { … }

work(Item item) { … }

}

public

Item

=> void wPool(int i) {

worker():i; // create i workers

}

(13)

Master/Worker

public void => Item master() {

while (moreWork) { …

push item; }

}

public Item => void worker() {

work(Item i) { … }

master() => wPool(3);

work(Item i) { … }

}

public Item => void wPool(int i) {

worker():i; // create i workers

}

(14)

Master/Worker

public void => Item master() { while (moreWork) { …

push item; } }

public Item => void worker() { work(Item i) { … }

}

public Item => void wPool(int i) { worker():i; // create i workers }

master()

=>*

wPool(3); // broadcast

master()

=>

wPool(3); // round robin

master()

=>?

wPool(3); // FCFS

(15)

Divide & Conquer

Parallelism

Compare sequential and parallel MergeSort

void mergesort(int from, int to) {

if (to - from > threshold) {

int x = from + (to - from)/2;

int x = from + (to - from)/2;

mergesort(from, x);

mergesort(x + 1, to);

merge(from, x + 1, to);

}

else sort(from, to);

}

(16)

Divide & Conquer

Parallelism

Compare sequential and parallel MergeSort

void

mergesort(int from, int to) {

if (to - from > threshold) {

int x = from + (to - from)/2;

void => void

mergesort(int from, int to){

if (to - from > threshold) {

int x = from + (to - from)/2;

int x = from + (to - from)/2;

mergesort(from, x);

mergesort(x + 1, to);

merge(from, x + 1, to);

}

else sort(from, to);

}

int x = from + (to - from)/2;

mergesort(from, x)

||| mergesort(x + 1, to);

merge(from, x + 1, to);

}

else sort(from, to);

}

(17)

XJava Compiler and Runtime

XJava

program

Java

program

XJava

runtime

XJava

compiler

XJava runtime is the place where parallelism

actually happens

Java VM

OS scheduler

(18)

Preliminary Results

Up to 40% code savings

over threaded Java

Almost no manual synchronization needed

Good

speedups

over sequential Java

Good

speedups

over sequential Java

Up to 3.5

(Quadcore)

(19)

XJava: Conclusion

High-level parallel OO programming

Lower risk of synchonization bugs

Code savings, higher productivity

(20)

Thank you!

Questions?

Questions?

References

Related documents

As incomes rise, more people are likely to choose higher levels of healthcare for themselves and, given the relationship between income and private health insurance coverage, it

Data manipulation will involve clustering as well as Rapid Miner data exploration tools and functions are used to determine the expected distribution of demand or pressure points

understand the non-equilibrium carrier dynamics of hot electrons and holes in metal halide perovskites, in particular during intraband energy relaxation processes, in order to

In addition, the GC&N Committee is responsible for: (i) assessing the effectiveness of the Board, each of its committees and individual Trustees; (ii) overseeing

We split observa- tions into tertiles based on chemical concentrations then performed multivariable logistic regression analyses to explore associations between the concentrations

Drawing on a developmental psychopathology approach, these studies examine the specific ways in which adolescents use social media, the individual characteristics that may make

( 1 ) and compare with a numerical estimate obtained from the interaction energy between straight segments of the discretized dislocation line [ 21 ]. As shown in Fig. 1 , the

This study aims to determine the effect of administration of State Property, which consists of bookkeeping, inventory, and reporting on the optimization of fixed assets