Download - Concurrent Collections ( CnC )
![Page 1: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/1.jpg)
Concurrent Collections (CnC)
A programming model for parallel programming
1Dennis Kafura – CS5204 – Operating Systems
![Page 2: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/2.jpg)
Concurrent Collections
CnC
Dennis Kafura – CS5204 – Operating Systems 2
Kathleen KnobeIntel
![Page 3: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/3.jpg)
Concurrent Collections
Overview
Ideas Separate if an operation is executed from when that
operation is executed Focus on ordering constraints dictated by semantics of
application Programming languages usually bind these together
Overburdens development effort Limits implementation alternatives
Dynamic single assignment Use write-once values rather than variables (locations) Avoids issues of synchronization, overwriting, etc.
Dennis Kafura – CS5204 – Operating Systems 3
![Page 4: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/4.jpg)
Concurrent Collections
Overview Representations
Diagram (“whiteboard”) version and text formats Relationships between high level operations (steps)
Data dependencies (producer-consumer relationship) Control dependencies (controller-controllee relationship)
High level operations (steps) Purely functional Implemented in conventional programming language
Dennis Kafura – CS5204 – Operating Systems 4
Note: figure from presentation by Kathleen Knobe (Intel) and Vivek Sarkar (Rice)
![Page 5: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/5.jpg)
Concurrent Collections
Overview Advantages
Allows roles and expertise of domain expert and tuning expert to be differentiated and combined by allowing each to focus on the aspects of the computation related to their expertise.
Domain expert need not know about parallelism
Tuning expert need not know about domain
Dennis Kafura – CS5204 – Operating Systems 5
Note: figure from presentation by Kathleen Knobe (Intel) and Vivek Sarkar (Rice)
![Page 6: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/6.jpg)
Concurrent Collections
Overview
Advantages (cont.) Avoids specifying/reasoning/deducing which operations
can execute in parallel This is difficult to do Depends on architecture
Allows run-time support to be tailored for different architectures
Creates portability across different architectures
Dennis Kafura – CS5204 – Operating Systems 6
![Page 7: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/7.jpg)
Concurrent Collections
Basic Structures
Element CnC name Graphical form Textual form
computation step (foo)
data item [x]
control tag <T>
environment env
Dennis Kafura – CS5204 – Operating Systems 7
foo
T
x
![Page 8: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/8.jpg)
Concurrent Collections
Simple Example
Dennis Kafura – CS5204 – Operating Systems 8
“aaaffqqqmmmmmmm”
“aaa”
“ff”“qqq”
“mmmmmmm”
“aaa”
“qqq”
“mmmmmmm”
Produce odd length sequences of consecutive identical characters
span
string
![Page 9: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/9.jpg)
Concurrent Collections
Relations
Dennis Kafura – CS5204 – Operating Systems 9
span
string
producer consumer
prescriptive
![Page 10: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/10.jpg)
Concurrent Collections
Item Collections
Dennis Kafura – CS5204 – Operating Systems 10
[“aaaffqqqmmmmmmm” : 1]
span
string
Multiple item instances correspond to different values of the item kind Each instance is distinguished by a user-defined instance tag
[“aaa” :1,1]
[“qqq” : 1,3]
[“mmmmmmm” : 1,4]
input
[“aaa” :1,1]
[“ff” : 1,2][“qqq” : 1,3]
[“mmmmmmm” : 1,4]
spanresults
![Page 11: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/11.jpg)
Concurrent Collections
Step Collections
Dennis Kafura – CS5204 – Operating Systems 11
span
string
Multiple steps instances correspond to different instantiations of the code implementing the step
Each instance is distinguished by a user-defined instance tag
(createSpan : 1)
createSpan
(processSpan :1,1)(processSpan : 1,2)
(processSpan : 1,3)
(processSpan : 1,4)
processSpan
![Page 12: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/12.jpg)
Concurrent Collections
Tag Collections
Dennis Kafura – CS5204 – Operating Systems 12
span
string
Tag collections are sets of tags of the same type/structure as the step with which they are associated
<1>
<1,1>
<1,2><1,3><1,4>
spanTags
stringTags
![Page 13: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/13.jpg)
Concurrent Collections
Execution Semantics
Dennis Kafura – CS5204 – Operating Systems 13
[“qqq” : 1,3]
span
(processSpan : 1,3)
processSpan
<1,3>
spanTags
A step instance with a given tag will execute when
• a matching tag instance is present, and
• the step instances matching inputs are available
![Page 14: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/14.jpg)
Concurrent Collections
Semantics
When (S : t1) executes, if it produces [I, t2], then [I, t2] becomes available. When (S : t1) executes, if it produces <T: t2>, then <T, t2> becomes available. If <T> prescribes (S), when <T : t> is available then (S : t) becomes prescribed. If forall {I, t1] such that (S: t2) gets [I, t1]
[I,t1] is available // if all inputs of (S: t2) are available then (S: t2) is inputs-available.
If (S: t) is both inputs-available and prescribed then is its enabled.Any enabled step is ready to execute.
Dennis Kafura – CS5204 – Operating Systems 14
![Page 15: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/15.jpg)
Concurrent Collections
Semantics
Execution frontier: the set of instances that have any attributes and are not dead.
Program termination: no step is currently executing and no unexecuted step is currently enabled.
Valid program termination: a program terminates and all prescribed steps have executed.
Instances that are dead may be garbage collected. Note: parallel execution is possible but not mandated; thus
testing/debugging on a sequential machine is possible.
Dennis Kafura – CS5204 – Operating Systems 15
![Page 16: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/16.jpg)
Concurrent Collections
Sources of Parallelism
Dennis Kafura – CS5204 – Operating Systems 16
[“aaaffqqqmmmmmmm” : 1]
[“bbbxxxxxxffxxxxxyy” : 2]
span
string
(processSpan :1,1)
input
[“aaa” :1,1][“ff” : 1,2]
[“qqq” : 1,3]
[“ff” : 2,3]
span executing
[“bbb” : 2,1]
[“mmmmmmm” : 1,4]
[“xxxxxx” : 2, 2]
(processSpan :1,3)
(processSpan :2,2)
(processSpan : 2,3)
(createSpan : 2)
![Page 17: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/17.jpg)
Concurrent Collections
Textual Representation
Dennis Kafura – CS5204 – Operating Systems 17
<stringTags: int stringID>;<spanTags: int stringID, int spanID>;
[input: int stringID];[span: int stringID, int spanID];[results: int stringID, int spanID];
env -> [input], <stringTags>;[results], <spanTags> -> env;
span
string
![Page 18: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/18.jpg)
Concurrent Collections
Textual Representation
Dennis Kafura – CS5204 – Operating Systems 18
<stringTags> :: (createSpan);<spanTags> :: (processSpan);
[input: stringID] -> (createSpan: stringID);(createSpan: stringID) -> <spanTags: stringID, spanID>;(createSpan: stringID) -> [span: stringID, spanID];[span: stringID, spanID] -> (processSpan: stringID, spanID);(processSpan: stringID, spanID) -> [results: stringID, spanID];
span
string
![Page 19: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/19.jpg)
Concurrent Collections
Mechanics
Dennis Kafura – CS5204 – Operating Systems 19
Note: graphics from Kathleen Knobe (Intel), Vivek Sarkar (Rice), PLDI Tuturial, 2009
![Page 20: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/20.jpg)
Concurrent Collections
A coded step
Dennis Kafura – CS5204 – Operating Systems 20
int createSpan::execute(const int & t, partStr_context & c) const{ string in; c.input.get(t, in);
if(! in.empty()) { char ch – in[0]; int len = 0; unsigned int i=0; unsigned int j = 0; while (i < in.length()) { if (in[j] == ch) { i++; len++; } else { c.span.put(t, j, in.substr(j, len)); c.spanTags.put (t,j); ch = in[i]; len = 0; j = i; } } c.span.put(t, j, in.substr(j.len); c.spanTags,put(t, j); } return CnC::CNC_Success;}
![Page 21: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/21.jpg)
Concurrent Collections
Another Example
Dennis Kafura – CS5204 – Operating Systems 21
![Page 22: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/22.jpg)
Concurrent Collections
Patterns – steps in different collections
Dennis Kafura – CS5204 – Operating Systems 22
![Page 23: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/23.jpg)
Concurrent Collections
Patterns – steps in same collection
Dennis Kafura – CS5204 – Operating Systems 23
![Page 24: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/24.jpg)
Concurrent Collections
Performance
Dennis Kafura – CS5204 – Operating Systems 24
Acknowledgements: Aparna Chandramolishwaran, Rich Vuduc (Georgia Tech)
![Page 25: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/25.jpg)
Concurrent Collections
Performance
Dennis Kafura – CS5204 – Operating Systems 25
TBB implementation, 8-way Intel dual Xeon Harpertown SMP system.
![Page 26: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/26.jpg)
Concurrent Collections
Performance
Dennis Kafura – CS5204 – Operating Systems 26
Habenero-Java implementation, 8-way Intel dual Xeon Harpertown SMP system.
![Page 27: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/27.jpg)
Concurrent Collections
Performance
Dennis Kafura – CS5204 – Operating Systems 27
Acknowledgements: Aparna Chandramolishwaran, Rich Vuduc (Georgia Tech)
![Page 28: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/28.jpg)
Concurrent Collections
Performance
Dennis Kafura – CS5204 – Operating Systems 28
Input stream compression using “deduplication”
![Page 29: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/29.jpg)
Concurrent Collections
Memory management
Problem the lifetime of a produced (data) item is not clear the (data) item may be used by multiple steps some step using a (data) item may not exist yet Serious problem for long-running computations
Solution Declarative annotations (slicing annotations) added to
step implementations Indicates which (data) items will be read by the step Converted into reference counting procedures
Dennis Kafura – CS5204 – Operating Systems 29
![Page 30: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/30.jpg)
Concurrent Collections
Memory states
5 memory states Note: no transition from
FREE to ITEM Assumes step
implementation manages local stack and local heap correctly
Dennis Kafura – CS5204 – Operating Systems 30
![Page 31: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/31.jpg)
Concurrent Collections
Annotations
Dennis Kafura – CS5204 – Operating Systems 31
General form:(S: I) is in readers( [C: T]), constraints(I,T)
![Page 32: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/32.jpg)
Concurrent Collections
Conditions for removing an item
Dennis Kafura – CS5204 – Operating Systems 32
![Page 33: Concurrent Collections ( CnC )](https://reader036.vdocument.in/reader036/viewer/2022062411/56816693550346895dda7559/html5/thumbnails/33.jpg)
Concurrent Collections
Performance
Memory usage did not vary with number of cores Optimal (running time) tile size was 125 (for above case) Memory savings a factor of 7 In other cases, memory savings a factor of 14
Dennis Kafura – CS5204 – Operating Systems 33