Changes between Version 21 and Version 22 of OpenMPTransformation


Ignore:
Timestamp:
04/21/14 08:13:35 (12 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OpenMPTransformation

    v21 v22  
    4848}}}
    4949
    50 == Worksharing state ==
     50== Modeling shared variables ==
     51
     52For each shared variable `v` introduce a second variable `v_state`.  The type of `v_state` is obtained from the type of `v` by replacing all primitive types (leaf nodes in the type tree) by `int`.  Initially all these ints are -1.
     53
     54A write to (some part of) the shared variable by thread tid:
     55* if the state value is -1, set it to tid, then do the write
     56* if the state value is tid, do the write
     57* else report a data race.
     58
     59A read from (some part of) the shared variable by thread tid:
     60* if the state value is -1 or tid, do the read
     61* else report a data race.
     62
     63Translating `flush`of (some part of) the shared variable by thread tid:
     64* if the state value is -1: no-op
     65* if the state value is tid: set it to -1
     66* else: some other thread has some write to the variable which it hasn't flushed.  But this thread has not done any writes to that variable (since it last flushed).  This is a no-op.
     67
     68Function
     69{{{
     70  barrier_and_flush();
     71}}}
     72does a barrier on `_barrier` and a flush on all shared variables.
     73
     74
     75== Modeling worksharing state ==
    5176
    5277The worksharing state will be stored in another handle type object.  The situation here is analogous to the `$gcomm` and `$comm` use for MPI.  Those objects store the shared state for message-passing.    We need similar object for shared state the coordinates work-sharing and barrier constructs:
     
    99124
    100125
    101 == Translation Strategies ==
    102 
    103 
    104 === Translating shared variables ===
    105 
    106 For each shared variable `v` introduce a second variable `v_state`.  The type of `v_state` is obtained from the type of `v` by replacing all primitive types (leaf nodes in the type tree) by `int`.  Initially all these ints are -1.
    107 
    108 A write to (some part of) the shared variable by thread tid:
    109 * if the state value is -1, set it to tid, then do the write
    110 * if the state value is tid, do the write
    111 * else report a data race.
    112 
    113 A read from (some part of) the shared variable by thread tid:
    114 * if the state value is -1 or tid, do the read
    115 * else report a data race.
    116 
    117 Translating `flush`of (some part of) the shared variable by thread tid:
    118 * if the state value is -1: no-op
    119 * if the state value is tid: set it to -1
    120 * else: some other thread has some write to the variable which it hasn't flushed.  But this thread has not done any writes to that variable (since it last flushed).  This is a no-op.
    121 
    122 Function
    123 {{{
    124   barrier_and_flush();
    125 }}}
    126 does a barrier on `_barrier` and a flush on all shared variables.
     126== Translations of specific directives ==
    127127
    128128=== Translating `parallel` ===
     
    187187}
    188188}}}
     189
     190We vary the way the way iterators are chosen to explore different tradeoffs and strategies.  On one extreme, every kind of partition can be explored; on the other, some fixed strategy like round-robin with chunksize 1 can be used.  This only changes the definition of `$omp_ws_arrive_loop`, not the translation above.
    189191
    190192=== Translating `sections` ===
     
    350352* `omp_get_num_threads()` => `_nthreads`
    351353* `omp_get_thread_num()` => `_tid`
    352