CONCURRENT COLLECTIONS 2 5/24/11 Concurrent Collec9ons - - PowerPoint PPT Presentation

concurrent collections
SMART_READER_LITE
LIVE PREVIEW

CONCURRENT COLLECTIONS 2 5/24/11 Concurrent Collec9ons - - PowerPoint PPT Presentation

1 5/24/11 Concurrent Collec9ons CONCURRENT COLLECTIONS 2 5/24/11 Concurrent Collec9ons Acknowledgements Slides and material from Kathleen Knobe (Intel)


slide-1
SLIDE 1

CONCURRENT ¡COLLECTIONS ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

1 ¡

slide-2
SLIDE 2

Acknowledgements ¡

  • Slides ¡and ¡material ¡from ¡
  • Kathleen ¡Knobe ¡(Intel) ¡
  • Vivek ¡Sarkar ¡(Rice ¡University) ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

2 ¡

slide-3
SLIDE 3

CnC ¡– ¡Concurrent ¡Collec9ons ¡

  • Declara9vely ¡specify ¡the ¡computa9on ¡
  • And ¡the ¡ordering ¡constraints ¡
  • Parallelism ¡is ¡implicit ¡
  • Available ¡from ¡Intel ¡at ¡ ¡
  • hPp://soRware.intel.com/en-­‑us/ar9cles/intel-­‑concurrent-­‑

collec9ons-­‑for-­‑cc/ ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

3 ¡

slide-4
SLIDE 4

Two ¡Sources ¡of ¡Dependencies ¡

  • Data ¡Dependency ¡(Producer ¡Consumer) ¡
  • Consumer ¡of ¡a ¡data ¡cannot ¡execute ¡before ¡producer ¡has ¡

produced ¡the ¡data ¡

  • Control ¡Dependency ¡
  • Controllee ¡cannot ¡execute ¡unless ¡its ¡execu9on ¡is ¡determined ¡

as ¡necessary ¡by ¡the ¡Controller ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

4 ¡

slide-5
SLIDE 5

Three ¡Kinds ¡of ¡Collec9ons ¡

  • ( ¡Step ¡) ¡– ¡represents ¡computa9on ¡
  • [ ¡Item ¡] ¡– ¡represents ¡data ¡
  • < ¡Tag ¡> ¡– ¡represents ¡control ¡flow ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

5 ¡

slide-6
SLIDE 6

Dynamic ¡Instances ¡of ¡Collec9ons ¡

  • Mul9ple ¡instances ¡for ¡each ¡Step, ¡Item, ¡Tag ¡collec9ons ¡

at ¡run9me ¡

  • Each ¡instance ¡has ¡a ¡unique ¡Tag ¡
  • A ¡tag ¡is ¡a ¡tuple ¡of ¡values ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

6 ¡

slide-7
SLIDE 7

Item ¡Collec9on ¡

  • Each ¡(data) ¡item ¡instance ¡is ¡dynamically ¡wriPen ¡once ¡
  • Persists ¡in ¡the ¡‘tuple ¡space’ ¡forever ¡
  • Garbage ¡collec9on ¡is ¡implicit ¡
  • Each ¡step ¡instance ¡can ¡
  • Get() ¡mul9ple ¡item ¡instances ¡from ¡mul9ple ¡item ¡collec9ons ¡
  • Put() ¡mul9ple ¡item ¡instance ¡into ¡mul9ple ¡item ¡collec9ons ¡
  • Each ¡item ¡can ¡be ¡Get() ¡by ¡mul9ple ¡steps ¡instance ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

7 ¡

slide-8
SLIDE 8

Step ¡Collec9on ¡

  • Every ¡step ¡collec9on ¡is ¡“prescribed” ¡by ¡a ¡Tag ¡

collec9on ¡

  • An ¡step ¡instance ¡with ¡tag ¡T ¡can ¡execute ¡only ¡if ¡T ¡is ¡present ¡in ¡

the ¡prescribed ¡Tab ¡collec9on ¡

  • Each ¡(computa9on) ¡step ¡instance ¡is ¡of ¡the ¡form ¡
  • A ¡sequence ¡of ¡Item ¡Get()s ¡
  • Determins9c ¡side-­‑effect-­‑free ¡sequen9al ¡computa9on ¡
  • A ¡func9on ¡of ¡the ¡tag ¡and ¡data ¡items ¡read ¡
  • A ¡sequence ¡of ¡Item ¡Put()s ¡and ¡Tag ¡Put()s ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

8 ¡

slide-9
SLIDE 9

