Забыли?

?

# The Chapel Language

код для вставкиСкачать
```An Introduction to Chapel
compiled for Mary Hall, February 2006
Cray Inc.
What is Chapel?
пЃµ Overall goal: вЂњSolve the parallel programming problemвЂќ
вЂ“ simplify the creation of parallel programs
вЂ“ support their evolution to extreme-performance,
вЂ“ emphasize generality
пЃµ Motivating Language Technologies:
2) locality-aware programming
3) object-oriented programming
4) generic programming and type inference
Chapel (23)
Data Parallelism: Domains
пЃµ domain: an index set
вЂ“ specifies size and shape of вЂњarraysвЂќ
вЂ“ supports sequential and parallel iteration
вЂ“ potentially decomposed across locales
пЃµ Three main classes:
вЂ“ arithmetic: indices are Cartesian tuples
пЃµ rectilinear,
multidimensional
пЃµ optionally strided and/or sparse
вЂ“ indefinite: indices serve as hash keys
пЃµ supports
hash tables, associative arrays, dictionaries
пЃµ supports
sets, graph-based computations
вЂ“ opaque: indices are anonymous
пЃµ Fundamental Chapel concept for data parallelism
пЃµ A generalization of ZPLвЂ™s region concept
Chapel (25)
A Simple Domain Declaration
var m: integer = 4;
var n: integer = 8;
var D: domain(2) = [1..m, 1..n];
D
Chapel (26)
A Simple Domain Declaration
var m: integer = 4;
var n: integer = 8;
var D: domain(2) = [1..m, 1..n];
var DInner: domain(D) = [2..m-1, 2..n-1];
DInner
D
Chapel (27)
Domain Uses
пЃµ Declaring arrays:
var A, B: [D] float;
A
B
пЃµ Sub-array references:
A(DInner) = B(DInner);
пЃµ Sequential iteration:
for (i,j) in DInner { вЂ¦A(i,j)вЂ¦ }
or: for ij in DInner { вЂ¦A(ij)вЂ¦ }
1 2 3 4
7 8
D
пЃµ Parallel iteration:
forall ij in DInner { вЂ¦A(ij)вЂ¦ }
or: [ij in DInner] вЂ¦A(ij)вЂ¦
D
пЃµ Array reallocation:
D = [1..2*m, 1..2*n];
A
Chapel (28)
BDInner
B
5
6
9 10 11 12
Other Arithmetic Domains
var D2: domain(2) = (1,1)..(m,n);
D2
var StridedD: domain(D) = D by (2,3);
StridedD
var indexList: seq(index(D)) = вЂ¦;
var SparseD: sparse domain(D) = indexList;
SparseD
Chapel (29)
Indefinite Domains
var People: domain(string);
var Age: [People] integer;
var Birthdate: [People] string;
Age(вЂњjohnвЂќ) = 60;
Birthdate(вЂњjohnвЂќ) = вЂњ12/11/1943вЂќ;
вЂ¦
forall person in People {
if (Birthdate(person) == today) {
Age(person) += 1;
}
}
вЂњjohnвЂќ
People
Chapel (32)
60
вЂњ12/11/1943вЂќ
Age
Birthday
Opaque Domains
var Vertices: domain(opaque);
for i in (1..5) {
Vertices.new();
}
Vertices
var AV, BV: [Vertices] float;
AV
BV
Chapel (33)
Opaque Domains
var Vertices: domain(opaque);
var left, right: [Vertices] index(Vertices);
var root: index(Vertices);
root = Vertices.new();
left(root) = Vertices.new();
right(root) = Vertices.new();
left(right(root)) = Vertices.new();
root
conceptually:
root
Left
more precisely:
Vertices
Right
Chapel (34)
пЃµ co-begins: indicate statements that may run in parallel:
computePivot(lo, hi, data);
cobegin {
Quicksort(lo, pivot, data);
Quicksort(pivot, hi, data);
}
cobegin {
}
пЃµ atomic sections: support atomic transactions
atomic {
newnode.next = insertpt;
newnode.prev = insertpt.prev;
insertpt.prev.next = newnode;
insertpt.prev = newnode;
}
пЃµ sync and single-assignment variables: synchronize tasks
вЂ“ similar to Cray MTA C/Fortran
Chapel (35)
2) Locality-aware Programming
пЃµ locale: machine unit of storage and processing
пЃµ programmer specifies number of locales on executable
command-line
prompt> myChapelProg вЂ“nl=8
пЃµ Chapel programs provided with built-in locale array:
const Locales: [1..numLocales] locale;
пЃµ Users may use this to create their own locale arrays:
var CompGrid: [1..GridRows, 1..GridCols] locale = вЂ¦;
A
B
C
D
E
F
G
H
CompGrid
A
B
Chapel (36)
C
D
E
F
G
H
Data Distribution
пЃµ domains may be distributed across locales
var D: domain(2) distributed(Block(2) to CompGrid) = вЂ¦;
D
A
B
C
D
E
F
G
H
CompGrid
A
B
пЃµ Distributions specifyвЂ¦
вЂ¦mapping of indices to locales
вЂ¦per-locale storage layout of domain indices and
array elements
пЃµ Distributions implemented as a class hierarchy
вЂ“ Chapel provides a number of standard distributions
вЂ“ Users may also write their own
one of our biggest
challenges
Chapel (37)
Computation Distribution
пЃµ вЂњonвЂќ keyword binds computation to locale(s):
cobegin {
}
A
B
C
D
E
F
G
H
пЃµ вЂњonвЂќ can also be used in a data-driven manner:
forall (i,j) in D {
on B(j/2,i*2) do A(i,j) = foo(B(j/2,i*2));
}
foo()
A
Chapel (38)
B
A
B
C
D
E
F
G
H
CompGrid
Chapel Challenges
пЃµ User Acceptance
вЂ“ True of any new language
вЂ“ Skeptical audience
пЃµ Commodity Architecture Implementation
вЂ“ Chapel designed with idealized architecture in mind
вЂ“ Clusters are not ideal in many respects
вЂ“ Results in implementation and performance
challenges
вЂ“ Efficient user-defined domain distributions
вЂ“ Parallel Garbage Collection
пЃµ And many others as wellвЂ¦
Chapel (43)
Summary
пЃµ Chapel is being designed toвЂ¦
вЂ¦enhance programmer productivity
вЂ¦address a wide range of workflows
пЃµ Via high-level, extensible abstractions forвЂ¦
вЂ¦locality-aware programming
вЂ¦object-oriented programming
вЂ¦generic programming and type inference
пЃµ Status:
вЂ“ draft language specification available at:
http://chapel.cs.washington.edu
вЂ“ Open source implementation proceeding apace
вЂ“ User feedback desired
Chapel (46)
```
###### Документ
Категория
Презентации
Просмотров
4
Размер файла
1 244 Кб
Теги
1/--страниц
Пожаловаться на содержимое документа