Tag ¡Collec9on ¡

  • Explicitly ¡specifies ¡the ¡control ¡flow ¡between ¡steps ¡
  • A ¡tag ¡collec9on ¡might ¡control ¡mul9ple ¡step ¡collec9ons ¡ ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

9 ¡

slide-10
SLIDE 10

Simple ¡Example ¡

5/24/11 ¡

  • Break ¡an ¡input ¡string ¡into ¡sequences ¡of ¡repeated ¡

characters ¡

  • Filter ¡only ¡strings ¡of ¡odd ¡length ¡

Concurrent ¡Collec9ons ¡

10 ¡

slide-11
SLIDE 11

Execu9on ¡Seman9cs ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

11 ¡

  • A ¡step ¡instance ¡becomes ¡“proscribed” ¡when ¡its ¡tag ¡is ¡available ¡
  • A ¡step ¡instance ¡becomes ¡“inputs ¡available” ¡when ¡all ¡its ¡Get()s ¡

can ¡succeed ¡

  • A ¡step ¡is ¡enabled ¡when ¡it ¡is ¡“proscribed” ¡and ¡“inputs ¡available” ¡ ¡
  • Enabled ¡steps ¡will ¡eventually ¡be ¡executed ¡
slide-12
SLIDE 12

Control ¡Tags ¡Follow ¡Data ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

12 ¡

slide-13
SLIDE 13

Graph ¡in ¡Textual ¡Form ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

13 ¡

// control tags <int singletonTag: singleton>; <int spanTags: spanID>; // data items [string input <int>: singleton]; [string span <int>: spanID]; [string results <int>: spanID]; // proscription relation <singletonTag> :: (createSpan); <spanTags> :: (processSpan); // program inputs and outputs env -> [input]; env -> <singletonTag>; [results] -> env; // producer/consumer relations [input: singleton] -> (createSpan: singleton)

  • > <spanTags: spanID>, [span: spanID];

[span] -> (processSpan) -> [results];

slide-14
SLIDE 14

Coordina9on ¡Separated ¡from ¡Code ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

14 ¡

int createSpan::execute(const int & t, partStr_context & c ) const { // Get input string string in; c.input.get(t, in); while (! in.empty()) { // construct span // … c.span.put(j, in.substr(j, len)); c.spanTags.put(j); // … } return CnC::CNC_Success; }

slide-15
SLIDE 15

Control ¡Separate ¡From ¡Data ¡

  • Face ¡detec9on ¡through ¡a ¡cascading ¡sequence ¡of ¡

classifiers ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

15 ¡

slide-16
SLIDE 16

Scheduling ¡Decisions ¡

  • When ¡to ¡execute ¡enabled ¡steps ¡instances ¡
  • Where ¡to ¡execute ¡enabled ¡step ¡instances ¡
  • Specula9vely ¡execute ¡steps ¡whose ¡inputs ¡are ¡available ¡
  • Based ¡on ¡availability ¡of ¡processor ¡resources ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

16 ¡

slide-17
SLIDE 17

Differences ¡Between ¡Linda ¡and ¡CnC ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

17 ¡

slide-18
SLIDE 18

Is ¡CnC ¡Determinis9c? ¡

  • For ¡a ¡given ¡input, ¡does ¡CnC ¡generate ¡the ¡same ¡
  • utput? ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

18 ¡

slide-19
SLIDE 19

Program ¡Termina9on ¡

  • A ¡CnC ¡program ¡terminates ¡when ¡ ¡
  • No ¡step ¡instance ¡is ¡execu9ng ¡
  • All ¡unexecuted ¡steps ¡are ¡not ¡enabled ¡
  • Valid ¡program ¡termina9on ¡
  • All ¡proscribed ¡steps ¡are ¡executed ¡
  • i.e. ¡A ¡proscribed ¡step ¡s9ll ¡wai9ng ¡for ¡an ¡input ¡data ¡ ¡error ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

19 ¡

slide-20
SLIDE 20

Garbage ¡Collec9on ¡

  • An ¡item ¡once ¡produced ¡logically ¡stays ¡forever ¡
  • Can ¡be ¡garbage ¡collected ¡when ¡no ¡future ¡step ¡instance ¡will ¡

issue ¡a ¡Get() ¡with ¡the ¡same ¡tag ¡

  • A ¡difficult ¡analysis ¡problem ¡
  • Current ¡implementa9on ¡
  • User ¡provides ¡a ¡getCount() ¡method ¡
  • Determines ¡the ¡number ¡of ¡steps ¡that ¡will ¡read ¡the ¡item ¡

5/24/11 ¡ Concurrent ¡Collec9ons ¡

20 ¡