<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Amahaba</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Amahaba"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Amahaba"/>
	<updated>2026-05-21T16:05:21Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Wiki_invalidate_states.jpg&amp;diff=74408</id>
		<title>File:Wiki invalidate states.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Wiki_invalidate_states.jpg&amp;diff=74408"/>
		<updated>2013-03-27T18:19:48Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Wiki_invalidate_bus.jpg&amp;diff=74407</id>
		<title>File:Wiki invalidate bus.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Wiki_invalidate_bus.jpg&amp;diff=74407"/>
		<updated>2013-03-27T18:17:34Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74406</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74406"/>
		<updated>2013-03-27T18:14:48Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Cache Coherence Protocols on Real Architectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Wiki_first_shared.jpg‎]]&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Figure 1.  Multiple Caches of Shared Resource'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor.&lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Advantages of Write Update Protocol ====&lt;br /&gt;
The simplest, most obvious and fastest. &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Wiki_first_shared.jpg&amp;diff=74405</id>
		<title>File:Wiki first shared.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Wiki_first_shared.jpg&amp;diff=74405"/>
		<updated>2013-03-27T18:13:58Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Diags.png&amp;diff=74360</id>
		<title>File:Diags.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Diags.png&amp;diff=74360"/>
		<updated>2013-03-22T16:19:16Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Invalid1.png&amp;diff=74359</id>
		<title>File:Invalid1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Invalid1.png&amp;diff=74359"/>
		<updated>2013-03-22T16:18:56Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74346</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74346"/>
		<updated>2013-03-21T18:32:57Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Cache Coherence Protocols on Real Architectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Shared memory.jpg]]&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Figure 1.  Multiple Caches of Shared Resource'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor.&lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Advantages of Write Update Protocol ====&lt;br /&gt;
The simplest, most obvious and fastest. &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74345</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74345"/>
		<updated>2013-03-21T18:32:22Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Cache Coherence Protocols on Real Architectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Shared memory.jpg]]&lt;br /&gt;
'''Figure 1.  Multiple Caches of Shared Resource'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor.&lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Advantages of Write Update Protocol ====&lt;br /&gt;
The simplest, most obvious and fastest. &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74332</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74332"/>
		<updated>2013-03-21T04:29:20Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Quiz */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File: Shared memory.jpg| 400px | center | Multiple Caches of Shared Resource]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
Advantages : &lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor. &lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advantages of Write Update Protocol:&lt;br /&gt;
The simplest, most obvious and fastest, &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability&lt;br /&gt;
&lt;br /&gt;
Disadvantages&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74331</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74331"/>
		<updated>2013-03-21T04:28:42Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File: Shared memory.jpg| 400px | center | Multiple Caches of Shared Resource]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
Advantages : &lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor. &lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advantages of Write Update Protocol:&lt;br /&gt;
The simplest, most obvious and fastest, &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability&lt;br /&gt;
&lt;br /&gt;
Disadvantages&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74330</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74330"/>
		<updated>2013-03-21T04:28:05Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File: Shared memory.jpg| 400px | center | Multiple Caches of Shared Resource]]&lt;br /&gt;
&amp;lt;left&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/left&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
Advantages : &lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor. &lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advantages of Write Update Protocol:&lt;br /&gt;
The simplest, most obvious and fastest, &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability&lt;br /&gt;
&lt;br /&gt;
Disadvantages&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74329</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74329"/>
		<updated>2013-03-21T04:27:49Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File: Shared memory.jpg| 400px | left | Multiple Caches of Shared Resource]]&lt;br /&gt;
&amp;lt;left&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/left&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
Advantages : &lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor. &lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advantages of Write Update Protocol:&lt;br /&gt;
The simplest, most obvious and fastest, &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability&lt;br /&gt;
&lt;br /&gt;
Disadvantages&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74328</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74328"/>
		<updated>2013-03-21T04:27:03Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File: Shared memory.png | 400px | left | Multiple Caches of Shared Resource]]&lt;br /&gt;
&amp;lt;left&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/left&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
Advantages : &lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor. &lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advantages of Write Update Protocol:&lt;br /&gt;
The simplest, most obvious and fastest, &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability&lt;br /&gt;
&lt;br /&gt;
Disadvantages&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74327</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74327"/>
		<updated>2013-03-21T04:24:44Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Shared memory.png | 400px | left | Multiple Caches of Shared Resource]]&lt;br /&gt;
&amp;lt;left&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/left&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
Advantages : &lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor. &lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advantages of Write Update Protocol:&lt;br /&gt;
The simplest, most obvious and fastest, &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability&lt;br /&gt;
&lt;br /&gt;
Disadvantages&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74326</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74326"/>
		<updated>2013-03-21T04:23:10Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;left&amp;gt;[[File:Shared_memory.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/left&amp;gt;&lt;br /&gt;
&amp;lt;left&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/left&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
Advantages : &lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor. &lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advantages of Write Update Protocol:&lt;br /&gt;
The simplest, most obvious and fastest, &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability&lt;br /&gt;
&lt;br /&gt;
Disadvantages&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74325</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74325"/>
		<updated>2013-03-21T04:21:54Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Cache Coherence Protocols on Real Architectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;left&amp;gt;[[Image:Shared_memory.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/left&amp;gt;&lt;br /&gt;
&amp;lt;left&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/left&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
== Invalidation Coherence Protocols ==&lt;br /&gt;
Invalidate all remote copies of cache when a local cache block is updated. Under the invalidation scheme, updates are only propagated when data are read, and several updates can take place before communication is necessary. In the multiple-reader-single-write scheme described, this is potentially expensive. But, if the read/write ratio is sufficiently high, then the parallelism obtained by allowing multiple simultaneous readers offsets this cost. However, for multiple read after write command, there would be continuous misses and subsequent fetches for those misses. &lt;br /&gt;
&lt;br /&gt;
=== Write-Through Write Invalidate Caches ===&lt;br /&gt;
The state of a cache block copy of local processor can take one of the two&lt;br /&gt;
states :&lt;br /&gt;
Valid State:&lt;br /&gt;
All processors can read safely. The cache block is valid and clean, i.e. the cached value is the same as that at a lower memory level&lt;br /&gt;
Local processor can also write&lt;br /&gt;
Invalid State: (not in cache)&lt;br /&gt;
Block being invalidated.&lt;br /&gt;
Block being replaced&lt;br /&gt;
Any requests to the cache block will result into cache misses.&lt;br /&gt;
The requests are:&lt;br /&gt;
PrRd (Processor-Read) - processor-side request to read data from a cache block&lt;br /&gt;
PrWr (Processor-Write) - request sent when processor wants to write into a cache block&lt;br /&gt;
The Snooped Bus requests are:&lt;br /&gt;
BusRd (Bus-Read) - When request that indicates there is a read request to a block made by a processor&lt;br /&gt;
BusWr (Bus-Write) - Request that indicates there is a write request to a block made by a processor. In case of a write-through cache, the BusWr is a write-through to the main memory performed by another processor.&lt;br /&gt;
In the beginning the state of the cache block is Invalid state. If a &lt;br /&gt;
When a remote processor writes to its cache copy, all other cache copies become invalidated. When there is a processor-side read request, the processor suffers a cache miss. This results in a BusRd request on the bus. The memory block is fetched from main memory. The block goes to the valid state. When there is a PrWr request, then a BusWr command is sent on bus. Other caches that have the block invalidate their copy. The main memory (write-through) loads the correct value into the requested cache. Therefore, the state remains invalid.&lt;br /&gt;
For the case, when the block is the valid state, on a PrRd, it is a cache hit since the block resides in the cache. The state remains valid. On a PrWr, if there is a cache hit, that means, no other cache block resides. Thus no bus snooping protocol has to be sent.&lt;br /&gt;
On a BusRd, a cache block in the valid state remains in the valid state. While a block in the invalid state remains in the invalid state. &lt;br /&gt;
On a BusWr, a cache block in the valid state gets into the invalid state and an invalid block remain in the invalid state. &lt;br /&gt;
&lt;br /&gt;
Advantages : &lt;br /&gt;
A processor can modify a cache block by invalidating other copies in other caches. Thus cache block that is being modifies resides only in one cache giving exclusive membership to that processor. &lt;br /&gt;
&lt;br /&gt;
=== Write Back Write Invalidate caches ===&lt;br /&gt;
• Processor / Cache Operations&lt;br /&gt;
 PrRd, PrWr, block Replace &lt;br /&gt;
States&lt;br /&gt;
 Invalid, Valid (clean) - same as above&lt;br /&gt;
 Modified (dirty) - A block that is valid and has value written into; thus, is different from the one in main memory&lt;br /&gt;
&lt;br /&gt;
• Bus Transactions&lt;br /&gt;
 Bus Read (BusRd), Write-Back (BusWB)&lt;br /&gt;
 &lt;br /&gt;
Write-through Advantages :&lt;br /&gt;
When a processor continuously writes into the same cache block, only a single command is used to invalidate the cache blocks&lt;br /&gt;
Disadvantage :&lt;br /&gt;
requires a high amount of bandwidth.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Advantages of Write Update Protocol:&lt;br /&gt;
The simplest, most obvious and fastest, &lt;br /&gt;
Also, for a bandwidth-restricted architecture, using write back caches does not prevent scalability&lt;br /&gt;
&lt;br /&gt;
Disadvantages&lt;br /&gt;
•	Multiple writes to the same word (no intervening read) need only one invalidate message but would require an update for each&lt;br /&gt;
•	Writes to same block in (usual) multi-word cache block require only one invalidate but would require multiple updates. Due to both spatial and temporal locality, previous cases occur often.&lt;br /&gt;
•	Bus bandwidth is a precious commodity in shared memory multi-processors&lt;br /&gt;
•	Experience has shown that invalidate protocols use significantly less bandwidth&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74131</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74131"/>
		<updated>2013-03-21T01:04:35Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Subblock states */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Subblock states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''':  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
'''Dirty''': The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74130</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74130"/>
		<updated>2013-03-21T01:03:34Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Subblock protocol */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Block states'''&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
Invalid:  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
Clean Shared: A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
Dirty Shared: The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
Dirty: The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74129</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74129"/>
		<updated>2013-03-21T01:03:04Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Block states */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
** Block states&lt;br /&gt;
&lt;br /&gt;
'''Invalid''': All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
'''Valid Exclusive''': All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
'''Clean Shared''': The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
'''Dirty Shared''': Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
Invalid:  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
Clean Shared: A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
Dirty Shared: The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
Dirty: The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74128</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74128"/>
		<updated>2013-03-21T01:01:50Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Adaptive Coherence Protocols */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
Invalid: All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
Valid Exclusive: All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
Clean Shared: The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
Dirty Shared: Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
Invalid:  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
Clean Shared: A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
Dirty Shared: The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
Dirty: The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74127</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74127"/>
		<updated>2013-03-21T00:56:36Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Adaptive Coherence Protocols */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
Invalid: All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
Valid Exclusive: All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replacement.&lt;br /&gt;
&lt;br /&gt;
Clean Shared: The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
Dirty Shared: Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
Invalid:  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
Clean Shared: A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
Dirty Shared: The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
Dirty: The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
Suppose invalidation ratio (R) = 5&lt;br /&gt;
Current threshold block (Tb) = 3&lt;br /&gt;
If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
Tb will be 2. (Decreased)&lt;br /&gt;
So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74120</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74120"/>
		<updated>2013-03-20T23:54:29Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Cache Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74119</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74119"/>
		<updated>2013-03-20T23:51:28Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Firefly Protocol */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory). The following states can be assigned to a block in this protocol.&lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74118</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74118"/>
		<updated>2013-03-20T23:50:02Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Firefly Protocol */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
Firefly protocol is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74117</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74117"/>
		<updated>2013-03-20T23:49:17Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Firefly Protocol */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the  Dragon Protocol, it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74116</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74116"/>
		<updated>2013-03-20T23:48:18Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Dragon Protocol */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation). It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74115</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74115"/>
		<updated>2013-03-20T23:45:52Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Dragon Protocol */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states and does not include an invalidation state.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid. However,it can differ from main memory. Below are the finite state machines for the processor-side calls and bus-side calls. Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors.&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74114</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74114"/>
		<updated>2013-03-20T23:41:06Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Dragon Protocol */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
Dragon protocol saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74113</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74113"/>
		<updated>2013-03-20T23:40:11Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidate data and thus not resulting in a cache miss.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage. The update-based protocols we will be discussing in this section are&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74112</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74112"/>
		<updated>2013-03-20T23:34:15Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74111</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74111"/>
		<updated>2013-03-20T23:32:48Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Update and Adaptive Coherence Protocols on Real Architectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol. We shall discuss all three below.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74110</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74110"/>
		<updated>2013-03-20T23:32:09Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Invalidation Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74109</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74109"/>
		<updated>2013-03-20T23:30:58Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Update and Adaptive Coherence Protocols on Real Architectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994 doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent.One of the drawbacks of an invalidation-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type of protocol called adaptive coherence protocol.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74108</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74108"/>
		<updated>2013-03-20T23:28:51Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Update and Adaptive Coherence Protocols on Real Architectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994&lt;br /&gt;
doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;, invalidation based and update based. &lt;br /&gt;
&lt;br /&gt;
Invalidation based protocol will purge the copies of the line from the other caches which results in a single copy of the line whereas updating forwards the write value to the other caches, after which all caches are consistent&amp;quot;&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
One of the drawbacks of an invalidate-based protocol is that it incurs high number of coherence misses. To solve this, one can use a update coherence protocol, or a new type protocol called adaptive coherence protocol.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Cache_Coherency_Generic.png&amp;diff=74104</id>
		<title>File:Cache Coherency Generic.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Cache_Coherency_Generic.png&amp;diff=74104"/>
		<updated>2013-03-20T23:14:04Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: uploaded a new version of &amp;amp;quot;File:Cache Coherency Generic.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74103</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74103"/>
		<updated>2013-03-20T23:10:53Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Update and Adaptive Coherence Protocols on Real Architectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are two ways to maintain cache consistency&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994&lt;br /&gt;
doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt;. These are invalidation and update. The difference is that invalidation will &amp;quot;... purges the copies of the line &lt;br /&gt;
from the  other caches which results in a single copy of the line, and updating forwards the write value to  the other caches, after which all caches are consistent&amp;quot;&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  Since we have already talked about invalidation protocols, we will focus on update protocols.  However, now there has been a new type of adaptive coherence protocols and that will also be discussed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to Solihin textbook, page number 229, &amp;quot;One of the drawbacks of an invalidate-based protocol is that it incurs high number of coherence misses.&amp;quot;  What this means is that when a read has been made to an invalidated block, there will be a cache miss and serving this miss can create a high latency.  To solve this, one can use a update coherence protocol, or an adaptive coherence protocol.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74102</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74102"/>
		<updated>2013-03-20T23:07:08Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Update and Adaptive Coherence Protocols on Real Architectures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, [http://en.wikipedia.org/wiki/Cache_coherence '''cache coherence'''] refers to the consistency of data that is stored throughout the caches on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to &amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994&lt;br /&gt;
doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt; there are two ways to maintain cache consistency.  These are invalidation and update.  The difference is that invalidation will &amp;quot;... purges the copies of the line &lt;br /&gt;
from the  other caches which results in a single copy of the line, and updating forwards the write value to  the other caches, after which all caches are consistent&amp;quot;&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  Since we have already talked about invalidation protocols, we will focus on update protocols.  However, now there has been a new type of adaptive coherence protocols and that will also be discussed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to Solihin textbook, page number 229, &amp;quot;One of the drawbacks of an invalidate-based protocol is that it incurs high number of coherence misses.&amp;quot;  What this means is that when a read has been made to an invalidated block, there will be a cache miss and serving this miss can create a high latency.  To solve this, one can use a update coherence protocol, or an adaptive coherence protocol.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74096</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74096"/>
		<updated>2013-03-20T23:01:47Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, '''cache coherence''' refers to the consistency of data that is stored throughout the [http://en.wikipedia.org/wiki/Cache_(computing) caches] on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to &amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994&lt;br /&gt;
doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt; there are two ways to maintain cache consistency.  These are invalidation and update.  The difference is that invalidation will &amp;quot;... purges the copies of the line &lt;br /&gt;
from the  other caches which results in a single copy of the line, and updating forwards the write value to  the other caches, after which all caches are consistent&amp;quot;&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  Since we have already talked about invalidation protocols, we will focus on update protocols.  However, now there has been a new type of adaptive coherence protocols and that will also be discussed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to Solihin textbook, page number 229, &amp;quot;One of the drawbacks of an invalidate-based protocol is that it incurs high number of coherence misses.&amp;quot;  What this means is that when a read has been made to an invalidated block, there will be a cache miss and serving this miss can create a high latency.  To solve this, one can use a update coherence protocol, or an adaptive coherence protocol.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74091</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74091"/>
		<updated>2013-03-20T22:52:56Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Adaptive Coherence Protocols */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction to Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, '''cache coherence''' refers to the consistency of data that is stored throughout the [http://en.wikipedia.org/wiki/Cache_(computing) caches] on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to &amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994&lt;br /&gt;
doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt; there are two ways to maintain cache consistency.  These are invalidation and update.  The difference is that invalidation will &amp;quot;... purges the copies of the line &lt;br /&gt;
from the  other caches which results in a single copy of the line, and updating forwards the write value to  the other caches, after which all caches are consistent&amp;quot;&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  Since we have already talked about invalidation protocols, we will focus on update protocols.  However, now there has been a new type of adaptive coherence protocols and that will also be discussed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to Solihin textbook, page number 229, &amp;quot;One of the drawbacks of an invalidate-based protocol is that it incurs high number of coherence misses.&amp;quot;  What this means is that when a read has been made to an invalidated block, there will be a cache miss and serving this miss can create a high latency.  To solve this, one can use a update coherence protocol, or an adaptive coherence protocol.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Subblock protocol===&lt;br /&gt;
This snoopy-based protocol mitigate the features of  [http://en.wikipedia.org/wiki/MESI_protocol Illinois MESI protocol] and write policies with subblock validation to take the advantages of both small and large cache block size by using subblock.  &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
=====Block states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt; All subblocks are invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Valid Exclusive:&amp;lt;/b&amp;gt; All valid subblocks in this block are not present in any other caches. All subblocks that are clean shared may be written without a bus &amp;lt;dd&amp;gt;transaction. Any subblocks in the block may be invalid. There also may be Dirty blocks which must be written back upon replesment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; The block contains subblocks that are either Clean Shares or Invalid. The block can be replaced without a bus transaction.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; Subblocks in this block may be in any state. There may be Dirty blocks which must be written back on replacement.&amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of block/ line states is as follows:'''&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;center&amp;gt; [[File:line_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Finite state diagram of block''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Subblock states=====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Invalid:&amp;lt;/b&amp;gt;  The subblock is invalid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Clean Shared:&amp;lt;/b&amp;gt; A read access to the block will succeed. Unless the block the subblock is a part of is in the Valid Exclusive state, a write to the subblock will force an invalidation transaction on the bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty Shared:&amp;lt;/b&amp;gt; The subblock is treated like a Clean Shared sbublock, except that it must be written back on replacement. At most one cache will have a given subblock in either the Dirty Shared or Dirty state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dd&amp;gt; &amp;lt;b&amp;gt;Dirty:&amp;lt;/b&amp;gt; The subblocks is exclusive to this cache. It must be written back on replacement. Read and write access to this subblock hit with no bus transaction.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Finite state diagram of subblock is as follows:''' &lt;br /&gt;
&amp;lt;center&amp;gt;[[File:subblock_protocol.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Finite state diagram of Sub-block''' &amp;lt;/center&amp;gt; &lt;br /&gt;
   &lt;br /&gt;
Basic idea of this protocol is to do more data transfer between caches and less off-chip memory access.&lt;br /&gt;
In contrast with Illinois protocol, on read misses, shared cache block sends cached sublock and also all other clean and dirty shared subblockes in that block. &lt;br /&gt;
If the subblock is in the main memory, cache snooper pass the information of caches subblocks and memory will provide the requested subblock along with sublocks which are not currently cached.&lt;br /&gt;
On write to clean subblockes and write misses, snooper invalidates only the subblock to be written to avoid the penalties associated with false sharing.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;In contrast to the Illinois MESI Protocol, which requires extra power cycle to maintain the extra states and additional logic, the subblock protocol reduces number of cache blocks, compared to any cache update protocols, and thus reduces power consumption.. &amp;lt;/b&amp;gt; &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Read-snarfing protocol===&lt;br /&gt;
This is an enhancement to snoopy-cache coherence protocols that takes advantage of the inherent broadcast nature of the bus.&lt;br /&gt;
&lt;br /&gt;
In contrast with MESI protocol, if one processor wants to reload data in its cache due cache miss, read-snarfing protocol will effectively supply the block to other processors whose blocks were invalidated in the past. Only one read is required to restore the block to all caches which are invalidated.&lt;br /&gt;
&lt;br /&gt;
Protocol modifies the normal updated protocol by updating only those sub-blocks which are modified and update only need to broadcast when the data is actively shared. &lt;br /&gt;
Read-snarfing protocol maintains a counter and invalidation threshold (Tb) for each cache block “b” to overcome the drawback of WI’s write after read problem. Protocol predicts the number of write operations happens on a single cache block before a read request to the same cache block. Invalidation request is being broadcasted when the write counter reaches the Tb and protocol dynamically adjust the value of Tb based on the nature of program execution. &lt;br /&gt;
&lt;br /&gt;
Simple algorithm of Read-snarfing Random Walk protocol is as follows:&lt;br /&gt;
Initially Tb of each cache block b is set to 0. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Number of Write operation happens before being accessed by other processor&lt;br /&gt;
 If (most recent write run  &amp;gt;  R) {	&lt;br /&gt;
     If(Tb &amp;gt; 1) {	&lt;br /&gt;
	Tb--;&lt;br /&gt;
     }&lt;br /&gt;
} else {&lt;br /&gt;
     If(R &amp;gt; Tb) {&lt;br /&gt;
	Tb++;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = Invalidation Ratio which is (Ci + Cr) / Cu&lt;br /&gt;
Ci:  The cost in bus cycles of an invalidation transaction&lt;br /&gt;
Cu: The cost in bus cycles of an update transaction&lt;br /&gt;
Cr:  The cost in bus cycles of reading a cache block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block will be invalidated immediately with no wasted updates when Threshold reduces to 0.  &lt;br /&gt;
When block is actively shared, block is not invalidated by adjusting the Tb upward. &amp;lt;ref&amp;gt;[http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;ved=0CCIQFjAA&amp;amp;url=ftp%3A%2F%2Fftp.cs.washington.edu%2Ftr%2F1994%2F05%2FUW-CSE-94-05-02.PS.Z&amp;amp;ei=2n9kT8gjhPDSAaO2nb4P&amp;amp;usg=AFQjCNFFRgsJiBWjKAMOHcGcRL_vkkSqLg&amp;amp;sig2=aYWddXJdXsNNIFQ5U4zoqg Two techniques for improving performance on bus-based mu1tiprocessors]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;dl&amp;gt;&lt;br /&gt;
&amp;lt;dd&amp;gt;&lt;br /&gt;
=====Example 1 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Suppose invalidation ratio (R) = 5&lt;br /&gt;
&amp;lt;dd&amp;gt;Current threshold block (Tb) = 3&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 4 times before it is accessed by other processor, according to the above logic, Tb will be 4.&lt;br /&gt;
&amp;lt;dd&amp;gt;This means Tb is at the best possible value and only update can be issues.&lt;br /&gt;
&lt;br /&gt;
=====Example 2 =====&lt;br /&gt;
&amp;lt;dd&amp;gt;Consider, R= 5 and Tb = 3 for a particular block&lt;br /&gt;
&amp;lt;dd&amp;gt;If the processor writes 10 times before it is accessed by other processor&lt;br /&gt;
&amp;lt;dd&amp;gt;Tb will be 2. (Decreased)&lt;br /&gt;
&amp;lt;dd&amp;gt;So the protocol can incur a cost of 2 updates, 1 invalidate and 1 reread.&lt;br /&gt;
&amp;lt;dd&amp;gt;After 2 more write, Tb will be 0 and invalidation will occur immediately. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/dl&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74075</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74075"/>
		<updated>2013-03-20T22:39:44Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Quiz */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction to Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, '''cache coherence''' refers to the consistency of data that is stored throughout the [http://en.wikipedia.org/wiki/Cache_(computing) caches] on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to &amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994&lt;br /&gt;
doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt; there are two ways to maintain cache consistency.  These are invalidation and update.  The difference is that invalidation will &amp;quot;... purges the copies of the line &lt;br /&gt;
from the  other caches which results in a single copy of the line, and updating forwards the write value to  the other caches, after which all caches are consistent&amp;quot;&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  Since we have already talked about invalidation protocols, we will focus on update protocols.  However, now there has been a new type of adaptive coherence protocols and that will also be discussed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to Solihin textbook, page number 229, &amp;quot;One of the drawbacks of an invalidate-based protocol is that it incurs high number of coherence misses.&amp;quot;  What this means is that when a read has been made to an invalidated block, there will be a cache miss and serving this miss can create a high latency.  To solve this, one can use a update coherence protocol, or an adaptive coherence protocol.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
Question 1 : What write protocol is used in the Dragon Protocol?&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
Question 2 : How does the Dragon Protocol save on bandwidth?&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
Question 3 : How are the states different for Dragon protocol than MOESI protocol?&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
Question 4 : Why do update-based protocols not require a invalidation state?&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 5 : Which of the following is NOT true of the states in the Firefly protocol?&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
Question 6 : What are two adaptive protocols?&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
Question 8 : What is the major drawback for adaptive protocols?&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
Question 9 : What is not a sub-protocol of Cachet?&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
Question 10 : What is the basis for Cachet protocol?&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74047</id>
		<title>CSC/ECE 506 Spring 2013/8b ap</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/8b_ap&amp;diff=74047"/>
		<updated>2013-03-20T22:08:12Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction to Update and Adaptive Coherence Protocols on Real Architectures=&lt;br /&gt;
&lt;br /&gt;
In parallel computer architectures, '''cache coherence''' refers to the consistency of data that is stored throughout the [http://en.wikipedia.org/wiki/Cache_(computing) caches] on individual processors or throughout the shared memory.  The problem here is that we have multiple caches on multiple processors.  When an update to a single cache makes changes to a shared memory, you will need to have all the caches be coherent on the value change.  This is better shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:Cache Coherency Generic.png|400px| Multiple Caches of Shared Resource]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 1.  Multiple Caches of Shared Resource''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to &amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;Glasco, D.B.; Delagi, B.A.; Flynn, M.J.; , &amp;quot;Update-based cache coherence protocols for scalable shared-memory multiprocessors,&amp;quot; System Sciences, 1994. Proceedings of the Twenty-Seventh Hawaii International Conference on , vol.1, no., pp.534-545, 4-7 Jan. 1994&lt;br /&gt;
doi: 10.1109/HICSS.1994.323135&lt;br /&gt;
[http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;amp;arnumber=323135&amp;amp;isnumber=7709 Paper]&amp;lt;/ref&amp;gt; there are two ways to maintain cache consistency.  These are invalidation and update.  The difference is that invalidation will &amp;quot;... purges the copies of the line &lt;br /&gt;
from the  other caches which results in a single copy of the line, and updating forwards the write value to  the other caches, after which all caches are consistent&amp;quot;&amp;lt;ref name=&amp;quot;glasco&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  Since we have already talked about invalidation protocols, we will focus on update protocols.  However, now there has been a new type of adaptive coherence protocols and that will also be discussed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to Solihin textbook, page number 229, &amp;quot;One of the drawbacks of an invalidate-based protocol is that it incurs high number of coherence misses.&amp;quot;  What this means is that when a read has been made to an invalidated block, there will be a cache miss and serving this miss can create a high latency.  To solve this, one can use a update coherence protocol, or an adaptive coherence protocol.&lt;br /&gt;
&lt;br /&gt;
==Update Coherence Protocol==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Update-based cache coherence protocols work by directly updating all the cache values in the system.  This differs from the invalidation-based protocols because it achieves write propagation without having to invalidation and misses.  This saves on numerous coherence misses, time spent to correct the miss, and bandwidth usage.  The update-based protocols we will be discussing in this section are the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] and the [http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol].&lt;br /&gt;
&lt;br /&gt;
===Dragon Protocol===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol] is an implementation of update-based coherence protocol.  It further saves on bandwidth by updating the specific words within the cache instead of the entire block.  The caches use write allocate and write update policies.  The Dragon Protocol is made up of four states ('''Modified (M)''', '''Exclusive (E)''', '''Shared Modified (Sm)''', '''Shared Clean (Sc)''') and does not include an invalidation state, because if the block is in cache it is valid.&lt;br /&gt;
&lt;br /&gt;
* '''Modified (M)''' - cache block is exclusively owned, however it can be different from main memory&lt;br /&gt;
* '''Exclusive (E)''' - cache block is clean and is only in one cache&lt;br /&gt;
* '''Shared Modified (Sm)''' - cache block resides in multiple caches and is possible dirty&lt;br /&gt;
* '''Shared Clean (Sc)''' -  cache block resides in multiple caches and is clean&lt;br /&gt;
&lt;br /&gt;
There is not an invalidation state, because if a block is cached then it assumed to be valid.  However, it can differ from main memory.  Below are the finite state machines for the processor-side calls and bus-side calls.  Dragon protocol utilizes snoopy caches to appear as if it as a uniform memory space even though there are multiple processors.&lt;br /&gt;
[[File:Dragon Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 2.  Dragon Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon Protocol Bus-Side.png|500px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 3.  Dragon Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Dragon Protocol is implemented in the [http://en.wikipedia.org/wiki/Cray_CS6400 Cray CS6400] (also know as the Xerox Dragon multiprocessor workstation) and was developed by Xerox in.  It was available with either 60Mhz or 85Mhz processors.  The Xerox Dragon was designed to be a research numerous processors&lt;br /&gt;
&lt;br /&gt;
===Firefly Protocol===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Firefly_protocol Firefly protocol] is another example of update coherence cache protocols.  However, unlike the [http://en.wikipedia.org/wiki/Dragon_protocol Dragon Protocol], it uses write-through policy (which writes all changes back to memory).  &lt;br /&gt;
&lt;br /&gt;
* '''Valid Exclusive (VE)''' - cache block is exclusively owned, cache block is clean&lt;br /&gt;
* '''Dirty (D)''' - exclusive rights to the cache block, cache block is dirty&lt;br /&gt;
* '''Shared (S)''' - cache block is shared but is not modified&lt;br /&gt;
&lt;br /&gt;
The Firefly Protocol uses a special bus technique called SharedLine to allow quick detection to copies of the block in other caches.  It is similar to the COPIES_EXIST (C) and !COPIES_EXIST, and is shown that way in the finite state machines below.  Similar to the Dragon protocol, there is no invalidation state because no cache blocks are ever invalidated.  &lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Processor-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 4.  Firefly Protocol Processor-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Firefly Protocol Bus-Side.png|550px|center]]&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 5.  Firefly Protocol Bus-Side''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Firefly protocol is used in the [http://en.wikipedia.org/wiki/DEC_Firefly DEC Firefly] multiprocessor workstation, developed by [http://en.wikipedia.org/wiki/Digital_Equipment_Corporation Digital Equipment Corporation].  The system is asymmetic and the cache is direct-mapped to support multiprocessing.  The cache capicity was 16KB for the original [http://en.wikipedia.org/wiki/MicroVAX_78032 MicroVAX 78032] microprocessor were latter increased to 64KB when upgraded to the [http://en.wikipedia.org/wiki/CVAX#CVAX_78034 CVAX_78034] microprocessor.&lt;br /&gt;
&lt;br /&gt;
==Adaptive Coherence Protocols==&lt;br /&gt;
&lt;br /&gt;
===Introduction===&lt;br /&gt;
Even though there are clear advantages to using either update protocols or invalidate protocols, there are still disadvantages for each.  In a write invalidate protocol, any update/write operation in a processor invalidates the shared cache blocks of other processors.  This will force the other caches to do read requests such that the new data is retrieved.  This tends to cause a high bus bandwidth and can be especially bad if there is few processors that frequently update the cache.  Fortunately, write update protocols mitigate this issue.  It will update all other caches at the same time it propagates an update itself.  Unfortunately, this creates a different problem, there will sometime be unnecessary update to the cache on the other processors.  This tends to increase conflict and capacity cache misses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adaptive protocols tries to mitigate these problems.  It will both tend to have some high bus traffic as well as some unnecessary updates.  But, these can be mitigated based on how the adaptive algorithm switches between write-invalidate and write-update.  There is also adaptive directory-based protocols, but these are not discussed here.&lt;br /&gt;
&lt;br /&gt;
===Competitive Update Protocol===&lt;br /&gt;
A competitive-update protocol is a &amp;quot;..hybrid protocols between write-invalidate and write-update..&amp;quot;&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&lt;br /&gt;
H. Nilsson, P. Stenström &amp;quot;An adaptive update-based cache coherence protocol for reduction of miss rate and traffic&amp;quot;&lt;br /&gt;
Proc. Parallel Architectures and Languages Europe (PARLE) Conf., Lecture Notes in Computer Science, Athens, Greece, 817, Springer-Verlag, Berlin (Jul. 1994), pp. 363–374&lt;br /&gt;
[http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.7116&amp;amp;rep=rep1&amp;amp;type=pdf Paper]&amp;lt;/ref&amp;gt;&lt;br /&gt;
These hybrid protocols are used to reduce the coherence miss rate caused by invalidation or update alone.  The sole issue here is that there can be high traffic peeks and these peeks can offset the performance gain&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
According to Nilsson in &amp;lt;ref name=&amp;quot;nilsson2&amp;quot;&amp;gt;H. Nilsson, P. Stenström, and M. Dubois, “Implementation and Evaluation of Update-&lt;br /&gt;
Based Cache Protocols Under Relaxed Memory Consistency Models”, Technical Report,&lt;br /&gt;
Dept. of Computer Engineering, Lund University, Sweden, July 1993&amp;lt;/ref&amp;gt;, competitive-update protocols will outperform write-invalidate protocols under relaxed memory consistency.  The concept presented is very simple.  The first write to a block causes an update to the copy of the block.  If instead the local processor does not access it, it will then propagate an invalidate.  What this effectively does is make regularly accessed copies of the memory block be updated.  The limitation here is that migratory data makes this protocol sub-optimal.  The latest research done in this area is Competitive Update Protocol with Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.  This recognizes when there is migratory data and compensates.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[Image:CompetitiveUpdateProtocolWithMigratoryDetection.jpg|800px]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Figure 6.  Competitive Update Protocol With Migratory Detection&amp;lt;ref name=&amp;quot;nilsson&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt; '''Coherence actions for detection of migratory blocks (left) and coherence actions for read misses to migratory blocks (right).''' &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is only one of many ways to deal with migratory data.  For further reading, a Google Scholar search on &amp;quot;Adaptive Protocols and Migratory&amp;quot; will return many papers published on different ways to deal with migratory data issue that arises when using adaptive protocols.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Cachet===&lt;br /&gt;
Cachet is an adaptive cache coherence protocol that uses micro-protocols &amp;lt;ref name=&amp;quot;shen&amp;quot;&amp;gt;Xiaowei Shen, Arvind, and Larry Rudolph. 1999. CACHET: an adaptive cache coherence protocol for distributed shared-memory systems. In Proceedings of the 13th international conference on Supercomputing (ICS '99). ACM, New York, NY, USA, 135-144. DOI=10.1145/305138.305187[http://doi.acm.org/10.1145/305138.305187 Paper]&amp;lt;/ref&amp;gt; Cachet recognizes that shared-memory programs have various access patterns and no fixed cache coherence protocol works well for all access patterns.&amp;lt;ref name=&amp;quot;bennet&amp;quot;&amp;gt;J. K. Bennett, J. B. Carter, and W. Zwaenepoel. Adaptive Software Cache Management for Distributed Shared Memory Architectures. In Proceedings of the 17th Annual International Symposium on Computer Architecture, May 1990&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;eggers&amp;quot;&amp;gt;S. Eggers and R. H. Katz. Evaluating the Performance for Four Snooping Cache Coherency Protocols. In Proceedings of the 16th Annual International Symposium on Computer Architecture, May 1989&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;falsafi&amp;quot;&amp;gt;B. Falsafi, A. R. Lebeck, S. K. Reinhardt, I. Schoinas, M.  D. Hill, J. R. Larus, A. Rogers, and D. A. Wood. Application specific protocols for user-level shared memory. In Supercomputing, Nov. 1994&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;weber&amp;quot;&amp;gt;W. D. Weber and A. Gupta. Analysis of Cache Invalidation Patterns in Multiprocessors. In Proceedings of the 3rd International Conference on Architectural Support for Programming Languages and Operating Systems, 1989&amp;lt;/ref&amp;gt;.  What cachet attempts to do is either take in the access pattern through program annotations from the programmer or recognition by the compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So how does it work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Base: The most straightforward implementation simply uses the memory as the rendezvous. When a Commit instruction is executed for an address that is cached in the Dirty state, the data must be written back to the memory before the instruction can complete. A Reconcile instruction for an address cached in the Clean state requires the data be purged from the cache before the instruction can complete. An attractive characteristic of Cachet-Base is its simplicity; no state needs to be maintained at the memory side.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Cachet-WriterPush: Since load operations are usually more frequent than store operations, it is desirable to allow a Reconcile instruction to complete even when the address is cached in the Clean state. Thus, the following load access to the address causes no cache miss. Correspondingly, when a Commit instruction is performed on a dirty cell, it cannot complete before clean copies of the address are purged from all other caches. Therefore, it can be a lengthy process to commit an address that is cached in the Dirty state.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-Migratory: When an address is exclusively accessed by one processor for a reasonable time period, it makes sense to give the cache the exclusive ownership so that all instructions on the address become local operations. This is reminiscent of the exclusive state in conventional MESI like protocols. The protocol ensures that an address can be cached in at most one cache at any time. Therefore, a Commit instruction can complete even when the address is cached in the Dirty state, and a Reconcile instruction can complete even when the address is cached in the Clean state. The exclusive ownership can migrate among different caches whenever necessary.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Different micro-protocols are optimized for different access patterns. Cachet-Base is ideal when the location is randomly accessed by multiple processors, and only necessary commit and reconcile operations are invoked. A conventional implementation of release consistency usually requires that all addresses be indistinguishably committed before a release, and reconciled after an acquire. Such excessive use of commit and reconcile operations can result in performance degradation under Cachet-Base.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Cachet-WriterPush is appropriate when certain processors are likely to read an address many times before another processor writes the address. A reconcile operation performed on a clean copy causes no purge operation, regardless of whether the reconcile is necessary. Thus, subsequent load operations to the address can continually use the cached data without causing any cache miss. Cachet Migratory fits well when one processor is likely to read and write an address many times before another processor accesses the address.&amp;quot;&amp;lt;ref name=shen&amp;gt;&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is so interesting about Cachet is its ability to switch between these mirco-protocols.  This excerpt from the paper does the best of explaining it.&lt;br /&gt;
&lt;br /&gt;
==Power Considerations==&lt;br /&gt;
A major issue when considering power is how many bus transaction are incurring over the bus.  Different protocols require different bus transactions, so we are able to loosely demonstrate how much power is being utilized by each of the different techniques by comparing there bus transactions over the same read/write pattern.  We will use the patterns found in '''Ch 8 of Solihin'''.&lt;br /&gt;
&lt;br /&gt;
[[File:MSI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:MOESI_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:Dragon_Protocol_operation.png|600px]]&lt;br /&gt;
&lt;br /&gt;
As you can see from the above spreadsheets the update-based protocols demonstrate beter power consumption in terms of bus transactions and memory access.  The invalidation protocols require 6 bus transactions plus 4 memory access for the MSI protocol, as well as 5 bus transactions and 1 memory access for the MOESI protocol.  This is higher compared to the Dragon protocol which only used 4 bus transactions and 1 memory access.  By counting the number of bus transactions and memory access over the same procedure of processor calls we are able to put the different protocols on the same field and compare them.  The Dragon protocol also requires less time on the bus because it is only passing modified words instead of whole cache blocks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unfortunately for adaptive protocols, we are unable to provide rough estimates.  Most cases with competitive update and cachet, it depends on the problem itself.  For example, bus traffic can vary in a competitive update.  Competitive update does invalidates on non-regularly used cache blocks.  This can vary between program to program.  What make power estimates hard for adaptive protocols is the nature of being adaptive.  Depending on the program involved, the performance/power used can vary drastically.&lt;br /&gt;
&lt;br /&gt;
==Quiz==&lt;br /&gt;
'''Question 1 : What write protocol is used in the Dragon Protocol?'''&lt;br /&gt;
    a) write-permeate&lt;br /&gt;
    b) write-through&lt;br /&gt;
    c) write-back&lt;br /&gt;
    d) write-update&lt;br /&gt;
&lt;br /&gt;
'''Question 2 : How does the Dragon Protocol save on bandwidth?'''&lt;br /&gt;
    a) does not have a invalid state and can not incur read/write misses&lt;br /&gt;
    b) consistently updates the memory&lt;br /&gt;
    c) updates specific words within cache instead of entire blocks&lt;br /&gt;
    d) only flushes the memory when in the exclusive state&lt;br /&gt;
&lt;br /&gt;
'''Question 3 : How are the states different for Dragon protocol than MOESI protocol?'''&lt;br /&gt;
    a) The Dragon shared states can allow for copies to exist in multiple caches&lt;br /&gt;
    b) split up the share state into clean and modified&lt;br /&gt;
    c) Exclusive state in the Dragon protocol can be dirty&lt;br /&gt;
    d) The Modified state is exclusively owned in the MOESI protocol&lt;br /&gt;
&lt;br /&gt;
'''Question 4 : Why do update-based protocols not require a invalidation state?'''&lt;br /&gt;
    a) because the it does not allow for an invalid block&lt;br /&gt;
    b) if the block is in the cache then it is valid&lt;br /&gt;
    c)  (a) and (c) are correct&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
'''Question 5 : Which of the following is NOT true of the states in the Firefly protocol?'''&lt;br /&gt;
    a) They states use the SharedLine technique to detect for copies of the cache&lt;br /&gt;
    b) Dirty has multiple modified cache blocks&lt;br /&gt;
    c) Shared allows for multiple copies of the cache block to exist&lt;br /&gt;
    d) Valid Exclusive allows for only one copy of the cache to be in the state&lt;br /&gt;
&lt;br /&gt;
'''Question 6 : What are two adaptive protocols?'''&lt;br /&gt;
    a) Competitive Update&lt;br /&gt;
    b) Competitive Invalidate&lt;br /&gt;
    c) Cachet&lt;br /&gt;
    d) Roulette&lt;br /&gt;
&lt;br /&gt;
'''Question 7 : Competitive Update Protocol uses what protocol(s) as its basis?'''&lt;br /&gt;
    a) Update&lt;br /&gt;
    b) Invalidate&lt;br /&gt;
    c) Both (a) and (b)&lt;br /&gt;
    d) None of the above&lt;br /&gt;
&lt;br /&gt;
'''Question 8 : What is the major drawback for adaptive protocols?'''&lt;br /&gt;
    a) Write-Updates&lt;br /&gt;
    b) Write-Invalidates&lt;br /&gt;
    c) Overall Hardware Limitations&lt;br /&gt;
    d) Migratory Data&lt;br /&gt;
&lt;br /&gt;
'''Question 9 : What is not a sub-protocol of Cachet?'''&lt;br /&gt;
    a) Cachet-Base&lt;br /&gt;
    b) Cachet-WriterPush&lt;br /&gt;
    c) Cachet-ReadPush&lt;br /&gt;
    d) Cachet-Migratory&lt;br /&gt;
&lt;br /&gt;
'''Question 10 : What is the basis for Cachet protocol?'''&lt;br /&gt;
    a) It switches between update and invalidate&lt;br /&gt;
    b) It switches between three sub-protocols&lt;br /&gt;
    c) It switches between update and competitive update protocols&lt;br /&gt;
    d) It switches between invalidate and competitive update protocols&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73472</id>
		<title>CSC/ECE 506 Spring 2013/3b xz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73472"/>
		<updated>2013-02-21T01:40:05Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Overview of the Programming Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to MapReduce =&lt;br /&gt;
[[File:Mapreduce.png|thumbnail|MapReduce for a Shape Counter]]&lt;br /&gt;
MapReduce is a software framework introduced by Google in 2004 to support [http://publib.boulder.ibm.com/infocenter/txformp/v6r0m0/index.jsp?topic=%2Fcom.ibm.cics.te.doc%2Ferziaz0015.htm distributed computing] on large data sets on clusters of computers. &lt;br /&gt;
&lt;br /&gt;
MapReduce programming model consists of two major steps: &lt;br /&gt;
&lt;br /&gt;
* In the '''map''' step, the problem being solved is divided into a series of sub-problems and distributed to different workers. &lt;br /&gt;
&lt;br /&gt;
* After collecting results from workers, the computation enters the '''reduce''' step to combine and produce the final result.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of the Programming Model =&lt;br /&gt;
&lt;br /&gt;
The MapReduce programming model is inspired by [http://enfranchisedmind.com/blog/posts/what-is-a-functional-programming-language/ functional languages] and targets data-intensive computations. &lt;br /&gt;
&lt;br /&gt;
The input data format is application-specific, and is specified by the user. The output is a set of &amp;lt;key,value&amp;gt; pairs. The user expresses an algorithm using two functions, Map and Reduce. The Map function is applied on the input data and produces a list of intermediate &amp;lt;key,value&amp;gt; pairs. The Reduce function is applied to all intermediate pairs with the same key. It typically performs some kind of merging operation and produces zero or more output pairs. Finally, the output pairs are sorted by their key value. In the simplest form of MapReduce programs, the programmer provides just the Map function. All other functionality, including the grouping of the intermediate pairs which have the same key and the final sorting, is provided by the runtime.&lt;br /&gt;
&lt;br /&gt;
The programmer provides a simple description of the algorithm that focuses on functionality and not on parallelization. The actual parallelization and the details of [http://en.wikipedia.org/wiki/Concurrency_(computer_science)/ concurrency] management are left to the runtime system. Hence the program code is generic and easily portable across systems. Nevertheless, the model provides sufficient high-level information for parallelization. The Map function can be executed in parallel on non-overlapping portions of the input data and the Reduce function can be executed in parallel on each set of intermediate pairs with the same key. Similarly, since it is explicitly known which pairs each function will operate upon, one can employ pre-fetching or other scheduling optimizations for locality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Sample Code''&lt;br /&gt;
&lt;br /&gt;
The following pseudo-code shows the basic structure of a MapReduce program. &lt;br /&gt;
&lt;br /&gt;
Program to count number of occurrences of each word in a collection of documents.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Input : a Document&lt;br /&gt;
//Intermediate Output: key = word, value = 1&lt;br /&gt;
Map(void * input){&lt;br /&gt;
   for each word w in Input&lt;br /&gt;
       Emit Intermediate(w,1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Intermediate Output key = word, value = 1&lt;br /&gt;
//Output : key = word, value = occurrences&lt;br /&gt;
Reduce(String key, Iterator values){&lt;br /&gt;
   int result = 0;&lt;br /&gt;
   for each v in values &lt;br /&gt;
       result += v&lt;br /&gt;
   Emit(w, result)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Role of the Run-time System =&lt;br /&gt;
In both steps of MapReduce, the run-time must decide on factors such as the size of the units, the number of nodes involved, how units are assigned to nodes dynamically, and how buffer space is allocated. The decisions can be fully automatic or guided by the programmer given application specific knowledge. These decisions allow the run-time to execute a program efficiently across a wide range of machines and data-set scenarios without modifications to the source code. Finally, the run-time must merge and sort the output pairs from all Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
= Implementations =&lt;br /&gt;
Many different implementations of the MapReduce interface are possible. The right choice depends on the environment. For example, one implementation may be suitable for a small shared-memory machine, another for a large [http://msdn.microsoft.com/en-us/library/ms178144.aspx NUMA] multi-processor, and yet another for an even larger collection of networked machines. &lt;br /&gt;
&lt;br /&gt;
* Google's MapReduce and [http://en.wikipedia.org/wiki/Apache_Hadoop Hadoop] implement map reduce for large clusters of commodity PCs connected together with switched Ethernet.&lt;br /&gt;
&lt;br /&gt;
* [http://mapreduce.stanford.edu/ Phoenix] implements MapReduce for shared-memory systems.&lt;br /&gt;
&lt;br /&gt;
* [http://www.cse.ust.hk/gpuqp/Mars.html Mars] is a MapReduce framework on graphics processors ([http://www.nvidia.com/object/gpu.html GPUs]).&lt;br /&gt;
&lt;br /&gt;
== Google's MapReduce ==&lt;br /&gt;
&lt;br /&gt;
=== Execution Overview ===&lt;br /&gt;
The Map invocations are distributed across multiple machines by automatically partitioning the input data into a set of M splits. The input splits can be processed in parallel by different machines. Reduce invocations are distributed by partitioning the intermediate key space into R pieces using a partitioning function (e.g., hash(key) mod R). The number of partitions (R) and the partitioning function are specified by the user. Below is a detailed look. &amp;lt;ref&amp;gt;http://static.usenix.org/event/osdi04/tech/full_papers/dean/dean.pdf Simplified Data Processing on Large Clusters&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Google Map Reduce.jpg|center|Google's MapReduce]] &amp;lt;br&amp;gt;&lt;br /&gt;
The figure above shows the overall flow of a MapReduce operation in Google's implementation. When the user program calls the MapReduce function, the following sequence of actions occurs (the numbered labels in the figure above correspond to the numbers in the list below):&lt;br /&gt;
&lt;br /&gt;
# The MapReduce library in the user program first splits the input files into M pieces of typically 16 megabytes to 64 megabytes (MB) per piece (controllable by the user via an optional parameter). It then starts up many copies of the program on a cluster of machines.&lt;br /&gt;
# One of the copies of the program is special, ''the master''. The rest are workers that are assigned work by the master. There are ''M'' map tasks and R reduce tasks to assign. The master picks idle workers and assigns each one a map task or a reduce task.&lt;br /&gt;
# A worker who is assigned a map task reads the contents of the corresponding input split. It parses ''key/value'' pairs out of the input data and passes each pair to the user-defined Map function. The intermediate ''key/value'' pairs produced by the Map function are buffered in memory. &lt;br /&gt;
# Periodically, the buffered pairs are written to local disk, partitioned into ''R'' regions by the partitioning function. The locations of these buffered pairs on the local disk are passed back to the master, who is responsible for forwarding these locations to the reduce workers. When a reduce worker is notified by the master about these locations, it uses remote procedure calls to read the buffered data from the local disks of the  map workers.&lt;br /&gt;
# When a reduce worker has read all intermediate data, it sorts it by the intermediate keys so that all occurrences of the same key are grouped together. The sorting is needed because typically many different keys map to the same reduce task. If the amount of intermediate data is too large to fit in memory, an external sort is used.&lt;br /&gt;
# The reduce worker iterates over the sorted intermediate data and for each unique intermediate key encountered, it passes the key and the corresponding set of intermediate values to the user's Reduce function. The output of the Reduce function is appended to a final output file for this reduce partition.&lt;br /&gt;
# When all map tasks and reduce tasks have been completed, the master wakes up the user program. At this point, the MapReduce call in the user program returns back to the user code.&lt;br /&gt;
# After successful completion, the output of the mapreduce execution is available in the ''R'' output files (one per reduce task, with file names as specified by the user). Typically, users do not need to combine these ''R'' output files into one file . They often pass these files as input to another MapReduce call, or use them from another distributed application that is able to deal with input that is partitioned into multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Data Structures: Master ===&lt;br /&gt;
&lt;br /&gt;
The master keeps several data structures. For each map task and reduce task, it stores the state (idle, in-progress, or completed), and the identity of the worker machine (for non-idle tasks).&lt;br /&gt;
The master is the conduit through which the location of intermediate file regions is propagated from map tasks to reduce tasks. Therefore, for each completed map task, the master stores the locations and sizes of the ''R'' intermediate file regions produced by the map task. Updates to this location and size information are received as map tasks are completed. The information is pushed incrementally to workers that have in-progress reduce tasks.&lt;br /&gt;
&lt;br /&gt;
=== Fault Tolerance ===&lt;br /&gt;
&lt;br /&gt;
Since the MapReduce library is designed to help process very large amounts of data using hundreds or thousands of machines, the library must tolerate machine failures gracefully.&lt;br /&gt;
&lt;br /&gt;
* '''Master Failure'''&lt;br /&gt;
&lt;br /&gt;
It is easy to make the master write periodic checkpoints of the master data structures. If the master task dies, a new copy can be started from the last checkpoint. However, given that there is only a single master, its failure is unlikely; therefore Google's current implementation aborts the MapReduce computation if the master fails. Clients can check for this condition and retry the MapReduce operation if they desire.&lt;br /&gt;
&lt;br /&gt;
* '''Worker Failure'''&lt;br /&gt;
&lt;br /&gt;
The master pings every worker periodically. If no response is received from a worker in a certain amount of time, the master marks the worker as failed. Any map tasks completed by the worker are reset back to their initial idle state, and therefore become eligible for scheduling&lt;br /&gt;
on other workers. Similarly, any map task or reduce task in progress on a failed worker is also reset to idle and becomes eligible for rescheduling. Completed map tasks are re-executed on a failure because their output is stored on the local disk(s) of the failed machine and is therefore inaccessible. Completed reduce tasks do not need to be re-executed since their output is stored in a global file system. When a map task is executed first by worker ''A'' and then later executed by worker ''B'' (because ''A'' failed), all workers executing reduce tasks are notified of the re-execution. Any reduce task that has not already read the data from worker ''A'' will read the data from worker ''B''. MapReduce is resilient to large-scale worker failures.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Large variety of problems are easily expressible as Map-Reduce computations. &lt;br /&gt;
# The model is easy to use, even for programmers without experience with parallel and distributed systems, since it hides the details of parallelization, fault tolerance, locality optimization, and load balancing. For example, Map-Reduce is used for the generation of data for Google’s production Web search service, for sorting, data mining, machine learning, and many other systems.&lt;br /&gt;
# Implementation of Map-Reduce can be scaled to large clusters of machines comprising thousands of machines.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# Restricted programming model puts bounds on the way you implement the framework. &lt;br /&gt;
# Since network bandwidth is scarce, a number of optimization in the system are therefore targeted at reducing the amount of data sent across the network.&lt;br /&gt;
&lt;br /&gt;
=== Apache’s Hadoop MapReduce ===&lt;br /&gt;
&lt;br /&gt;
Apache, after Google published the paper on MapReduce and Google File System (GFS &amp;lt;ref&amp;gt;http://www.cs.rochester.edu/meetings/sosp2003/papers/p125-ghemawat.pdf Google File System&amp;lt;/ref&amp;gt;) introduced it's own implementation of the same. The important thing to note here is that Apache made this framework open-source. This framework transparently provides both reliability and data motion to applications. Hadoop has prominent users such as Yahoo! and Facebook.&lt;br /&gt;
(Good Read!&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Apache_Hadoop Apache Hadoop&amp;lt;/ref&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Hadoop MapRed is based on a “pull” model where multiple “TaskTrackers” poll the “JobTracker” for tasks (either map task or reduce task).&lt;br /&gt;
&lt;br /&gt;
[[File:HMR.png|center|Apache Hadoop MapReduce]]&lt;br /&gt;
The figure above depicts the execution of the job.&amp;lt;ref&amp;gt;http://horicky.blogspot.com/2008/11/hadoop-mapreduce-implementation.html Pragmatic Guide&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Client program uploads files to the Hadoop Distributed File System (HDFS) location and notifies the JobTracker which in turn returns the Job ID to the client. &lt;br /&gt;
* The Jobtracker allocates map tasks to the TaskTrackers. &lt;br /&gt;
* JobTracker determines appropriate jobs based on how busy the TaskTracker is. &lt;br /&gt;
* TaskTracker forks MapTask which extracts input data and invokees the user provided &amp;quot;map&amp;quot; function which fills in the buffer with key/value pairs until it is full. &lt;br /&gt;
* The buffer is eventually flushed into two files. &lt;br /&gt;
* After all the MapTask completes (all splits are done), the TaskTracker will notify the JobTracker which keeps track of the overall progress of job.&lt;br /&gt;
* When done, the JobTracker notifies TaskTracker to jump to reduce phase. This again follows same method where reduce task is forked. &lt;br /&gt;
* The output of each reducer is written to a temporary output file in HDFS. When the reducer finishes processing all keys, the temp output file will be renamed atomically to its final output filename.&lt;br /&gt;
&lt;br /&gt;
== Phoenix ==&lt;br /&gt;
Phoenix&amp;lt;ref&amp;gt;&lt;br /&gt;
http://csl.stanford.edu/~christos/publications/2007.cmp_mapreduce.hpca.pdf Evaluating MapReduce for Multi-core and Multiprocessor Systems&amp;lt;/ref&amp;gt; implements MapReduce for shared-memory systems. Its goal is to support efficient execution on multiple cores without burdening the programmer with concurrency management. Phoenix consists of a simple API that is visible to application programmers and an efficient runtime that handles parallelization, resource management, and fault recovery.&lt;br /&gt;
&lt;br /&gt;
=== Phoenix API ===&lt;br /&gt;
The current Phoenix implementation provides an API for C and C++. &amp;lt;br&amp;gt;&lt;br /&gt;
* The first set is provided by Phoenix and is used by the programmer’s application code to initialize the system and emit output pairs (1 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
* The second set includes the functions that the programmer defines (3 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from the Map and Reduce functions, the user provides functions that partition the data before each step and a function that implements key comparison. The function arguments are declared as void pointers wherever possible to provide flexibility in their declaration and fast use without conversion overhead. The data structure used to communicate basic function information and buffer allocation between the user code and run-time is of type ''scheduler_args_t'' ([http://pages.cs.wisc.edu/~gibson/mapreduceexample/MapReduceScheduler.h.html MapReduce Header File]). There are additional data structure types to facilitate communication between the Splitter, Map, Partition, and Reduce functions. These types use pointers whenever possible to implement communication without actually copying significant amounts of data.&lt;br /&gt;
&lt;br /&gt;
The Phoenix API does not rely on any specific compiler options and does not require a parallelizing compiler. However, it assumes that its functions can freely use stack-allocated and heap-allocated structures for private data. It also assumes that there is no communication through shared-memory structures other than the input/output buffers for these functions. For C/C++, these assumptions cannot be checked statically for arbitrary programs. Although there are stringent checks within the system to ensure valid data are communicated between user and run-time code, eventually it is the task of user to provide functionally correct code. &lt;br /&gt;
&lt;br /&gt;
[[File:Phoenix.jpg|center|Phoenix MapReduce]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Phoenix run-time was developed on top of [http://en.wikipedia.org/wiki/POSIX_Threads POSIX threads], but can be easily ported to other shared memory thread packages. The figure above shows the basic data flow for the run-time system. &lt;br /&gt;
&lt;br /&gt;
* The run-time is controlled by the scheduler, which is initiated by user code. &lt;br /&gt;
* The scheduler creates and manages the threads that run all Map and Reduce tasks. It also manages the buffers used for task communication. &lt;br /&gt;
* The programmer provides the scheduler with all the required data and function pointers through the ''scheduler_args_t'' structure. &lt;br /&gt;
*After initialization, the scheduler determines the number of cores to use for this computation. For each core, it spawns a worker thread that is dynamically assigned some number of Map and Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
To start the '''Map''' stage, the scheduler uses the ''Splitter'' to divide input pairs into equally sized units to be processed by the Map tasks. The Splitter is called once per Map task and returns a pointer to the data the Map task will process. The Map tasks are allocated dynamically to workers and each one emits intermediate &amp;lt;key,value&amp;gt; pairs. The ''Partition'' function splits the intermediate pairs into units for the Reduce tasks. The function ensures all values of the same key go to the same unit. Within each buffer, values are ordered by key to assist with the final sorting. At this point, the Map stage is over. The scheduler must wait for all Map tasks to complete before initiating the Reduce stage.&lt;br /&gt;
&lt;br /&gt;
'''Reduce''' tasks are also assigned to workers dynamically, similar to Map tasks. The one difference is that, while with Map tasks there is complete freedom in distributing pairs across tasks, with Reduce all values for the same key must be processed in one task. Hence, the Reduce stage may exhibit higher imbalance across workers and dynamic scheduling is more important. The output of each Reduce task is already sorted by key. As the last step, the final output from all tasks is merged into a single buffer, sorted by keys.&lt;br /&gt;
&lt;br /&gt;
=== Buffer Management ===&lt;br /&gt;
Two types of temporary buffers are necessary to store data between the various stages. All buffers are allocated in shared memory but are accessed in a well specified way by a few functions. To re-arrange buffers (e.g., split across tasks), pointer manipulation is done instead of the actual pairs, which may be large in size. The intermediate buffers are not directly visible to user code. Map-Reduce buffers are used to store the intermediate output pairs. Each worker has its own set of buffers. The buffers are initially sized to a default value and then resized dynamically as needed. At this stage, there may be multiple pairs with the same key. To accelerate the Partition function, the Emit intermediate function stores all values for the same key in the same buffer. At the end of the Map task, each buffer is sorted by key order. Reduce- Merge buffers are used to store the outputs of Reduce tasks before they are sorted. At this stage, each key has only one value associated with it. After sorting, the final output is available in the user allocated Output data buffer.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Phoenix is fast and scalable across all workloads&lt;br /&gt;
# On clusters of machines, the combiner function reduces the number of key-value pairs that must be exchanged between machines. These combiners contribute to better data locality and lower memory allocation pressure, resulting in substantial number of applications being scalable.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&amp;lt;ref&amp;gt;http://csl.stanford.edu/~christos/publications/2011.phoenixplus.mapreduce.pdf Phoenix++: Modular MapReduce for Shared Memory Systems&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Due to shared memory there is an inefficient  key-Value storage since containers must provide fast lookup and retrieval over potentially large data-set, all the while coordinating accesses across multiple threads&lt;br /&gt;
#Ineffective Combiner : However, on SMP machines memory allocation costs tend to dominate, even more than the memory traffic. Combiners fail to reduce the memory allocation pressure, since generated key-value pairs must still be stored. Further, by the time the combiners are run, those pairs may no longer be in the cache causing expensive memory access penalties.&lt;br /&gt;
#Phoenix implements internally grouping tasks into chunks to reduce scheduling costs and amortize per-task overhead. This design enables the user-implemented optimizations described in the previous two sections. However, it also has two drawbacks. Firstly, since the code for grouping tasks is pushed into user code, map function becomes more complicated due to the extra code to deal with chunks. Secondly, if the user leverages the exposed chunk to improve performance, the framework can no longer freely adjust the chunk size since doing so will affect the efficiency of the map function.&lt;br /&gt;
&lt;br /&gt;
== Map Reduce on Graphics Processors ==&lt;br /&gt;
=== Challenges ===&lt;br /&gt;
&lt;br /&gt;
Compared with CPUs, the hardware architecture of GPUs differs significantly. For instance, current GPUs have over one hundred [http://encyclopedia.jrank.org/articles/pages/6904/SIMD-Single-Instruction-Multiple-Data-Processing.html SIMD (Single Instruction Multiple Data)] processors whereas current multi-core CPUs offer a much smaller number of cores. Moreover, most GPUs do not support atomic operations or locks. &lt;br /&gt;
&lt;br /&gt;
Due to the architectural differences, there are following three technical challenges in implementing the MapReduce framework on the GPU. &lt;br /&gt;
# The synchronization overhead in the run-time system of the framework must be low so that the system can scale to hundreds of processors.&lt;br /&gt;
# Due to the lack of dynamic thread scheduling on current GPUs, it is essential to allocate work evenly across threads on the GPU to exploit its massive thread parallelism. &lt;br /&gt;
# The core tasks of MapReduce programs, including string processing, file manipulation and concurrent reads and writes, are unconventional to GPUs and must be handled efficiently.&lt;br /&gt;
&lt;br /&gt;
'''''Mars''''', MapReduce framework on the GPU was designed and implemented with these challenges in mind.&amp;lt;ref&amp;gt;http://www.ece.rutgers.edu/~parashar/Classes/08-09/ece572/readings/mars-pact-08.pdf Mars: A MapReduce Framework on Graphic Processors&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mars API ===&lt;br /&gt;
&lt;br /&gt;
Mars provides a small set of APIs that are similar to those of CPU-based MapReduce. Run-time system utilizes a large number of GPU threads for Map or Reduce tasks, and automatically assigns each thread a small number of key/value pairs to work on. As a result, the massive thread parallelism on the GPU is well utilized. To avoid any conflict between concurrent writes,  Mars has a lock-free scheme with low runtime overhead on the massive thread parallelism of the GPU. This scheme guarantees the correctness of parallel execution with little synchronization overhead. &lt;br /&gt;
&lt;br /&gt;
Mars has two kinds of APIs, the ''user-implemented APIs'', which the users implement, and the ''system-provided APIs'', which the users can use as library calls. &lt;br /&gt;
&lt;br /&gt;
* Mars has the following user-implemented APIs. These APIs are implemented with C/C++. ''void*'' type has been used so that the developer can manipulate strings and other complex data types conveniently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//MAP_COUNT counts result size of the map function.&lt;br /&gt;
voidMAP_COUNT(void *key, void *val, int keySize, int valSize);&lt;br /&gt;
&lt;br /&gt;
//The map function.&lt;br /&gt;
voidMAP(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
&lt;br /&gt;
//REDUCE_COUNT counts result size of the reduce function.&lt;br /&gt;
void REDUCE_COUNT(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
&lt;br /&gt;
//The reduce function.&lt;br /&gt;
void REDUCE(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Mars has the following four system-provided APIs. The emit functions are used in user-implemented map and reduce functions to output the intermediate/final results.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Emit the key size and the value size inMAP_COUNT.&lt;br /&gt;
void EMIT_INTERMEDIATE_COUNT(int keySize, int valSize);&lt;br /&gt;
&lt;br /&gt;
//Emit an intermediate result in MAP.&lt;br /&gt;
void EMIT_INTERMEDIATE(void* key, void* val, int keySize, int valSize);&lt;br /&gt;
&lt;br /&gt;
//Emit the key size and the value size in REDUCE_COUNT.&lt;br /&gt;
void EMIT_COUNT(int keySize, int valSize);&lt;br /&gt;
&lt;br /&gt;
//Emit a final result in REDUCE.&lt;br /&gt;
void EMIT(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Overall, the APIs in Mars are similar to those in the existing MapReduce frameworks such as Hadoop and Phoenix. The major difference is that Mars needs two APIs to implement the functionality of each CPU-based API. One is to count the size of results, and the other one is to output the results. This is because the GPU does not support atomic operations, and the Mars runtime uses a two-step design for the result output.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Details ===&lt;br /&gt;
&lt;br /&gt;
* Since the GPU does not support dynamic memory allocation on the device memory during the execution of the GPU code, arrays are used as the main data structure. &lt;br /&gt;
* The input data, the intermediate result and the final result are stored in three kinds of arrays, i.e., the key array, the value array and the directory index. The directory index consists of an entry of &amp;lt;key offset, key size, value offset, value size&amp;gt; for each key/value pair. &lt;br /&gt;
* Given a directory index entry, the key or the value at the corresponding offset in the key array or the value array is fetched. &lt;br /&gt;
* With the array structure, for the input data as well as for the result output the space on the device memory is allocated before executing the GPU program. However, the sizes of the output from the map and the reduce stages are unknown. The output scheme for the map stage is similar to that for the reduce stage.&lt;br /&gt;
&lt;br /&gt;
First, each map task outputs three counts, i.e., the number of intermediate results, the total size of keys (in bytes) and the total size of values (in bytes) generated by the map task. Based on key sizes (or value sizes) of all map tasks, the run-time system computes a prefix sum on these sizes and produces an array of write locations. A write location is the start location in the output array for the corresponding map task to write. Based on the number of intermediate results, the run-time system computes a prefix sum and produces an array of start locations in the output directory index for the corresponding map task. Through these prefix sums, the sizes of the arrays for the intermediate result is also known. Thus, the run-time allocates arrays in the device memory with the exact size for storing the intermediate results.&lt;br /&gt;
&lt;br /&gt;
Second, each map task outputs the intermediate key/value pairs to the output array and updates the directory index. Since each map has its deterministic and non-overlapping positions to write to, the write conflicts are avoided. This two-step scheme does not require the hardware support of atomic functions. It is suitable for the massive thread parallelism on the GPU. However, it doubles the map computation in the worst case. The overhead of this scheme is application dependent, and is usually much smaller than that in the worst case.&lt;br /&gt;
&lt;br /&gt;
=== Optimization Techniques ===&lt;br /&gt;
==== Memory Optimizations ====&lt;br /&gt;
Two memory optimizations are used to reduce the number of memory requests in order to improve the memory bandwidth utilization. &lt;br /&gt;
* '''Coalesced accesses'''&lt;br /&gt;
The GPU feature of coalesced accesses is utilized to improve the memory performance. The memory accesses of each thread to the data arrays are designed according to the coalesced access pattern when applicable. Suppose there are T threads in total and the number of key/value pairs is N in the map stage. Thread i processes the (i + T • k )th (k=0,..,N/T) key/value pair. Due to the SIMD property of the GPU, the memory addresses from the threads within a thread group are consecutive and these accesses are coalesced into one. The figure below illustrates the map stage with and without the coalesced access optimization.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mars.jpg]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Accesses using built-in vector types'''&lt;br /&gt;
Accessing the values in the device memory can be costly, because the data values are often&lt;br /&gt;
of different sizes and the accesses are hardly coalesced. Fortunately, GPUs such as G80 support built-in vector types such as char4 and int4. Reading built-in vectors fetches the entire vector&lt;br /&gt;
in a single memory request. Compared with reading char or int, the number of memory requests is greatly reduced and the memory performance is improved.&lt;br /&gt;
&lt;br /&gt;
==== Thread parallelism ====&lt;br /&gt;
The thread configuration, i.e., the number of thread groups and the number of threads per thread group, is related to multiple factors including, (1) the hardware configuration such as the number of multiprocessors and the on-chip computation resources such as the number of registers on each multiprocessor, (2) the computation characteristics of the map and the reduce tasks, e.g., they are memory- or computation-intensive. Since the map and the reduce functions are implemented by the developer, and their costs are unknown to the runtime system, it is difficult to find the optimal setting for the thread configuration at&lt;br /&gt;
run time.&lt;br /&gt;
&lt;br /&gt;
==== Handling variable-sized types ==== &lt;br /&gt;
The variable-sized types are supported with the directory index. If two key/value pairs need to be swapped, their corresponding entries in the directory index are swapped without modifying the key and the value arrays. This choice is to save the swapping cost since the directory entries are typically much smaller than the key/value pairs. Even though swapping changes the order of entries in the directory index, the array layout is preserved and therefore accesses to the directory index can still be coalesced after swaps. Since strings are a typical variable-sized type, and string processing is common in web data analysis tasks, a GPU-based string manipulation library was developed for Mars. The operations in the library include strcmp, strcat, memset and so on. The APIs of these operations are consistent with those in C/C++ library on the CPU. The difference is that simple algorithms for these GPU-based string operations were used, since they usually handle small strings within a map or a reduce task. In addition, char4 is used to implement strings to optimize the memory performance.&lt;br /&gt;
&lt;br /&gt;
==== Hashing ====&lt;br /&gt;
Hashing is used in the sort algorithm to store the results with the same key value consecutively. In that case, it is not needed that the results with the key values are in their strict ascending/ decreasing order. The hashing technique that hashes a key into a 32-bit integer is used, and the records are sorted according to their hash values. When two records are compared, their hash values are compared first. Only when their hash values are the same, their keys are fetched and compared. Given a good hash function, the probability of comparing the keys is low.&lt;br /&gt;
&lt;br /&gt;
==== File manipulation ====&lt;br /&gt;
Currently, the GPU cannot directly access the data in the hard disk. Thus, the file manipulation with the assistance of the CPU is performed in three phases. First, the file I/O on the CPU is performed and the file data is loaded into a buffer in the main memory. To reduce the I/O stall, multiple threads are used to perform the I/O task. Second, the preprocessing on the buffered data is performed and the input key/value pairs are obtained. Finally, the input key/value pairs are copied to the GPU device memory.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Provides a performance speedup of accessing data by using built-in vector types. These vector types  reduces the number of memory requests and improves the bandwidth utilization.&lt;br /&gt;
# Applications written on Mars may or may not have the reduce stage and thus improves speedup.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# GPU based applications are much more complex&lt;br /&gt;
# Mars currently handles data that can fit into the device memory but has not yet been checked to support massive data sets&lt;br /&gt;
&lt;br /&gt;
= More Examples =&lt;br /&gt;
Below are a few simple examples of programs that can be easily expressed as MapReduce computations.&lt;br /&gt;
*Distributed [http://unixhelp.ed.ac.uk/CGI/man-cgi?grep Grep]: The map function emits a line if it matches a given pattern. The reduce function is an identity function that just copies the supplied intermediate data to the output. &amp;lt;br&amp;gt;&lt;br /&gt;
*Count of URL Access Frequency: The map function processes logs of web page requests and outputs &amp;lt;URL, 1&amp;gt;. The reduce function adds together all values for the same URL and emits a &amp;lt;URL, total count&amp;gt; pair. &amp;lt;br&amp;gt;&lt;br /&gt;
*[http://books.google.com/books?id=gJrmszNHQV4C&amp;amp;pg=PA376&amp;amp;lpg=PA376&amp;amp;dq=what+is+reverse+web+link+graph&amp;amp;source=bl&amp;amp;ots=rLQ2yuV6oc&amp;amp;sig=wimcG_7MR7d9g-ePGXkEK1ANmws&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ei=BtxBT5HkN42DtgefhbXRBQ&amp;amp;ved=0CEwQ6AEwBg#v=onepage&amp;amp;q=what%20is%20reverse%20web%20link%20graph&amp;amp;f=false Reverse Web-Link Graph]: The map function outputs &amp;lt;target, source&amp;gt; pairs for each link to a target URL found in a page named &amp;quot;source&amp;quot;. The reduce function concatenates the list of all source URLs associated with a given target URL and emits the pair: &amp;lt;target, list(source)&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
*Term-Vector per Host: A term vector summarizes the most important words that occur in a document or a set of documents as a list of &amp;lt;word, frequency&amp;gt; pairs. The map function emits a &amp;lt;hostname, term vector&amp;gt; pair for each input document (where the hostname is extracted from the URL of the document). The reduce function is passed all per-document term vectors for a given host. It adds these term vectors together, throwing away infrequent terms, and then emits a final &amp;lt;hostname, term vector&amp;gt; pair.&amp;lt;br&amp;gt;&lt;br /&gt;
*[http://nlp.stanford.edu/IR-book/html/htmledition/a-first-take-at-building-an-inverted-index-1.html Inverted Index]: The map function parses each document, and emits a sequence of &amp;lt;word, document ID&amp;gt; pairs. The reduce function accepts all pairs for a given word, sorts the corresponding document IDs and emits a &amp;lt;word, list(document ID)&amp;gt; pair. The set of all output pairs forms a simple inverted index. It is easy to augment this computation to keep track of word positions.&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Google’s MapReduce runtime implementation targets large clusters of Linux PCs connected through Ethernet switches. Tasks are forked using remote procedure calls. Buffering and communication occurs by reading and writing files on a distributed file system. The locality optimizations focus mostly on avoiding remote file accesses. While such a system is effective with distributed computing, it leads to very high overheads if used with shared-memory systems that facilitate communication through memory and are typically of much smaller scale.&lt;br /&gt;
&lt;br /&gt;
Phoenix, implementation of MapReduce uses shared memory and minimizes the overheads of task spawning and data communication. With Phoenix,the programmer can provide a simple, functional expression of the algorithm and leaves parallelization and scheduling to the runtime system.Phoenix leads to scalable performance for both multi-core chips and conventional symmetric multiprocessors. Phoenix automatically handles key scheduling decisions during parallel execution. Despite runtime overheads, results have shown that performance of Phoenix to that of parallel code written in P-threads API are almost similar. Nevertheless,there are also applications that do not fit naturally in the MapReduce model for which P-threads code performs significantly better.&lt;br /&gt;
&lt;br /&gt;
Graphics processors have emerged as a commodity platform for parallel computing. However, the developer requires the knowledge of the GPU architecture and much effort in developing GPU applications. Such difficulty is even more for complex and performance centric tasks such as web data analysis. Since MapReduce has been successful in easing the development of web data analysis tasks, one can use a GPU-based MapReduce for these applications. With the GPU-based framework, the developer writes their code using the simple and familiar MapReduce interfaces. The runtime on the GPU is completely hidden from the developer by the framework.&lt;br /&gt;
&lt;br /&gt;
The framework is followed by criticisms as well. Google was awarded the patent for MapReduce, but it can be argued that this technology is similar to many other already existing ones. There are programming models that are similar to MapReduce like Algorithm Skeletons (Parallelism Patterns), Sector/Sphere, Datameer Analytics Solution. Algorithm Skeletons are a high-level parallel programming model for parallel and distributed computing.This frameowrk libraries are used for a number of applications. Sector/Sphere is a distributed file system targeting data storage over a large number of commodity computers. Sphere is the programming framework that supports massive in-storage parallel data processing for data stored in Sector. Additionally, Sector/Sphere is unique in its ability to operate in a wide area network (WAN) setting. Datameer Analytics Solution (DAS) is a business integration platform for Hadoop and includes data source integration, an analytics engine with a spreadsheet interface designed for business users with over 180 analytic functions and visualization including reports, charts and dashboards.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Interesting Read =&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Algorithmic_skeleton#Frameworks_and_libraries Algorithm Skeleton]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Sector/Sphere Sector/Sphere]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Datameer Datameer Analytic Solution]&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73470</id>
		<title>CSC/ECE 506 Spring 2013/3b xz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73470"/>
		<updated>2013-02-21T01:39:42Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Mars API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to MapReduce =&lt;br /&gt;
[[File:Mapreduce.png|thumbnail|MapReduce for a Shape Counter]]&lt;br /&gt;
MapReduce is a software framework introduced by Google in 2004 to support [http://publib.boulder.ibm.com/infocenter/txformp/v6r0m0/index.jsp?topic=%2Fcom.ibm.cics.te.doc%2Ferziaz0015.htm distributed computing] on large data sets on clusters of computers. &lt;br /&gt;
&lt;br /&gt;
MapReduce programming model consists of two major steps: &lt;br /&gt;
&lt;br /&gt;
* In the '''map''' step, the problem being solved is divided into a series of sub-problems and distributed to different workers. &lt;br /&gt;
&lt;br /&gt;
* After collecting results from workers, the computation enters the '''reduce''' step to combine and produce the final result.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of the Programming Model =&lt;br /&gt;
&lt;br /&gt;
The MapReduce programming model is inspired by [http://enfranchisedmind.com/blog/posts/what-is-a-functional-programming-language/ functional languages] and targets data-intensive computations. &lt;br /&gt;
&lt;br /&gt;
The input data format is application-specific, and is specified by the user. The output is a set of &amp;lt;key,value&amp;gt; pairs. The user expresses an algorithm using two functions, Map and Reduce. The Map function is applied on the input data and produces a list of intermediate &amp;lt;key,value&amp;gt; pairs. The Reduce function is applied to all intermediate pairs with the same key. It typically performs some kind of merging operation and produces zero or more output pairs. Finally, the output pairs are sorted by their key value. In the simplest form of MapReduce programs, the programmer provides just the Map function. All other functionality, including the grouping of the intermediate pairs which have the same key and the final sorting, is provided by the runtime.&lt;br /&gt;
&lt;br /&gt;
The programmer provides a simple description of the algorithm that focuses on functionality and not on parallelization. The actual parallelization and the details of [http://en.wikipedia.org/wiki/Concurrency_(computer_science)/ concurrency] management are left to the runtime system. Hence the program code is generic and easily portable across systems. Nevertheless, the model provides sufficient high-level information for parallelization. The Map function can be executed in parallel on non-overlapping portions of the input data and the Reduce function can be executed in parallel on each set of intermediate pairs with the same key. Similarly, since it is explicitly known which pairs each function will operate upon, one can employ pre-fetching or other scheduling optimizations for locality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Sample Code''&lt;br /&gt;
&lt;br /&gt;
The following pseudo-code shows the basic structure of a MapReduce program. &lt;br /&gt;
&lt;br /&gt;
Program to counts number of occurrences of each word in a collection of documents.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Input : a Document&lt;br /&gt;
//Intermediate Output: key = word, value = 1&lt;br /&gt;
Map(void * input){&lt;br /&gt;
   for each word w in Input&lt;br /&gt;
       Emit Intermediate(w,1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Intermediate Output key = word, value = 1&lt;br /&gt;
//Output : key = word, value = occurrences&lt;br /&gt;
Reduce(String key, Iterator values){&lt;br /&gt;
   int result = 0;&lt;br /&gt;
   for each v in values &lt;br /&gt;
       result += v&lt;br /&gt;
   Emit(w, result)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Role of the Run-time System =&lt;br /&gt;
In both steps of MapReduce, the run-time must decide on factors such as the size of the units, the number of nodes involved, how units are assigned to nodes dynamically, and how buffer space is allocated. The decisions can be fully automatic or guided by the programmer given application specific knowledge. These decisions allow the run-time to execute a program efficiently across a wide range of machines and data-set scenarios without modifications to the source code. Finally, the run-time must merge and sort the output pairs from all Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
= Implementations =&lt;br /&gt;
Many different implementations of the MapReduce interface are possible. The right choice depends on the environment. For example, one implementation may be suitable for a small shared-memory machine, another for a large [http://msdn.microsoft.com/en-us/library/ms178144.aspx NUMA] multi-processor, and yet another for an even larger collection of networked machines. &lt;br /&gt;
&lt;br /&gt;
* Google's MapReduce and [http://en.wikipedia.org/wiki/Apache_Hadoop Hadoop] implement map reduce for large clusters of commodity PCs connected together with switched Ethernet.&lt;br /&gt;
&lt;br /&gt;
* [http://mapreduce.stanford.edu/ Phoenix] implements MapReduce for shared-memory systems.&lt;br /&gt;
&lt;br /&gt;
* [http://www.cse.ust.hk/gpuqp/Mars.html Mars] is a MapReduce framework on graphics processors ([http://www.nvidia.com/object/gpu.html GPUs]).&lt;br /&gt;
&lt;br /&gt;
== Google's MapReduce ==&lt;br /&gt;
&lt;br /&gt;
=== Execution Overview ===&lt;br /&gt;
The Map invocations are distributed across multiple machines by automatically partitioning the input data into a set of M splits. The input splits can be processed in parallel by different machines. Reduce invocations are distributed by partitioning the intermediate key space into R pieces using a partitioning function (e.g., hash(key) mod R). The number of partitions (R) and the partitioning function are specified by the user. Below is a detailed look. &amp;lt;ref&amp;gt;http://static.usenix.org/event/osdi04/tech/full_papers/dean/dean.pdf Simplified Data Processing on Large Clusters&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Google Map Reduce.jpg|center|Google's MapReduce]] &amp;lt;br&amp;gt;&lt;br /&gt;
The figure above shows the overall flow of a MapReduce operation in Google's implementation. When the user program calls the MapReduce function, the following sequence of actions occurs (the numbered labels in the figure above correspond to the numbers in the list below):&lt;br /&gt;
&lt;br /&gt;
# The MapReduce library in the user program first splits the input files into M pieces of typically 16 megabytes to 64 megabytes (MB) per piece (controllable by the user via an optional parameter). It then starts up many copies of the program on a cluster of machines.&lt;br /&gt;
# One of the copies of the program is special, ''the master''. The rest are workers that are assigned work by the master. There are ''M'' map tasks and R reduce tasks to assign. The master picks idle workers and assigns each one a map task or a reduce task.&lt;br /&gt;
# A worker who is assigned a map task reads the contents of the corresponding input split. It parses ''key/value'' pairs out of the input data and passes each pair to the user-defined Map function. The intermediate ''key/value'' pairs produced by the Map function are buffered in memory. &lt;br /&gt;
# Periodically, the buffered pairs are written to local disk, partitioned into ''R'' regions by the partitioning function. The locations of these buffered pairs on the local disk are passed back to the master, who is responsible for forwarding these locations to the reduce workers. When a reduce worker is notified by the master about these locations, it uses remote procedure calls to read the buffered data from the local disks of the  map workers.&lt;br /&gt;
# When a reduce worker has read all intermediate data, it sorts it by the intermediate keys so that all occurrences of the same key are grouped together. The sorting is needed because typically many different keys map to the same reduce task. If the amount of intermediate data is too large to fit in memory, an external sort is used.&lt;br /&gt;
# The reduce worker iterates over the sorted intermediate data and for each unique intermediate key encountered, it passes the key and the corresponding set of intermediate values to the user's Reduce function. The output of the Reduce function is appended to a final output file for this reduce partition.&lt;br /&gt;
# When all map tasks and reduce tasks have been completed, the master wakes up the user program. At this point, the MapReduce call in the user program returns back to the user code.&lt;br /&gt;
# After successful completion, the output of the mapreduce execution is available in the ''R'' output files (one per reduce task, with file names as specified by the user). Typically, users do not need to combine these ''R'' output files into one file . They often pass these files as input to another MapReduce call, or use them from another distributed application that is able to deal with input that is partitioned into multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Data Structures: Master ===&lt;br /&gt;
&lt;br /&gt;
The master keeps several data structures. For each map task and reduce task, it stores the state (idle, in-progress, or completed), and the identity of the worker machine (for non-idle tasks).&lt;br /&gt;
The master is the conduit through which the location of intermediate file regions is propagated from map tasks to reduce tasks. Therefore, for each completed map task, the master stores the locations and sizes of the ''R'' intermediate file regions produced by the map task. Updates to this location and size information are received as map tasks are completed. The information is pushed incrementally to workers that have in-progress reduce tasks.&lt;br /&gt;
&lt;br /&gt;
=== Fault Tolerance ===&lt;br /&gt;
&lt;br /&gt;
Since the MapReduce library is designed to help process very large amounts of data using hundreds or thousands of machines, the library must tolerate machine failures gracefully.&lt;br /&gt;
&lt;br /&gt;
* '''Master Failure'''&lt;br /&gt;
&lt;br /&gt;
It is easy to make the master write periodic checkpoints of the master data structures. If the master task dies, a new copy can be started from the last checkpoint. However, given that there is only a single master, its failure is unlikely; therefore Google's current implementation aborts the MapReduce computation if the master fails. Clients can check for this condition and retry the MapReduce operation if they desire.&lt;br /&gt;
&lt;br /&gt;
* '''Worker Failure'''&lt;br /&gt;
&lt;br /&gt;
The master pings every worker periodically. If no response is received from a worker in a certain amount of time, the master marks the worker as failed. Any map tasks completed by the worker are reset back to their initial idle state, and therefore become eligible for scheduling&lt;br /&gt;
on other workers. Similarly, any map task or reduce task in progress on a failed worker is also reset to idle and becomes eligible for rescheduling. Completed map tasks are re-executed on a failure because their output is stored on the local disk(s) of the failed machine and is therefore inaccessible. Completed reduce tasks do not need to be re-executed since their output is stored in a global file system. When a map task is executed first by worker ''A'' and then later executed by worker ''B'' (because ''A'' failed), all workers executing reduce tasks are notified of the re-execution. Any reduce task that has not already read the data from worker ''A'' will read the data from worker ''B''. MapReduce is resilient to large-scale worker failures.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Large variety of problems are easily expressible as Map-Reduce computations. &lt;br /&gt;
# The model is easy to use, even for programmers without experience with parallel and distributed systems, since it hides the details of parallelization, fault tolerance, locality optimization, and load balancing. For example, Map-Reduce is used for the generation of data for Google’s production Web search service, for sorting, data mining, machine learning, and many other systems.&lt;br /&gt;
# Implementation of Map-Reduce can be scaled to large clusters of machines comprising thousands of machines.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# Restricted programming model puts bounds on the way you implement the framework. &lt;br /&gt;
# Since network bandwidth is scarce, a number of optimization in the system are therefore targeted at reducing the amount of data sent across the network.&lt;br /&gt;
&lt;br /&gt;
=== Apache’s Hadoop MapReduce ===&lt;br /&gt;
&lt;br /&gt;
Apache, after Google published the paper on MapReduce and Google File System (GFS &amp;lt;ref&amp;gt;http://www.cs.rochester.edu/meetings/sosp2003/papers/p125-ghemawat.pdf Google File System&amp;lt;/ref&amp;gt;) introduced it's own implementation of the same. The important thing to note here is that Apache made this framework open-source. This framework transparently provides both reliability and data motion to applications. Hadoop has prominent users such as Yahoo! and Facebook.&lt;br /&gt;
(Good Read!&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Apache_Hadoop Apache Hadoop&amp;lt;/ref&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Hadoop MapRed is based on a “pull” model where multiple “TaskTrackers” poll the “JobTracker” for tasks (either map task or reduce task).&lt;br /&gt;
&lt;br /&gt;
[[File:HMR.png|center|Apache Hadoop MapReduce]]&lt;br /&gt;
The figure above depicts the execution of the job.&amp;lt;ref&amp;gt;http://horicky.blogspot.com/2008/11/hadoop-mapreduce-implementation.html Pragmatic Guide&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Client program uploads files to the Hadoop Distributed File System (HDFS) location and notifies the JobTracker which in turn returns the Job ID to the client. &lt;br /&gt;
* The Jobtracker allocates map tasks to the TaskTrackers. &lt;br /&gt;
* JobTracker determines appropriate jobs based on how busy the TaskTracker is. &lt;br /&gt;
* TaskTracker forks MapTask which extracts input data and invokees the user provided &amp;quot;map&amp;quot; function which fills in the buffer with key/value pairs until it is full. &lt;br /&gt;
* The buffer is eventually flushed into two files. &lt;br /&gt;
* After all the MapTask completes (all splits are done), the TaskTracker will notify the JobTracker which keeps track of the overall progress of job.&lt;br /&gt;
* When done, the JobTracker notifies TaskTracker to jump to reduce phase. This again follows same method where reduce task is forked. &lt;br /&gt;
* The output of each reducer is written to a temporary output file in HDFS. When the reducer finishes processing all keys, the temp output file will be renamed atomically to its final output filename.&lt;br /&gt;
&lt;br /&gt;
== Phoenix ==&lt;br /&gt;
Phoenix&amp;lt;ref&amp;gt;&lt;br /&gt;
http://csl.stanford.edu/~christos/publications/2007.cmp_mapreduce.hpca.pdf Evaluating MapReduce for Multi-core and Multiprocessor Systems&amp;lt;/ref&amp;gt; implements MapReduce for shared-memory systems. Its goal is to support efficient execution on multiple cores without burdening the programmer with concurrency management. Phoenix consists of a simple API that is visible to application programmers and an efficient runtime that handles parallelization, resource management, and fault recovery.&lt;br /&gt;
&lt;br /&gt;
=== Phoenix API ===&lt;br /&gt;
The current Phoenix implementation provides an API for C and C++. &amp;lt;br&amp;gt;&lt;br /&gt;
* The first set is provided by Phoenix and is used by the programmer’s application code to initialize the system and emit output pairs (1 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
* The second set includes the functions that the programmer defines (3 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from the Map and Reduce functions, the user provides functions that partition the data before each step and a function that implements key comparison. The function arguments are declared as void pointers wherever possible to provide flexibility in their declaration and fast use without conversion overhead. The data structure used to communicate basic function information and buffer allocation between the user code and run-time is of type ''scheduler_args_t'' ([http://pages.cs.wisc.edu/~gibson/mapreduceexample/MapReduceScheduler.h.html MapReduce Header File]). There are additional data structure types to facilitate communication between the Splitter, Map, Partition, and Reduce functions. These types use pointers whenever possible to implement communication without actually copying significant amounts of data.&lt;br /&gt;
&lt;br /&gt;
The Phoenix API does not rely on any specific compiler options and does not require a parallelizing compiler. However, it assumes that its functions can freely use stack-allocated and heap-allocated structures for private data. It also assumes that there is no communication through shared-memory structures other than the input/output buffers for these functions. For C/C++, these assumptions cannot be checked statically for arbitrary programs. Although there are stringent checks within the system to ensure valid data are communicated between user and run-time code, eventually it is the task of user to provide functionally correct code. &lt;br /&gt;
&lt;br /&gt;
[[File:Phoenix.jpg|center|Phoenix MapReduce]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Phoenix run-time was developed on top of [http://en.wikipedia.org/wiki/POSIX_Threads POSIX threads], but can be easily ported to other shared memory thread packages. The figure above shows the basic data flow for the run-time system. &lt;br /&gt;
&lt;br /&gt;
* The run-time is controlled by the scheduler, which is initiated by user code. &lt;br /&gt;
* The scheduler creates and manages the threads that run all Map and Reduce tasks. It also manages the buffers used for task communication. &lt;br /&gt;
* The programmer provides the scheduler with all the required data and function pointers through the ''scheduler_args_t'' structure. &lt;br /&gt;
*After initialization, the scheduler determines the number of cores to use for this computation. For each core, it spawns a worker thread that is dynamically assigned some number of Map and Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
To start the '''Map''' stage, the scheduler uses the ''Splitter'' to divide input pairs into equally sized units to be processed by the Map tasks. The Splitter is called once per Map task and returns a pointer to the data the Map task will process. The Map tasks are allocated dynamically to workers and each one emits intermediate &amp;lt;key,value&amp;gt; pairs. The ''Partition'' function splits the intermediate pairs into units for the Reduce tasks. The function ensures all values of the same key go to the same unit. Within each buffer, values are ordered by key to assist with the final sorting. At this point, the Map stage is over. The scheduler must wait for all Map tasks to complete before initiating the Reduce stage.&lt;br /&gt;
&lt;br /&gt;
'''Reduce''' tasks are also assigned to workers dynamically, similar to Map tasks. The one difference is that, while with Map tasks there is complete freedom in distributing pairs across tasks, with Reduce all values for the same key must be processed in one task. Hence, the Reduce stage may exhibit higher imbalance across workers and dynamic scheduling is more important. The output of each Reduce task is already sorted by key. As the last step, the final output from all tasks is merged into a single buffer, sorted by keys.&lt;br /&gt;
&lt;br /&gt;
=== Buffer Management ===&lt;br /&gt;
Two types of temporary buffers are necessary to store data between the various stages. All buffers are allocated in shared memory but are accessed in a well specified way by a few functions. To re-arrange buffers (e.g., split across tasks), pointer manipulation is done instead of the actual pairs, which may be large in size. The intermediate buffers are not directly visible to user code. Map-Reduce buffers are used to store the intermediate output pairs. Each worker has its own set of buffers. The buffers are initially sized to a default value and then resized dynamically as needed. At this stage, there may be multiple pairs with the same key. To accelerate the Partition function, the Emit intermediate function stores all values for the same key in the same buffer. At the end of the Map task, each buffer is sorted by key order. Reduce- Merge buffers are used to store the outputs of Reduce tasks before they are sorted. At this stage, each key has only one value associated with it. After sorting, the final output is available in the user allocated Output data buffer.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Phoenix is fast and scalable across all workloads&lt;br /&gt;
# On clusters of machines, the combiner function reduces the number of key-value pairs that must be exchanged between machines. These combiners contribute to better data locality and lower memory allocation pressure, resulting in substantial number of applications being scalable.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&amp;lt;ref&amp;gt;http://csl.stanford.edu/~christos/publications/2011.phoenixplus.mapreduce.pdf Phoenix++: Modular MapReduce for Shared Memory Systems&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Due to shared memory there is an inefficient  key-Value storage since containers must provide fast lookup and retrieval over potentially large data-set, all the while coordinating accesses across multiple threads&lt;br /&gt;
#Ineffective Combiner : However, on SMP machines memory allocation costs tend to dominate, even more than the memory traffic. Combiners fail to reduce the memory allocation pressure, since generated key-value pairs must still be stored. Further, by the time the combiners are run, those pairs may no longer be in the cache causing expensive memory access penalties.&lt;br /&gt;
#Phoenix implements internally grouping tasks into chunks to reduce scheduling costs and amortize per-task overhead. This design enables the user-implemented optimizations described in the previous two sections. However, it also has two drawbacks. Firstly, since the code for grouping tasks is pushed into user code, map function becomes more complicated due to the extra code to deal with chunks. Secondly, if the user leverages the exposed chunk to improve performance, the framework can no longer freely adjust the chunk size since doing so will affect the efficiency of the map function.&lt;br /&gt;
&lt;br /&gt;
== Map Reduce on Graphics Processors ==&lt;br /&gt;
=== Challenges ===&lt;br /&gt;
&lt;br /&gt;
Compared with CPUs, the hardware architecture of GPUs differs significantly. For instance, current GPUs have over one hundred [http://encyclopedia.jrank.org/articles/pages/6904/SIMD-Single-Instruction-Multiple-Data-Processing.html SIMD (Single Instruction Multiple Data)] processors whereas current multi-core CPUs offer a much smaller number of cores. Moreover, most GPUs do not support atomic operations or locks. &lt;br /&gt;
&lt;br /&gt;
Due to the architectural differences, there are following three technical challenges in implementing the MapReduce framework on the GPU. &lt;br /&gt;
# The synchronization overhead in the run-time system of the framework must be low so that the system can scale to hundreds of processors.&lt;br /&gt;
# Due to the lack of dynamic thread scheduling on current GPUs, it is essential to allocate work evenly across threads on the GPU to exploit its massive thread parallelism. &lt;br /&gt;
# The core tasks of MapReduce programs, including string processing, file manipulation and concurrent reads and writes, are unconventional to GPUs and must be handled efficiently.&lt;br /&gt;
&lt;br /&gt;
'''''Mars''''', MapReduce framework on the GPU was designed and implemented with these challenges in mind.&amp;lt;ref&amp;gt;http://www.ece.rutgers.edu/~parashar/Classes/08-09/ece572/readings/mars-pact-08.pdf Mars: A MapReduce Framework on Graphic Processors&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mars API ===&lt;br /&gt;
&lt;br /&gt;
Mars provides a small set of APIs that are similar to those of CPU-based MapReduce. Run-time system utilizes a large number of GPU threads for Map or Reduce tasks, and automatically assigns each thread a small number of key/value pairs to work on. As a result, the massive thread parallelism on the GPU is well utilized. To avoid any conflict between concurrent writes,  Mars has a lock-free scheme with low runtime overhead on the massive thread parallelism of the GPU. This scheme guarantees the correctness of parallel execution with little synchronization overhead. &lt;br /&gt;
&lt;br /&gt;
Mars has two kinds of APIs, the ''user-implemented APIs'', which the users implement, and the ''system-provided APIs'', which the users can use as library calls. &lt;br /&gt;
&lt;br /&gt;
* Mars has the following user-implemented APIs. These APIs are implemented with C/C++. ''void*'' type has been used so that the developer can manipulate strings and other complex data types conveniently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//MAP_COUNT counts result size of the map function.&lt;br /&gt;
voidMAP_COUNT(void *key, void *val, int keySize, int valSize);&lt;br /&gt;
&lt;br /&gt;
//The map function.&lt;br /&gt;
voidMAP(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
&lt;br /&gt;
//REDUCE_COUNT counts result size of the reduce function.&lt;br /&gt;
void REDUCE_COUNT(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
&lt;br /&gt;
//The reduce function.&lt;br /&gt;
void REDUCE(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Mars has the following four system-provided APIs. The emit functions are used in user-implemented map and reduce functions to output the intermediate/final results.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Emit the key size and the value size inMAP_COUNT.&lt;br /&gt;
void EMIT_INTERMEDIATE_COUNT(int keySize, int valSize);&lt;br /&gt;
&lt;br /&gt;
//Emit an intermediate result in MAP.&lt;br /&gt;
void EMIT_INTERMEDIATE(void* key, void* val, int keySize, int valSize);&lt;br /&gt;
&lt;br /&gt;
//Emit the key size and the value size in REDUCE_COUNT.&lt;br /&gt;
void EMIT_COUNT(int keySize, int valSize);&lt;br /&gt;
&lt;br /&gt;
//Emit a final result in REDUCE.&lt;br /&gt;
void EMIT(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Overall, the APIs in Mars are similar to those in the existing MapReduce frameworks such as Hadoop and Phoenix. The major difference is that Mars needs two APIs to implement the functionality of each CPU-based API. One is to count the size of results, and the other one is to output the results. This is because the GPU does not support atomic operations, and the Mars runtime uses a two-step design for the result output.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Details ===&lt;br /&gt;
&lt;br /&gt;
* Since the GPU does not support dynamic memory allocation on the device memory during the execution of the GPU code, arrays are used as the main data structure. &lt;br /&gt;
* The input data, the intermediate result and the final result are stored in three kinds of arrays, i.e., the key array, the value array and the directory index. The directory index consists of an entry of &amp;lt;key offset, key size, value offset, value size&amp;gt; for each key/value pair. &lt;br /&gt;
* Given a directory index entry, the key or the value at the corresponding offset in the key array or the value array is fetched. &lt;br /&gt;
* With the array structure, for the input data as well as for the result output the space on the device memory is allocated before executing the GPU program. However, the sizes of the output from the map and the reduce stages are unknown. The output scheme for the map stage is similar to that for the reduce stage.&lt;br /&gt;
&lt;br /&gt;
First, each map task outputs three counts, i.e., the number of intermediate results, the total size of keys (in bytes) and the total size of values (in bytes) generated by the map task. Based on key sizes (or value sizes) of all map tasks, the run-time system computes a prefix sum on these sizes and produces an array of write locations. A write location is the start location in the output array for the corresponding map task to write. Based on the number of intermediate results, the run-time system computes a prefix sum and produces an array of start locations in the output directory index for the corresponding map task. Through these prefix sums, the sizes of the arrays for the intermediate result is also known. Thus, the run-time allocates arrays in the device memory with the exact size for storing the intermediate results.&lt;br /&gt;
&lt;br /&gt;
Second, each map task outputs the intermediate key/value pairs to the output array and updates the directory index. Since each map has its deterministic and non-overlapping positions to write to, the write conflicts are avoided. This two-step scheme does not require the hardware support of atomic functions. It is suitable for the massive thread parallelism on the GPU. However, it doubles the map computation in the worst case. The overhead of this scheme is application dependent, and is usually much smaller than that in the worst case.&lt;br /&gt;
&lt;br /&gt;
=== Optimization Techniques ===&lt;br /&gt;
==== Memory Optimizations ====&lt;br /&gt;
Two memory optimizations are used to reduce the number of memory requests in order to improve the memory bandwidth utilization. &lt;br /&gt;
* '''Coalesced accesses'''&lt;br /&gt;
The GPU feature of coalesced accesses is utilized to improve the memory performance. The memory accesses of each thread to the data arrays are designed according to the coalesced access pattern when applicable. Suppose there are T threads in total and the number of key/value pairs is N in the map stage. Thread i processes the (i + T • k )th (k=0,..,N/T) key/value pair. Due to the SIMD property of the GPU, the memory addresses from the threads within a thread group are consecutive and these accesses are coalesced into one. The figure below illustrates the map stage with and without the coalesced access optimization.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mars.jpg]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Accesses using built-in vector types'''&lt;br /&gt;
Accessing the values in the device memory can be costly, because the data values are often&lt;br /&gt;
of different sizes and the accesses are hardly coalesced. Fortunately, GPUs such as G80 support built-in vector types such as char4 and int4. Reading built-in vectors fetches the entire vector&lt;br /&gt;
in a single memory request. Compared with reading char or int, the number of memory requests is greatly reduced and the memory performance is improved.&lt;br /&gt;
&lt;br /&gt;
==== Thread parallelism ====&lt;br /&gt;
The thread configuration, i.e., the number of thread groups and the number of threads per thread group, is related to multiple factors including, (1) the hardware configuration such as the number of multiprocessors and the on-chip computation resources such as the number of registers on each multiprocessor, (2) the computation characteristics of the map and the reduce tasks, e.g., they are memory- or computation-intensive. Since the map and the reduce functions are implemented by the developer, and their costs are unknown to the runtime system, it is difficult to find the optimal setting for the thread configuration at&lt;br /&gt;
run time.&lt;br /&gt;
&lt;br /&gt;
==== Handling variable-sized types ==== &lt;br /&gt;
The variable-sized types are supported with the directory index. If two key/value pairs need to be swapped, their corresponding entries in the directory index are swapped without modifying the key and the value arrays. This choice is to save the swapping cost since the directory entries are typically much smaller than the key/value pairs. Even though swapping changes the order of entries in the directory index, the array layout is preserved and therefore accesses to the directory index can still be coalesced after swaps. Since strings are a typical variable-sized type, and string processing is common in web data analysis tasks, a GPU-based string manipulation library was developed for Mars. The operations in the library include strcmp, strcat, memset and so on. The APIs of these operations are consistent with those in C/C++ library on the CPU. The difference is that simple algorithms for these GPU-based string operations were used, since they usually handle small strings within a map or a reduce task. In addition, char4 is used to implement strings to optimize the memory performance.&lt;br /&gt;
&lt;br /&gt;
==== Hashing ====&lt;br /&gt;
Hashing is used in the sort algorithm to store the results with the same key value consecutively. In that case, it is not needed that the results with the key values are in their strict ascending/ decreasing order. The hashing technique that hashes a key into a 32-bit integer is used, and the records are sorted according to their hash values. When two records are compared, their hash values are compared first. Only when their hash values are the same, their keys are fetched and compared. Given a good hash function, the probability of comparing the keys is low.&lt;br /&gt;
&lt;br /&gt;
==== File manipulation ====&lt;br /&gt;
Currently, the GPU cannot directly access the data in the hard disk. Thus, the file manipulation with the assistance of the CPU is performed in three phases. First, the file I/O on the CPU is performed and the file data is loaded into a buffer in the main memory. To reduce the I/O stall, multiple threads are used to perform the I/O task. Second, the preprocessing on the buffered data is performed and the input key/value pairs are obtained. Finally, the input key/value pairs are copied to the GPU device memory.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Provides a performance speedup of accessing data by using built-in vector types. These vector types  reduces the number of memory requests and improves the bandwidth utilization.&lt;br /&gt;
# Applications written on Mars may or may not have the reduce stage and thus improves speedup.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# GPU based applications are much more complex&lt;br /&gt;
# Mars currently handles data that can fit into the device memory but has not yet been checked to support massive data sets&lt;br /&gt;
&lt;br /&gt;
= More Examples =&lt;br /&gt;
Below are a few simple examples of programs that can be easily expressed as MapReduce computations.&lt;br /&gt;
*Distributed [http://unixhelp.ed.ac.uk/CGI/man-cgi?grep Grep]: The map function emits a line if it matches a given pattern. The reduce function is an identity function that just copies the supplied intermediate data to the output. &amp;lt;br&amp;gt;&lt;br /&gt;
*Count of URL Access Frequency: The map function processes logs of web page requests and outputs &amp;lt;URL, 1&amp;gt;. The reduce function adds together all values for the same URL and emits a &amp;lt;URL, total count&amp;gt; pair. &amp;lt;br&amp;gt;&lt;br /&gt;
*[http://books.google.com/books?id=gJrmszNHQV4C&amp;amp;pg=PA376&amp;amp;lpg=PA376&amp;amp;dq=what+is+reverse+web+link+graph&amp;amp;source=bl&amp;amp;ots=rLQ2yuV6oc&amp;amp;sig=wimcG_7MR7d9g-ePGXkEK1ANmws&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ei=BtxBT5HkN42DtgefhbXRBQ&amp;amp;ved=0CEwQ6AEwBg#v=onepage&amp;amp;q=what%20is%20reverse%20web%20link%20graph&amp;amp;f=false Reverse Web-Link Graph]: The map function outputs &amp;lt;target, source&amp;gt; pairs for each link to a target URL found in a page named &amp;quot;source&amp;quot;. The reduce function concatenates the list of all source URLs associated with a given target URL and emits the pair: &amp;lt;target, list(source)&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
*Term-Vector per Host: A term vector summarizes the most important words that occur in a document or a set of documents as a list of &amp;lt;word, frequency&amp;gt; pairs. The map function emits a &amp;lt;hostname, term vector&amp;gt; pair for each input document (where the hostname is extracted from the URL of the document). The reduce function is passed all per-document term vectors for a given host. It adds these term vectors together, throwing away infrequent terms, and then emits a final &amp;lt;hostname, term vector&amp;gt; pair.&amp;lt;br&amp;gt;&lt;br /&gt;
*[http://nlp.stanford.edu/IR-book/html/htmledition/a-first-take-at-building-an-inverted-index-1.html Inverted Index]: The map function parses each document, and emits a sequence of &amp;lt;word, document ID&amp;gt; pairs. The reduce function accepts all pairs for a given word, sorts the corresponding document IDs and emits a &amp;lt;word, list(document ID)&amp;gt; pair. The set of all output pairs forms a simple inverted index. It is easy to augment this computation to keep track of word positions.&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Google’s MapReduce runtime implementation targets large clusters of Linux PCs connected through Ethernet switches. Tasks are forked using remote procedure calls. Buffering and communication occurs by reading and writing files on a distributed file system. The locality optimizations focus mostly on avoiding remote file accesses. While such a system is effective with distributed computing, it leads to very high overheads if used with shared-memory systems that facilitate communication through memory and are typically of much smaller scale.&lt;br /&gt;
&lt;br /&gt;
Phoenix, implementation of MapReduce uses shared memory and minimizes the overheads of task spawning and data communication. With Phoenix,the programmer can provide a simple, functional expression of the algorithm and leaves parallelization and scheduling to the runtime system.Phoenix leads to scalable performance for both multi-core chips and conventional symmetric multiprocessors. Phoenix automatically handles key scheduling decisions during parallel execution. Despite runtime overheads, results have shown that performance of Phoenix to that of parallel code written in P-threads API are almost similar. Nevertheless,there are also applications that do not fit naturally in the MapReduce model for which P-threads code performs significantly better.&lt;br /&gt;
&lt;br /&gt;
Graphics processors have emerged as a commodity platform for parallel computing. However, the developer requires the knowledge of the GPU architecture and much effort in developing GPU applications. Such difficulty is even more for complex and performance centric tasks such as web data analysis. Since MapReduce has been successful in easing the development of web data analysis tasks, one can use a GPU-based MapReduce for these applications. With the GPU-based framework, the developer writes their code using the simple and familiar MapReduce interfaces. The runtime on the GPU is completely hidden from the developer by the framework.&lt;br /&gt;
&lt;br /&gt;
The framework is followed by criticisms as well. Google was awarded the patent for MapReduce, but it can be argued that this technology is similar to many other already existing ones. There are programming models that are similar to MapReduce like Algorithm Skeletons (Parallelism Patterns), Sector/Sphere, Datameer Analytics Solution. Algorithm Skeletons are a high-level parallel programming model for parallel and distributed computing.This frameowrk libraries are used for a number of applications. Sector/Sphere is a distributed file system targeting data storage over a large number of commodity computers. Sphere is the programming framework that supports massive in-storage parallel data processing for data stored in Sector. Additionally, Sector/Sphere is unique in its ability to operate in a wide area network (WAN) setting. Datameer Analytics Solution (DAS) is a business integration platform for Hadoop and includes data source integration, an analytics engine with a spreadsheet interface designed for business users with over 180 analytic functions and visualization including reports, charts and dashboards.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Interesting Read =&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Algorithmic_skeleton#Frameworks_and_libraries Algorithm Skeleton]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Sector/Sphere Sector/Sphere]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Datameer Datameer Analytic Solution]&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73451</id>
		<title>CSC/ECE 506 Spring 2013/3b xz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73451"/>
		<updated>2013-02-21T01:09:26Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to MapReduce =&lt;br /&gt;
[[File:Mapreduce.png|thumbnail|MapReduce for a Shape Counter]]&lt;br /&gt;
MapReduce is a software framework introduced by Google in 2004 to support [http://publib.boulder.ibm.com/infocenter/txformp/v6r0m0/index.jsp?topic=%2Fcom.ibm.cics.te.doc%2Ferziaz0015.htm distributed computing] on large data sets on clusters of computers. &lt;br /&gt;
&lt;br /&gt;
MapReduce programming model consists of two major steps: &lt;br /&gt;
&lt;br /&gt;
* In the '''map''' step, the problem being solved is divided into a series of sub-problems and distributed to different workers. &lt;br /&gt;
&lt;br /&gt;
* After collecting results from workers, the computation enters the '''reduce''' step to combine and produce the final result.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of the Programming Model =&lt;br /&gt;
&lt;br /&gt;
The MapReduce programming model is inspired by [http://enfranchisedmind.com/blog/posts/what-is-a-functional-programming-language/ functional languages] and targets data-intensive computations. &lt;br /&gt;
&lt;br /&gt;
The input data format is application-specific, and is specified by the user. The output is a set of &amp;lt;key,value&amp;gt; pairs. The user expresses an algorithm using two functions, Map and Reduce. The Map function is applied on the input data and produces a list of intermediate &amp;lt;key,value&amp;gt; pairs. The Reduce function is applied to all intermediate pairs with the same key. It typically performs some kind of merging operation and produces zero or more output pairs. Finally, the output pairs are sorted by their key value. In the simplest form of MapReduce programs, the programmer provides just the Map function. All other functionality, including the grouping of the intermediate pairs which have the same key and the final sorting, is provided by the runtime.&lt;br /&gt;
&lt;br /&gt;
The programmer provides a simple description of the algorithm that focuses on functionality and not on parallelization. The actual parallelization and the details of [http://en.wikipedia.org/wiki/Concurrency_(computer_science)/ concurrency] management are left to the runtime system. Hence the program code is generic and easily portable across systems. Nevertheless, the model provides sufficient high-level information for parallelization. The Map function can be executed in parallel on non-overlapping portions of the input data and the Reduce function can be executed in parallel on each set of intermediate pairs with the same key. Similarly, since it is explicitly known which pairs each function will operate upon, one can employ pre-fetching or other scheduling optimizations for locality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Sample Code''&lt;br /&gt;
&lt;br /&gt;
The following pseudo-code shows the basic structure of a MapReduce program. &lt;br /&gt;
&lt;br /&gt;
Program to counts number of occurrences of each word in a collection of documents.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Input : a Document&lt;br /&gt;
//Intermediate Output: key = word, value = 1&lt;br /&gt;
Map(void * input){&lt;br /&gt;
   for each word w in Input&lt;br /&gt;
       Emit Intermediate(w,1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Intermediate Output key = word, value = 1&lt;br /&gt;
//Output : key = word, value = occurrences&lt;br /&gt;
Reduce(String key, Iterator values){&lt;br /&gt;
   int result = 0;&lt;br /&gt;
   for each v in values &lt;br /&gt;
       result += v&lt;br /&gt;
   Emit(w, result)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Role of the Run-time System =&lt;br /&gt;
In both steps of MapReduce, the run-time must decide on factors such as the size of the units, the number of nodes involved, how units are assigned to nodes dynamically, and how buffer space is allocated. The decisions can be fully automatic or guided by the programmer given application specific knowledge. These decisions allow the run-time to execute a program efficiently across a wide range of machines and data-set scenarios without modifications to the source code. Finally, the run-time must merge and sort the output pairs from all Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
= Implementations =&lt;br /&gt;
Many different implementations of the MapReduce interface are possible. The right choice depends on the environment. For example, one implementation may be suitable for a small shared-memory machine, another for a large [http://msdn.microsoft.com/en-us/library/ms178144.aspx NUMA] multi-processor, and yet another for an even larger collection of networked machines. &lt;br /&gt;
&lt;br /&gt;
* Google's MapReduce and [http://en.wikipedia.org/wiki/Apache_Hadoop Hadoop] implement map reduce for large clusters of commodity PCs connected together with switched Ethernet.&lt;br /&gt;
&lt;br /&gt;
* [http://mapreduce.stanford.edu/ Phoenix] implements MapReduce for shared-memory systems.&lt;br /&gt;
&lt;br /&gt;
* [http://www.cse.ust.hk/gpuqp/Mars.html Mars] is a MapReduce framework on graphics processors ([http://www.nvidia.com/object/gpu.html GPUs]).&lt;br /&gt;
&lt;br /&gt;
== Google's MapReduce ==&lt;br /&gt;
&lt;br /&gt;
=== Execution Overview ===&lt;br /&gt;
The Map invocations are distributed across multiple machines by automatically partitioning the input data into a set of M splits. The input splits can be processed in parallel by different machines. Reduce invocations are distributed by partitioning the intermediate key space into R pieces using a partitioning function (e.g., hash(key) mod R). The number of partitions (R) and the partitioning function are specified by the user. Below is a detailed look. &amp;lt;ref&amp;gt;http://static.usenix.org/event/osdi04/tech/full_papers/dean/dean.pdf Simplified Data Processing on Large Clusters&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Google Map Reduce.jpg|center|Google's MapReduce]] &amp;lt;br&amp;gt;&lt;br /&gt;
The figure above shows the overall flow of a MapReduce operation in Google's implementation. When the user program calls the MapReduce function, the following sequence of actions occurs (the numbered labels in the figure above correspond to the numbers in the list below):&lt;br /&gt;
&lt;br /&gt;
# The MapReduce library in the user program first splits the input files into M pieces of typically 16 megabytes to 64 megabytes (MB) per piece (controllable by the user via an optional parameter). It then starts up many copies of the program on a cluster of machines.&lt;br /&gt;
# One of the copies of the program is special, ''the master''. The rest are workers that are assigned work by the master. There are ''M'' map tasks and R reduce tasks to assign. The master picks idle workers and assigns each one a map task or a reduce task.&lt;br /&gt;
# A worker who is assigned a map task reads the contents of the corresponding input split. It parses ''key/value'' pairs out of the input data and passes each pair to the user-defined Map function. The intermediate ''key/value'' pairs produced by the Map function are buffered in memory. &lt;br /&gt;
# Periodically, the buffered pairs are written to local disk, partitioned into ''R'' regions by the partitioning function. The locations of these buffered pairs on the local disk are passed back to the master, who is responsible for forwarding these locations to the reduce workers. When a reduce worker is notified by the master about these locations, it uses remote procedure calls to read the buffered data from the local disks of the  map workers.&lt;br /&gt;
# When a reduce worker has read all intermediate data, it sorts it by the intermediate keys so that all occurrences of the same key are grouped together. The sorting is needed because typically many different keys map to the same reduce task. If the amount of intermediate data is too large to fit in memory, an external sort is used.&lt;br /&gt;
# The reduce worker iterates over the sorted intermediate data and for each unique intermediate key encountered, it passes the key and the corresponding set of intermediate values to the user's Reduce function. The output of the Reduce function is appended to a final output file for this reduce partition.&lt;br /&gt;
# When all map tasks and reduce tasks have been completed, the master wakes up the user program. At this point, the MapReduce call in the user program returns back to the user code.&lt;br /&gt;
# After successful completion, the output of the mapreduce execution is available in the ''R'' output files (one per reduce task, with file names as specified by the user). Typically, users do not need to combine these ''R'' output files into one file . They often pass these files as input to another MapReduce call, or use them from another distributed application that is able to deal with input that is partitioned into multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Data Structures: Master ===&lt;br /&gt;
&lt;br /&gt;
The master keeps several data structures. For each map task and reduce task, it stores the state (idle, in-progress, or completed), and the identity of the worker machine (for non-idle tasks).&lt;br /&gt;
The master is the conduit through which the location of intermediate file regions is propagated from map tasks to reduce tasks. Therefore, for each completed map task, the master stores the locations and sizes of the ''R'' intermediate file regions produced by the map task. Updates to this location and size information are received as map tasks are completed. The information is pushed incrementally to workers that have in-progress reduce tasks.&lt;br /&gt;
&lt;br /&gt;
=== Fault Tolerance ===&lt;br /&gt;
&lt;br /&gt;
Since the MapReduce library is designed to help process very large amounts of data using hundreds or thousands of machines, the library must tolerate machine failures gracefully.&lt;br /&gt;
&lt;br /&gt;
* '''Master Failure'''&lt;br /&gt;
&lt;br /&gt;
It is easy to make the master write periodic checkpoints of the master data structures. If the master task dies, a new copy can be started from the last checkpoint. However, given that there is only a single master, its failure is unlikely; therefore Google's current implementation aborts the MapReduce computation if the master fails. Clients can check for this condition and retry the MapReduce operation if they desire.&lt;br /&gt;
&lt;br /&gt;
* '''Worker Failure'''&lt;br /&gt;
&lt;br /&gt;
The master pings every worker periodically. If no response is received from a worker in a certain amount of time, the master marks the worker as failed. Any map tasks completed by the worker are reset back to their initial idle state, and therefore become eligible for scheduling&lt;br /&gt;
on other workers. Similarly, any map task or reduce task in progress on a failed worker is also reset to idle and becomes eligible for rescheduling. Completed map tasks are re-executed on a failure because their output is stored on the local disk(s) of the failed machine and is therefore inaccessible. Completed reduce tasks do not need to be re-executed since their output is stored in a global file system. When a map task is executed first by worker ''A'' and then later executed by worker ''B'' (because ''A'' failed), all workers executing reduce tasks are notified of the re-execution. Any reduce task that has not already read the data from worker ''A'' will read the data from worker ''B''. MapReduce is resilient to large-scale worker failures.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Large variety of problems are easily expressible as Map-Reduce computations. &lt;br /&gt;
# The model is easy to use, even for programmers without experience with parallel and distributed systems, since it hides the details of parallelization, fault tolerance, locality optimization, and load balancing. For example, Map-Reduce is used for the generation of data for Google’s production Web search service, for sorting, data mining, machine learning, and many other systems.&lt;br /&gt;
# Implementation of Map-Reduce can be scaled to large clusters of machines comprising thousands of machines.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# Restricted programming model puts bounds on the way you implement the framework. &lt;br /&gt;
# Since network bandwidth is scarce, a number of optimization in the system are therefore targeted at reducing the amount of data sent across the network.&lt;br /&gt;
&lt;br /&gt;
=== Apache’s Hadoop MapReduce ===&lt;br /&gt;
&lt;br /&gt;
Apache, after Google published the paper on MapReduce and Google File System (GFS &amp;lt;ref&amp;gt;http://www.cs.rochester.edu/meetings/sosp2003/papers/p125-ghemawat.pdf Google File System&amp;lt;/ref&amp;gt;) introduced it's own implementation of the same. The important thing to note here is that Apache made this framework open-source. This framework transparently provides both reliability and data motion to applications. Hadoop has prominent users such as Yahoo! and Facebook.&lt;br /&gt;
(Good Read!&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Apache_Hadoop Apache Hadoop&amp;lt;/ref&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Hadoop MapRed is based on a “pull” model where multiple “TaskTrackers” poll the “JobTracker” for tasks (either map task or reduce task).&lt;br /&gt;
&lt;br /&gt;
[[File:HMR.png|center|Apache Hadoop MapReduce]]&lt;br /&gt;
The figure above depicts the execution of the job.&amp;lt;ref&amp;gt;http://horicky.blogspot.com/2008/11/hadoop-mapreduce-implementation.html Pragmatic Guide&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Client program uploads files to the Hadoop Distributed File System (HDFS) location and notifies the JobTracker which in turn returns the Job ID to the client. &lt;br /&gt;
* The Jobtracker allocates map tasks to the TaskTrackers. &lt;br /&gt;
* JobTracker determines appropriate jobs based on how busy the TaskTracker is. &lt;br /&gt;
* TaskTracker forks MapTask which extracts input data and invokees the user provided &amp;quot;map&amp;quot; function which fills in the buffer with key/value pairs until it is full. &lt;br /&gt;
* The buffer is eventually flushed into two files. &lt;br /&gt;
* After all the MapTask completes (all splits are done), the TaskTracker will notify the JobTracker which keeps track of the overall progress of job.&lt;br /&gt;
* When done, the JobTracker notifies TaskTracker to jump to reduce phase. This again follows same method where reduce task is forked. &lt;br /&gt;
* The output of each reducer is written to a temporary output file in HDFS. When the reducer finishes processing all keys, the temp output file will be renamed atomically to its final output filename.&lt;br /&gt;
&lt;br /&gt;
== Phoenix ==&lt;br /&gt;
Phoenix&amp;lt;ref&amp;gt;&lt;br /&gt;
http://csl.stanford.edu/~christos/publications/2007.cmp_mapreduce.hpca.pdf Evaluating MapReduce for Multi-core and Multiprocessor Systems&amp;lt;/ref&amp;gt; implements MapReduce for shared-memory systems. Its goal is to support efficient execution on multiple cores without burdening the programmer with concurrency management. Phoenix consists of a simple API that is visible to application programmers and an efficient runtime that handles parallelization, resource management, and fault recovery.&lt;br /&gt;
&lt;br /&gt;
=== Phoenix API ===&lt;br /&gt;
The current Phoenix implementation provides an API for C and C++. &amp;lt;br&amp;gt;&lt;br /&gt;
* The first set is provided by Phoenix and is used by the programmer’s application code to initialize the system and emit output pairs (1 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
* The second set includes the functions that the programmer defines (3 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from the Map and Reduce functions, the user provides functions that partition the data before each step and a function that implements key comparison. The function arguments are declared as void pointers wherever possible to provide flexibility in their declaration and fast use without conversion overhead. The data structure used to communicate basic function information and buffer allocation between the user code and run-time is of type ''scheduler_args_t'' ([http://pages.cs.wisc.edu/~gibson/mapreduceexample/MapReduceScheduler.h.html MapReduce Header File]). There are additional data structure types to facilitate communication between the Splitter, Map, Partition, and Reduce functions. These types use pointers whenever possible to implement communication without actually copying significant amounts of data.&lt;br /&gt;
&lt;br /&gt;
The Phoenix API does not rely on any specific compiler options and does not require a parallelizing compiler. However, it assumes that its functions can freely use stack-allocated and heap-allocated structures for private data. It also assumes that there is no communication through shared-memory structures other than the input/output buffers for these functions. For C/C++, these assumptions cannot be checked statically for arbitrary programs. Although there are stringent checks within the system to ensure valid data are communicated between user and run-time code, eventually it is the task of user to provide functionally correct code. &lt;br /&gt;
&lt;br /&gt;
[[File:Phoenix.jpg|center|Phoenix MapReduce]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Phoenix run-time was developed on top of [http://en.wikipedia.org/wiki/POSIX_Threads POSIX threads], but can be easily ported to other shared memory thread packages. The figure above shows the basic data flow for the run-time system. &lt;br /&gt;
&lt;br /&gt;
* The run-time is controlled by the scheduler, which is initiated by user code. &lt;br /&gt;
* The scheduler creates and manages the threads that run all Map and Reduce tasks. It also manages the buffers used for task communication. &lt;br /&gt;
* The programmer provides the scheduler with all the required data and function pointers through the ''scheduler_args_t'' structure. &lt;br /&gt;
*After initialization, the scheduler determines the number of cores to use for this computation. For each core, it spawns a worker thread that is dynamically assigned some number of Map and Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
To start the '''Map''' stage, the scheduler uses the ''Splitter'' to divide input pairs into equally sized units to be processed by the Map tasks. The Splitter is called once per Map task and returns a pointer to the data the Map task will process. The Map tasks are allocated dynamically to workers and each one emits intermediate &amp;lt;key,value&amp;gt; pairs. The ''Partition'' function splits the intermediate pairs into units for the Reduce tasks. The function ensures all values of the same key go to the same unit. Within each buffer, values are ordered by key to assist with the final sorting. At this point, the Map stage is over. The scheduler must wait for all Map tasks to complete before initiating the Reduce stage.&lt;br /&gt;
&lt;br /&gt;
'''Reduce''' tasks are also assigned to workers dynamically, similar to Map tasks. The one difference is that, while with Map tasks there is complete freedom in distributing pairs across tasks, with Reduce all values for the same key must be processed in one task. Hence, the Reduce stage may exhibit higher imbalance across workers and dynamic scheduling is more important. The output of each Reduce task is already sorted by key. As the last step, the final output from all tasks is merged into a single buffer, sorted by keys.&lt;br /&gt;
&lt;br /&gt;
=== Buffer Management ===&lt;br /&gt;
Two types of temporary buffers are necessary to store data between the various stages. All buffers are allocated in shared memory but are accessed in a well specified way by a few functions. To re-arrange buffers (e.g., split across tasks), pointer manipulation is done instead of the actual pairs, which may be large in size. The intermediate buffers are not directly visible to user code. Map-Reduce buffers are used to store the intermediate output pairs. Each worker has its own set of buffers. The buffers are initially sized to a default value and then resized dynamically as needed. At this stage, there may be multiple pairs with the same key. To accelerate the Partition function, the Emit intermediate function stores all values for the same key in the same buffer. At the end of the Map task, each buffer is sorted by key order. Reduce- Merge buffers are used to store the outputs of Reduce tasks before they are sorted. At this stage, each key has only one value associated with it. After sorting, the final output is available in the user allocated Output data buffer.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Phoenix is fast and scalable across all workloads&lt;br /&gt;
# On clusters of machines, the combiner function reduces the number of key-value pairs that must be exchanged between machines. These combiners contribute to better data locality and lower memory allocation pressure, resulting in substantial number of applications being scalable.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&amp;lt;ref&amp;gt;http://csl.stanford.edu/~christos/publications/2011.phoenixplus.mapreduce.pdf Phoenix++: Modular MapReduce for Shared Memory Systems&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Due to shared memory there is an inefficient  key-Value storage since containers must provide fast lookup and retrieval over potentially large data-set, all the while coordinating accesses across multiple threads&lt;br /&gt;
#Ineffective Combiner : However, on SMP machines memory allocation costs tend to dominate, even more than the memory traffic. Combiners fail to reduce the memory allocation pressure, since generated key-value pairs must still be stored. Further, by the time the combiners are run, those pairs may no longer be in the cache causing expensive memory access penalties.&lt;br /&gt;
#Phoenix implements internally grouping tasks into chunks to reduce scheduling costs and amortize per-task overhead. This design enables the user-implemented optimizations described in the previous two sections. However, it also has two drawbacks. Firstly, since the code for grouping tasks is pushed into user code, map function becomes more complicated due to the extra code to deal with chunks. Secondly, if the user leverages the exposed chunk to improve performance, the framework can no longer freely adjust the chunk size since doing so will affect the efficiency of the map function.&lt;br /&gt;
&lt;br /&gt;
== Map Reduce on Graphics Processors ==&lt;br /&gt;
=== Challenges ===&lt;br /&gt;
&lt;br /&gt;
Compared with CPUs, the hardware architecture of GPUs differs significantly. For instance, current GPUs have over one hundred [http://encyclopedia.jrank.org/articles/pages/6904/SIMD-Single-Instruction-Multiple-Data-Processing.html SIMD (Single Instruction Multiple Data)] processors whereas current multi-core CPUs offer a much smaller number of cores. Moreover, most GPUs do not support atomic operations or locks. &lt;br /&gt;
&lt;br /&gt;
Due to the architectural differences, there are following three technical challenges in implementing the MapReduce framework on the GPU. &lt;br /&gt;
# The synchronization overhead in the run-time system of the framework must be low so that the system can scale to hundreds of processors.&lt;br /&gt;
# Due to the lack of dynamic thread scheduling on current GPUs, it is essential to allocate work evenly across threads on the GPU to exploit its massive thread parallelism. &lt;br /&gt;
# The core tasks of MapReduce programs, including string processing, file manipulation and concurrent reads and writes, are unconventional to GPUs and must be handled efficiently.&lt;br /&gt;
&lt;br /&gt;
'''''Mars''''', MapReduce framework on the GPU was designed and implemented with these challenges in mind.&amp;lt;ref&amp;gt;http://www.ece.rutgers.edu/~parashar/Classes/08-09/ece572/readings/mars-pact-08.pdf Mars: A MapReduce Framework on Graphic Processors&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mars API ===&lt;br /&gt;
&lt;br /&gt;
Mars provides a small set of APIs that are similar to those of CPU-based MapReduce. Run-time system utilizes a large number of GPU threads for Map or Reduce tasks, and automatically assigns each thread a small number of key/value pairs to work on. As a result, the massive thread parallelism on the GPU is well utilized. To avoid any conflict between concurrent writes,  Mars has a lock-free scheme with low runtime overhead on the massive thread parallelism of the GPU. This scheme guarantees the correctness of parallel execution with little synchronization overhead. &lt;br /&gt;
&lt;br /&gt;
Mars has two kinds of APIs, the ''user-implemented APIs'', which the users implement, and the ''system-provided APIs'', which the users can use as library calls. &lt;br /&gt;
&lt;br /&gt;
* Mars has the following user-implemented APIs. These APIs are implemented with C/C++. ''void*'' type has been used so that the developer can manipulate strings and other complex data types conveniently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//MAP_COUNT counts result size of the map function.&lt;br /&gt;
voidMAP_COUNT(void *key, void *val, int keySize, int valSize);&lt;br /&gt;
//The map function.&lt;br /&gt;
voidMAP(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
//REDUCE_COUNT counts result size of the reduce function.&lt;br /&gt;
void REDUCE_COUNT(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
//The reduce function.&lt;br /&gt;
void REDUCE(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Mars has the following four system-provided APIs. The emit functions are used in user-implemented map and reduce functions to output the intermediate/final results.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Emit the key size and the value size inMAP_COUNT.&lt;br /&gt;
void EMIT_INTERMEDIATE_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit an intermediate result in MAP.&lt;br /&gt;
void EMIT_INTERMEDIATE(void* key, void* val, int keySize, int valSize);&lt;br /&gt;
//Emit the key size and the value size in REDUCE_COUNT.&lt;br /&gt;
void EMIT_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit a final result in REDUCE.&lt;br /&gt;
void EMIT(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Overall, the APIs in Mars are similar to those in the existing MapReduce frameworks such as Hadoop and Phoenix. The major difference is that Mars needs two APIs to implement the functionality of each CPU-based API. One is to count the size of results, and the other one is to output the results. This is because the GPU does not support atomic operations, and the Mars runtime uses a two-step design for the result output.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Details ===&lt;br /&gt;
&lt;br /&gt;
* Since the GPU does not support dynamic memory allocation on the device memory during the execution of the GPU code, arrays are used as the main data structure. &lt;br /&gt;
* The input data, the intermediate result and the final result are stored in three kinds of arrays, i.e., the key array, the value array and the directory index. The directory index consists of an entry of &amp;lt;key offset, key size, value offset, value size&amp;gt; for each key/value pair. &lt;br /&gt;
* Given a directory index entry, the key or the value at the corresponding offset in the key array or the value array is fetched. &lt;br /&gt;
* With the array structure, for the input data as well as for the result output the space on the device memory is allocated before executing the GPU program. However, the sizes of the output from the map and the reduce stages are unknown. The output scheme for the map stage is similar to that for the reduce stage.&lt;br /&gt;
&lt;br /&gt;
First, each map task outputs three counts, i.e., the number of intermediate results, the total size of keys (in bytes) and the total size of values (in bytes) generated by the map task. Based on key sizes (or value sizes) of all map tasks, the run-time system computes a prefix sum on these sizes and produces an array of write locations. A write location is the start location in the output array for the corresponding map task to write. Based on the number of intermediate results, the run-time system computes a prefix sum and produces an array of start locations in the output directory index for the corresponding map task. Through these prefix sums, the sizes of the arrays for the intermediate result is also known. Thus, the run-time allocates arrays in the device memory with the exact size for storing the intermediate results.&lt;br /&gt;
&lt;br /&gt;
Second, each map task outputs the intermediate key/value pairs to the output array and updates the directory index. Since each map has its deterministic and non-overlapping positions to write to, the write conflicts are avoided. This two-step scheme does not require the hardware support of atomic functions. It is suitable for the massive thread parallelism on the GPU. However, it doubles the map computation in the worst case. The overhead of this scheme is application dependent, and is usually much smaller than that in the worst case.&lt;br /&gt;
&lt;br /&gt;
=== Optimization Techniques ===&lt;br /&gt;
==== Memory Optimizations ====&lt;br /&gt;
Two memory optimizations are used to reduce the number of memory requests in order to improve the memory bandwidth utilization. &lt;br /&gt;
* '''Coalesced accesses'''&lt;br /&gt;
The GPU feature of coalesced accesses is utilized to improve the memory performance. The memory accesses of each thread to the data arrays are designed according to the coalesced access pattern when applicable. Suppose there are T threads in total and the number of key/value pairs is N in the map stage. Thread i processes the (i + T • k )th (k=0,..,N/T) key/value pair. Due to the SIMD property of the GPU, the memory addresses from the threads within a thread group are consecutive and these accesses are coalesced into one. The figure below illustrates the map stage with and without the coalesced access optimization.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mars.jpg]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Accesses using built-in vector types'''&lt;br /&gt;
Accessing the values in the device memory can be costly, because the data values are often&lt;br /&gt;
of different sizes and the accesses are hardly coalesced. Fortunately, GPUs such as G80 support built-in vector types such as char4 and int4. Reading built-in vectors fetches the entire vector&lt;br /&gt;
in a single memory request. Compared with reading char or int, the number of memory requests is greatly reduced and the memory performance is improved.&lt;br /&gt;
&lt;br /&gt;
==== Thread parallelism ====&lt;br /&gt;
The thread configuration, i.e., the number of thread groups and the number of threads per thread group, is related to multiple factors including, (1) the hardware configuration such as the number of multiprocessors and the on-chip computation resources such as the number of registers on each multiprocessor, (2) the computation characteristics of the map and the reduce tasks, e.g., they are memory- or computation-intensive. Since the map and the reduce functions are implemented by the developer, and their costs are unknown to the runtime system, it is difficult to find the optimal setting for the thread configuration at&lt;br /&gt;
run time.&lt;br /&gt;
&lt;br /&gt;
==== Handling variable-sized types ==== &lt;br /&gt;
The variable-sized types are supported with the directory index. If two key/value pairs need to be swapped, their corresponding entries in the directory index are swapped without modifying the key and the value arrays. This choice is to save the swapping cost since the directory entries are typically much smaller than the key/value pairs. Even though swapping changes the order of entries in the directory index, the array layout is preserved and therefore accesses to the directory index can still be coalesced after swaps. Since strings are a typical variable-sized type, and string processing is common in web data analysis tasks, a GPU-based string manipulation library was developed for Mars. The operations in the library include strcmp, strcat, memset and so on. The APIs of these operations are consistent with those in C/C++ library on the CPU. The difference is that simple algorithms for these GPU-based string operations were used, since they usually handle small strings within a map or a reduce task. In addition, char4 is used to implement strings to optimize the memory performance.&lt;br /&gt;
&lt;br /&gt;
==== Hashing ====&lt;br /&gt;
Hashing is used in the sort algorithm to store the results with the same key value consecutively. In that case, it is not needed that the results with the key values are in their strict ascending/ decreasing order. The hashing technique that hashes a key into a 32-bit integer is used, and the records are sorted according to their hash values. When two records are compared, their hash values are compared first. Only when their hash values are the same, their keys are fetched and compared. Given a good hash function, the probability of comparing the keys is low.&lt;br /&gt;
&lt;br /&gt;
==== File manipulation ====&lt;br /&gt;
Currently, the GPU cannot directly access the data in the hard disk. Thus, the file manipulation with the assistance of the CPU is performed in three phases. First, the file I/O on the CPU is performed and the file data is loaded into a buffer in the main memory. To reduce the I/O stall, multiple threads are used to perform the I/O task. Second, the preprocessing on the buffered data is performed and the input key/value pairs are obtained. Finally, the input key/value pairs are copied to the GPU device memory.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Provides a performance speedup of accessing data by using built-in vector types. These vector types  reduces the number of memory requests and improves the bandwidth utilization.&lt;br /&gt;
# Applications written on Mars may or may not have the reduce stage and thus improves speedup.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# GPU based applications are much more complex&lt;br /&gt;
# Mars currently handles data that can fit into the device memory but has not yet been checked to support massive data sets&lt;br /&gt;
&lt;br /&gt;
= More Examples =&lt;br /&gt;
Below are a few simple examples of programs that can be easily expressed as MapReduce computations.&lt;br /&gt;
*Distributed [http://unixhelp.ed.ac.uk/CGI/man-cgi?grep Grep]: The map function emits a line if it matches a given pattern. The reduce function is an identity function that just copies the supplied intermediate data to the output. &amp;lt;br&amp;gt;&lt;br /&gt;
*Count of URL Access Frequency: The map function processes logs of web page requests and outputs &amp;lt;URL, 1&amp;gt;. The reduce function adds together all values for the same URL and emits a &amp;lt;URL, total count&amp;gt; pair. &amp;lt;br&amp;gt;&lt;br /&gt;
*[http://books.google.com/books?id=gJrmszNHQV4C&amp;amp;pg=PA376&amp;amp;lpg=PA376&amp;amp;dq=what+is+reverse+web+link+graph&amp;amp;source=bl&amp;amp;ots=rLQ2yuV6oc&amp;amp;sig=wimcG_7MR7d9g-ePGXkEK1ANmws&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ei=BtxBT5HkN42DtgefhbXRBQ&amp;amp;ved=0CEwQ6AEwBg#v=onepage&amp;amp;q=what%20is%20reverse%20web%20link%20graph&amp;amp;f=false Reverse Web-Link Graph]: The map function outputs &amp;lt;target, source&amp;gt; pairs for each link to a target URL found in a page named &amp;quot;source&amp;quot;. The reduce function concatenates the list of all source URLs associated with a given target URL and emits the pair: &amp;lt;target, list(source)&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
*Term-Vector per Host: A term vector summarizes the most important words that occur in a document or a set of documents as a list of &amp;lt;word, frequency&amp;gt; pairs. The map function emits a &amp;lt;hostname, term vector&amp;gt; pair for each input document (where the hostname is extracted from the URL of the document). The reduce function is passed all per-document term vectors for a given host. It adds these term vectors together, throwing away infrequent terms, and then emits a final &amp;lt;hostname, term vector&amp;gt; pair.&amp;lt;br&amp;gt;&lt;br /&gt;
*[http://nlp.stanford.edu/IR-book/html/htmledition/a-first-take-at-building-an-inverted-index-1.html Inverted Index]: The map function parses each document, and emits a sequence of &amp;lt;word, document ID&amp;gt; pairs. The reduce function accepts all pairs for a given word, sorts the corresponding document IDs and emits a &amp;lt;word, list(document ID)&amp;gt; pair. The set of all output pairs forms a simple inverted index. It is easy to augment this computation to keep track of word positions.&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Google’s MapReduce runtime implementation targets large clusters of Linux PCs connected through Ethernet switches. Tasks are forked using remote procedure calls. Buffering and communication occurs by reading and writing files on a distributed file system. The locality optimizations focus mostly on avoiding remote file accesses. While such a system is effective with distributed computing, it leads to very high overheads if used with shared-memory systems that facilitate communication through memory and are typically of much smaller scale.&lt;br /&gt;
&lt;br /&gt;
Phoenix, implementation of MapReduce uses shared memory and minimizes the overheads of task spawning and data communication. With Phoenix,the programmer can provide a simple, functional expression of the algorithm and leaves parallelization and scheduling to the runtime system.Phoenix leads to scalable performance for both multi-core chips and conventional symmetric multiprocessors. Phoenix automatically handles key scheduling decisions during parallel execution. Despite runtime overheads, results have shown that performance of Phoenix to that of parallel code written in P-threads API are almost similar. Nevertheless,there are also applications that do not fit naturally in the MapReduce model for which P-threads code performs significantly better.&lt;br /&gt;
&lt;br /&gt;
Graphics processors have emerged as a commodity platform for parallel computing. However, the developer requires the knowledge of the GPU architecture and much effort in developing GPU applications. Such difficulty is even more for complex and performance centric tasks such as web data analysis. Since MapReduce has been successful in easing the development of web data analysis tasks, one can use a GPU-based MapReduce for these applications. With the GPU-based framework, the developer writes their code using the simple and familiar MapReduce interfaces. The runtime on the GPU is completely hidden from the developer by the framework.&lt;br /&gt;
&lt;br /&gt;
The framework is followed by criticisms as well. Google was awarded the patent for MapReduce, but it can be argued that this technology is similar to many other already existing ones. There are programming models that are similar to MapReduce like Algorithm Skeletons (Parallelism Patterns), Sector/Sphere, Datameer Analytics Solution. Algorithm Skeletons are a high-level parallel programming model for parallel and distributed computing.This frameowrk libraries are used for a number of applications. Sector/Sphere is a distributed file system targeting data storage over a large number of commodity computers. Sphere is the programming framework that supports massive in-storage parallel data processing for data stored in Sector. Additionally, Sector/Sphere is unique in its ability to operate in a wide area network (WAN) setting. Datameer Analytics Solution (DAS) is a business integration platform for Hadoop and includes data source integration, an analytics engine with a spreadsheet interface designed for business users with over 180 analytic functions and visualization including reports, charts and dashboards.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Interesting Read =&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Algorithmic_skeleton#Frameworks_and_libraries Algorithm Skeleton]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Sector/Sphere Sector/Sphere]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Datameer Datameer Analytic Solution]&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73448</id>
		<title>CSC/ECE 506 Spring 2013/3b xz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73448"/>
		<updated>2013-02-21T01:07:04Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Apache’s Hadoop MapReduce */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to MapReduce =&lt;br /&gt;
MapReduce is a software framework introduced by Google in 2004 to support [http://publib.boulder.ibm.com/infocenter/txformp/v6r0m0/index.jsp?topic=%2Fcom.ibm.cics.te.doc%2Ferziaz0015.htm distributed computing] on large data sets on clusters of computers. &lt;br /&gt;
&lt;br /&gt;
MapReduce programming model consists of two major steps: &lt;br /&gt;
&lt;br /&gt;
* In the '''map''' step, the problem being solved is divided into a series of sub-problems and distributed to different workers. &lt;br /&gt;
&lt;br /&gt;
* After collecting results from workers, the computation enters the '''reduce''' step to combine and produce the final result.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of the Programming Model =&lt;br /&gt;
[[File:Mapreduce.png|thumbnail|MapReduce for a Shape Counter]]&lt;br /&gt;
The MapReduce programming model is inspired by [http://enfranchisedmind.com/blog/posts/what-is-a-functional-programming-language/ functional languages] and targets data-intensive computations. &lt;br /&gt;
&lt;br /&gt;
The input data format is application-specific, and is specified by the user. The output is a set of &amp;lt;key,value&amp;gt; pairs. The user expresses an algorithm using two functions, Map and Reduce. The Map function is applied on the input data and produces a list of intermediate &amp;lt;key,value&amp;gt; pairs. The Reduce function is applied to all intermediate pairs with the same key. It typically performs some kind of merging operation and produces zero or more output pairs. Finally, the output pairs are sorted by their key value. In the simplest form of MapReduce programs, the programmer provides just the Map function. All other functionality, including the grouping of the intermediate pairs which have the same key and the final sorting, is provided by the runtime.&lt;br /&gt;
&lt;br /&gt;
The programmer provides a simple description of the algorithm that focuses on functionality and not on parallelization. The actual parallelization and the details of concurrency management are left to the runtime system. Hence the program code is generic and easily portable across systems. Nevertheless, the model provides sufficient high-level information for parallelization. The Map function can be executed in parallel on non-overlapping portions of the input data and the Reduce function can be executed in parallel on each set of intermediate pairs with the same key. Similarly, since it is explicitly known which pairs each function will operate upon, one can employ pre-fetching or other scheduling optimizations for locality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Sample Code''&lt;br /&gt;
&lt;br /&gt;
The following pseudo-code shows the basic structure of a MapReduce program. &lt;br /&gt;
&lt;br /&gt;
Program to counts number of occurrences of each word in a collection of documents.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Input : a Document&lt;br /&gt;
//Intermediate Output: key = word, value = 1&lt;br /&gt;
Map(void * input){&lt;br /&gt;
   for each word w in Input&lt;br /&gt;
       Emit Intermediate(w,1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Intermediate Output key = word, value = 1&lt;br /&gt;
//Output : key = word, value = occurrences&lt;br /&gt;
Reduce(String key, Iterator values){&lt;br /&gt;
   int result = 0;&lt;br /&gt;
   for each v in values &lt;br /&gt;
       result += v&lt;br /&gt;
   Emit(w, result)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Role of the Run-time System =&lt;br /&gt;
In both steps of MapReduce, the run-time must decide on factors such as the size of the units, the number of nodes involved, how units are assigned to nodes dynamically, and how buffer space is allocated. The decisions can be fully automatic or guided by the programmer given application specific knowledge. These decisions allow the run-time to execute a program efficiently across a wide range of machines and data-set scenarios without modifications to the source code. Finally, the run-time must merge and sort the output pairs from all Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
= Implementations =&lt;br /&gt;
Many different implementations of the MapReduce interface are possible. The right choice depends on the environment. For example, one implementation may be suitable for a small shared-memory machine, another for a large [http://msdn.microsoft.com/en-us/library/ms178144.aspx NUMA] multi-processor, and yet another for an even larger collection of networked machines. &lt;br /&gt;
&lt;br /&gt;
* Google's MapReduce and [http://en.wikipedia.org/wiki/Apache_Hadoop Hadoop] implement map reduce for large clusters of commodity PCs connected together with switched Ethernet.&lt;br /&gt;
&lt;br /&gt;
* [http://mapreduce.stanford.edu/ Phoenix] implements MapReduce for shared-memory systems.&lt;br /&gt;
&lt;br /&gt;
* [http://www.cse.ust.hk/gpuqp/Mars.html Mars] is a MapReduce framework on graphics processors ([http://www.nvidia.com/object/gpu.html GPUs]).&lt;br /&gt;
&lt;br /&gt;
== Google's MapReduce ==&lt;br /&gt;
&lt;br /&gt;
=== Execution Overview ===&lt;br /&gt;
The Map invocations are distributed across multiple machines by automatically partitioning the input data into a set of M splits. The input splits can be processed in parallel by different machines. Reduce invocations are distributed by partitioning the intermediate key space into R pieces using a partitioning function (e.g., hash(key) mod R). The number of partitions (R) and the partitioning function are specified by the user. Below is a detailed look. &amp;lt;ref&amp;gt;http://static.usenix.org/event/osdi04/tech/full_papers/dean/dean.pdf Simplified Data Processing on Large Clusters&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Google Map Reduce.jpg|center|Google's MapReduce]] &amp;lt;br&amp;gt;&lt;br /&gt;
The figure above shows the overall flow of a MapReduce operation in Google's implementation. When the user program calls the MapReduce function, the following sequence of actions occurs (the numbered labels in the figure above correspond to the numbers in the list below):&lt;br /&gt;
&lt;br /&gt;
# The MapReduce library in the user program first splits the input files into M pieces of typically 16 megabytes to 64 megabytes (MB) per piece (controllable by the user via an optional parameter). It then starts up many copies of the program on a cluster of machines.&lt;br /&gt;
# One of the copies of the program is special, ''the master''. The rest are workers that are assigned work by the master. There are ''M'' map tasks and R reduce tasks to assign. The master picks idle workers and assigns each one a map task or a reduce task.&lt;br /&gt;
# A worker who is assigned a map task reads the contents of the corresponding input split. It parses ''key/value'' pairs out of the input data and passes each pair to the user-defined Map function. The intermediate ''key/value'' pairs produced by the Map function are buffered in memory. &lt;br /&gt;
# Periodically, the buffered pairs are written to local disk, partitioned into ''R'' regions by the partitioning function. The locations of these buffered pairs on the local disk are passed back to the master, who is responsible for forwarding these locations to the reduce workers. When a reduce worker is notified by the master about these locations, it uses remote procedure calls to read the buffered data from the local disks of the  map workers.&lt;br /&gt;
# When a reduce worker has read all intermediate data, it sorts it by the intermediate keys so that all occurrences of the same key are grouped together. The sorting is needed because typically many different keys map to the same reduce task. If the amount of intermediate data is too large to fit in memory, an external sort is used.&lt;br /&gt;
# The reduce worker iterates over the sorted intermediate data and for each unique intermediate key encountered, it passes the key and the corresponding set of intermediate values to the user's Reduce function. The output of the Reduce function is appended to a final output file for this reduce partition.&lt;br /&gt;
# When all map tasks and reduce tasks have been completed, the master wakes up the user program. At this point, the MapReduce call in the user program returns back to the user code.&lt;br /&gt;
# After successful completion, the output of the mapreduce execution is available in the ''R'' output files (one per reduce task, with file names as specified by the user). Typically, users do not need to combine these ''R'' output files into one file . They often pass these files as input to another MapReduce call, or use them from another distributed application that is able to deal with input that is partitioned into multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Data Structures: Master ===&lt;br /&gt;
&lt;br /&gt;
The master keeps several data structures. For each map task and reduce task, it stores the state (idle, in-progress, or completed), and the identity of the worker machine (for non-idle tasks).&lt;br /&gt;
The master is the conduit through which the location of intermediate file regions is propagated from map tasks to reduce tasks. Therefore, for each completed map task, the master stores the locations and sizes of the ''R'' intermediate file regions produced by the map task. Updates to this location and size information are received as map tasks are completed. The information is pushed incrementally to workers that have in-progress reduce tasks.&lt;br /&gt;
&lt;br /&gt;
=== Fault Tolerance ===&lt;br /&gt;
&lt;br /&gt;
Since the MapReduce library is designed to help process very large amounts of data using hundreds or thousands of machines, the library must tolerate machine failures gracefully.&lt;br /&gt;
&lt;br /&gt;
* '''Master Failure'''&lt;br /&gt;
&lt;br /&gt;
It is easy to make the master write periodic checkpoints of the master data structures. If the master task dies, a new copy can be started from the last checkpoint. However, given that there is only a single master, its failure is unlikely; therefore Google's current implementation aborts the MapReduce computation if the master fails. Clients can check for this condition and retry the MapReduce operation if they desire.&lt;br /&gt;
&lt;br /&gt;
* '''Worker Failure'''&lt;br /&gt;
&lt;br /&gt;
The master pings every worker periodically. If no response is received from a worker in a certain amount of time, the master marks the worker as failed. Any map tasks completed by the worker are reset back to their initial idle state, and therefore become eligible for scheduling&lt;br /&gt;
on other workers. Similarly, any map task or reduce task in progress on a failed worker is also reset to idle and becomes eligible for rescheduling. Completed map tasks are re-executed on a failure because their output is stored on the local disk(s) of the failed machine and is therefore inaccessible. Completed reduce tasks do not need to be re-executed since their output is stored in a global file system. When a map task is executed first by worker ''A'' and then later executed by worker ''B'' (because ''A'' failed), all workers executing reduce tasks are notified of the re-execution. Any reduce task that has not already read the data from worker ''A'' will read the data from worker ''B''. MapReduce is resilient to large-scale worker failures.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Large variety of problems are easily expressible as Map-Reduce computations. &lt;br /&gt;
# The model is easy to use, even for programmers without experience with parallel and distributed systems, since it hides the details of parallelization, fault tolerance, locality optimization, and load balancing. For example, Map-Reduce is used for the generation of data for Google’s production Web search service, for sorting, data mining, machine learning, and many other systems.&lt;br /&gt;
# Implementation of Map-Reduce can be scaled to large clusters of machines comprising thousands of machines.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# Restricted programming model puts bounds on the way you implement the framework. &lt;br /&gt;
# Since network bandwidth is scarce, a number of optimization in the system are therefore targeted at reducing the amount of data sent across the network.&lt;br /&gt;
&lt;br /&gt;
=== Apache’s Hadoop MapReduce ===&lt;br /&gt;
&lt;br /&gt;
Apache, after Google published the paper on MapReduce and Google File System (GFS &amp;lt;ref&amp;gt;http://www.cs.rochester.edu/meetings/sosp2003/papers/p125-ghemawat.pdf Google File System&amp;lt;/ref&amp;gt;) introduced it's own implementation of the same. The important thing to note here is that Apache made this framework open-source. This framework transparently provides both reliability and data motion to applications. Hadoop has prominent users such as Yahoo! and Facebook.&lt;br /&gt;
(Good Read!&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Apache_Hadoop Apache Hadoop&amp;lt;/ref&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Hadoop MapRed is based on a “pull” model where multiple “TaskTrackers” poll the “JobTracker” for tasks (either map task or reduce task).&lt;br /&gt;
&lt;br /&gt;
[[File:HMR.png|center|Apache Hadoop MapReduce]]&lt;br /&gt;
The figure above depicts the execution of the job.&amp;lt;ref&amp;gt;http://horicky.blogspot.com/2008/11/hadoop-mapreduce-implementation.html Pragmatic Guide&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Client program uploads files to the Hadoop Distributed File System (HDFS) location and notifies the JobTracker which in turn returns the Job ID to the client. &lt;br /&gt;
* The Jobtracker allocates map tasks to the TaskTrackers. &lt;br /&gt;
* JobTracker determines appropriate jobs based on how busy the TaskTracker is. &lt;br /&gt;
* TaskTracker forks MapTask which extracts input data and invokees the user provided &amp;quot;map&amp;quot; function which fills in the buffer with key/value pairs until it is full. &lt;br /&gt;
* The buffer is eventually flushed into two files. &lt;br /&gt;
* After all the MapTask completes (all splits are done), the TaskTracker will notify the JobTracker which keeps track of the overall progress of job.&lt;br /&gt;
* When done, the JobTracker notifies TaskTracker to jump to reduce phase. This again follows same method where reduce task is forked. &lt;br /&gt;
* The output of each reducer is written to a temporary output file in HDFS. When the reducer finishes processing all keys, the temp output file will be renamed atomically to its final output filename.&lt;br /&gt;
&lt;br /&gt;
== Phoenix ==&lt;br /&gt;
Phoenix&amp;lt;ref&amp;gt;&lt;br /&gt;
http://csl.stanford.edu/~christos/publications/2007.cmp_mapreduce.hpca.pdf Evaluating MapReduce for Multi-core and Multiprocessor Systems&amp;lt;/ref&amp;gt; implements MapReduce for shared-memory systems. Its goal is to support efficient execution on multiple cores without burdening the programmer with concurrency management. Phoenix consists of a simple API that is visible to application programmers and an efficient runtime that handles parallelization, resource management, and fault recovery.&lt;br /&gt;
&lt;br /&gt;
=== Phoenix API ===&lt;br /&gt;
The current Phoenix implementation provides an API for C and C++. &amp;lt;br&amp;gt;&lt;br /&gt;
* The first set is provided by Phoenix and is used by the programmer’s application code to initialize the system and emit output pairs (1 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
* The second set includes the functions that the programmer defines (3 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from the Map and Reduce functions, the user provides functions that partition the data before each step and a function that implements key comparison. The function arguments are declared as void pointers wherever possible to provide flexibility in their declaration and fast use without conversion overhead. The data structure used to communicate basic function information and buffer allocation between the user code and run-time is of type ''scheduler_args_t'' ([http://pages.cs.wisc.edu/~gibson/mapreduceexample/MapReduceScheduler.h.html MapReduce Header File]). There are additional data structure types to facilitate communication between the Splitter, Map, Partition, and Reduce functions. These types use pointers whenever possible to implement communication without actually copying significant amounts of data.&lt;br /&gt;
&lt;br /&gt;
The Phoenix API does not rely on any specific compiler options and does not require a parallelizing compiler. However, it assumes that its functions can freely use stack-allocated and heap-allocated structures for private data. It also assumes that there is no communication through shared-memory structures other than the input/output buffers for these functions. For C/C++, these assumptions cannot be checked statically for arbitrary programs. Although there are stringent checks within the system to ensure valid data are communicated between user and run-time code, eventually it is the task of user to provide functionally correct code. &lt;br /&gt;
&lt;br /&gt;
[[File:Phoenix.jpg|center|Phoenix MapReduce]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Phoenix run-time was developed on top of [http://en.wikipedia.org/wiki/POSIX_Threads POSIX threads], but can be easily ported to other shared memory thread packages. The figure above shows the basic data flow for the run-time system. &lt;br /&gt;
&lt;br /&gt;
* The run-time is controlled by the scheduler, which is initiated by user code. &lt;br /&gt;
* The scheduler creates and manages the threads that run all Map and Reduce tasks. It also manages the buffers used for task communication. &lt;br /&gt;
* The programmer provides the scheduler with all the required data and function pointers through the ''scheduler_args_t'' structure. &lt;br /&gt;
*After initialization, the scheduler determines the number of cores to use for this computation. For each core, it spawns a worker thread that is dynamically assigned some number of Map and Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
To start the '''Map''' stage, the scheduler uses the ''Splitter'' to divide input pairs into equally sized units to be processed by the Map tasks. The Splitter is called once per Map task and returns a pointer to the data the Map task will process. The Map tasks are allocated dynamically to workers and each one emits intermediate &amp;lt;key,value&amp;gt; pairs. The ''Partition'' function splits the intermediate pairs into units for the Reduce tasks. The function ensures all values of the same key go to the same unit. Within each buffer, values are ordered by key to assist with the final sorting. At this point, the Map stage is over. The scheduler must wait for all Map tasks to complete before initiating the Reduce stage.&lt;br /&gt;
&lt;br /&gt;
'''Reduce''' tasks are also assigned to workers dynamically, similar to Map tasks. The one difference is that, while with Map tasks there is complete freedom in distributing pairs across tasks, with Reduce all values for the same key must be processed in one task. Hence, the Reduce stage may exhibit higher imbalance across workers and dynamic scheduling is more important. The output of each Reduce task is already sorted by key. As the last step, the final output from all tasks is merged into a single buffer, sorted by keys.&lt;br /&gt;
&lt;br /&gt;
=== Buffer Management ===&lt;br /&gt;
Two types of temporary buffers are necessary to store data between the various stages. All buffers are allocated in shared memory but are accessed in a well specified way by a few functions. To re-arrange buffers (e.g., split across tasks), pointer manipulation is done instead of the actual pairs, which may be large in size. The intermediate buffers are not directly visible to user code. Map-Reduce buffers are used to store the intermediate output pairs. Each worker has its own set of buffers. The buffers are initially sized to a default value and then resized dynamically as needed. At this stage, there may be multiple pairs with the same key. To accelerate the Partition function, the Emit intermediate function stores all values for the same key in the same buffer. At the end of the Map task, each buffer is sorted by key order. Reduce- Merge buffers are used to store the outputs of Reduce tasks before they are sorted. At this stage, each key has only one value associated with it. After sorting, the final output is available in the user allocated Output data buffer.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Phoenix is fast and scalable across all workloads&lt;br /&gt;
# On clusters of machines, the combiner function reduces the number of key-value pairs that must be exchanged between machines. These combiners contribute to better data locality and lower memory allocation pressure, resulting in substantial number of applications being scalable.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&amp;lt;ref&amp;gt;http://csl.stanford.edu/~christos/publications/2011.phoenixplus.mapreduce.pdf Phoenix++: Modular MapReduce for Shared Memory Systems&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Due to shared memory there is an inefficient  key-Value storage since containers must provide fast lookup and retrieval over potentially large data-set, all the while coordinating accesses across multiple threads&lt;br /&gt;
#Ineffective Combiner : However, on SMP machines memory allocation costs tend to dominate, even more than the memory traffic. Combiners fail to reduce the memory allocation pressure, since generated key-value pairs must still be stored. Further, by the time the combiners are run, those pairs may no longer be in the cache causing expensive memory access penalties.&lt;br /&gt;
#Phoenix implements internally grouping tasks into chunks to reduce scheduling costs and amortize per-task overhead. This design enables the user-implemented optimizations described in the previous two sections. However, it also has two drawbacks. Firstly, since the code for grouping tasks is pushed into user code, map function becomes more complicated due to the extra code to deal with chunks. Secondly, if the user leverages the exposed chunk to improve performance, the framework can no longer freely adjust the chunk size since doing so will affect the efficiency of the map function.&lt;br /&gt;
&lt;br /&gt;
== Map Reduce on Graphics Processors ==&lt;br /&gt;
=== Challenges ===&lt;br /&gt;
&lt;br /&gt;
Compared with CPUs, the hardware architecture of GPUs differs significantly. For instance, current GPUs have over one hundred [http://encyclopedia.jrank.org/articles/pages/6904/SIMD-Single-Instruction-Multiple-Data-Processing.html SIMD (Single Instruction Multiple Data)] processors whereas current multi-core CPUs offer a much smaller number of cores. Moreover, most GPUs do not support atomic operations or locks. &lt;br /&gt;
&lt;br /&gt;
Due to the architectural differences, there are following three technical challenges in implementing the MapReduce framework on the GPU. &lt;br /&gt;
# The synchronization overhead in the run-time system of the framework must be low so that the system can scale to hundreds of processors.&lt;br /&gt;
# Due to the lack of dynamic thread scheduling on current GPUs, it is essential to allocate work evenly across threads on the GPU to exploit its massive thread parallelism. &lt;br /&gt;
# The core tasks of MapReduce programs, including string processing, file manipulation and concurrent reads and writes, are unconventional to GPUs and must be handled efficiently.&lt;br /&gt;
&lt;br /&gt;
'''''Mars''''', MapReduce framework on the GPU was designed and implemented with these challenges in mind.&amp;lt;ref&amp;gt;http://www.ece.rutgers.edu/~parashar/Classes/08-09/ece572/readings/mars-pact-08.pdf Mars: A MapReduce Framework on Graphic Processors&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mars API ===&lt;br /&gt;
&lt;br /&gt;
Mars provides a small set of APIs that are similar to those of CPU-based MapReduce. Run-time system utilizes a large number of GPU threads for Map or Reduce tasks, and automatically assigns each thread a small number of key/value pairs to work on. As a result, the massive thread parallelism on the GPU is well utilized. To avoid any conflict between concurrent writes,  Mars has a lock-free scheme with low runtime overhead on the massive thread parallelism of the GPU. This scheme guarantees the correctness of parallel execution with little synchronization overhead. &lt;br /&gt;
&lt;br /&gt;
Mars has two kinds of APIs, the ''user-implemented APIs'', which the users implement, and the ''system-provided APIs'', which the users can use as library calls. &lt;br /&gt;
&lt;br /&gt;
* Mars has the following user-implemented APIs. These APIs are implemented with C/C++. ''void*'' type has been used so that the developer can manipulate strings and other complex data types conveniently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//MAP_COUNT counts result size of the map function.&lt;br /&gt;
voidMAP_COUNT(void *key, void *val, int keySize, int valSize);&lt;br /&gt;
//The map function.&lt;br /&gt;
voidMAP(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
//REDUCE_COUNT counts result size of the reduce function.&lt;br /&gt;
void REDUCE_COUNT(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
//The reduce function.&lt;br /&gt;
void REDUCE(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Mars has the following four system-provided APIs. The emit functions are used in user-implemented map and reduce functions to output the intermediate/final results.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Emit the key size and the value size inMAP_COUNT.&lt;br /&gt;
void EMIT_INTERMEDIATE_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit an intermediate result in MAP.&lt;br /&gt;
void EMIT_INTERMEDIATE(void* key, void* val, int keySize, int valSize);&lt;br /&gt;
//Emit the key size and the value size in REDUCE_COUNT.&lt;br /&gt;
void EMIT_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit a final result in REDUCE.&lt;br /&gt;
void EMIT(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Overall, the APIs in Mars are similar to those in the existing MapReduce frameworks such as Hadoop and Phoenix. The major difference is that Mars needs two APIs to implement the functionality of each CPU-based API. One is to count the size of results, and the other one is to output the results. This is because the GPU does not support atomic operations, and the Mars runtime uses a two-step design for the result output.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Details ===&lt;br /&gt;
&lt;br /&gt;
* Since the GPU does not support dynamic memory allocation on the device memory during the execution of the GPU code, arrays are used as the main data structure. &lt;br /&gt;
* The input data, the intermediate result and the final result are stored in three kinds of arrays, i.e., the key array, the value array and the directory index. The directory index consists of an entry of &amp;lt;key offset, key size, value offset, value size&amp;gt; for each key/value pair. &lt;br /&gt;
* Given a directory index entry, the key or the value at the corresponding offset in the key array or the value array is fetched. &lt;br /&gt;
* With the array structure, for the input data as well as for the result output the space on the device memory is allocated before executing the GPU program. However, the sizes of the output from the map and the reduce stages are unknown. The output scheme for the map stage is similar to that for the reduce stage.&lt;br /&gt;
&lt;br /&gt;
First, each map task outputs three counts, i.e., the number of intermediate results, the total size of keys (in bytes) and the total size of values (in bytes) generated by the map task. Based on key sizes (or value sizes) of all map tasks, the run-time system computes a prefix sum on these sizes and produces an array of write locations. A write location is the start location in the output array for the corresponding map task to write. Based on the number of intermediate results, the run-time system computes a prefix sum and produces an array of start locations in the output directory index for the corresponding map task. Through these prefix sums, the sizes of the arrays for the intermediate result is also known. Thus, the run-time allocates arrays in the device memory with the exact size for storing the intermediate results.&lt;br /&gt;
&lt;br /&gt;
Second, each map task outputs the intermediate key/value pairs to the output array and updates the directory index. Since each map has its deterministic and non-overlapping positions to write to, the write conflicts are avoided. This two-step scheme does not require the hardware support of atomic functions. It is suitable for the massive thread parallelism on the GPU. However, it doubles the map computation in the worst case. The overhead of this scheme is application dependent, and is usually much smaller than that in the worst case.&lt;br /&gt;
&lt;br /&gt;
=== Optimization Techniques ===&lt;br /&gt;
==== Memory Optimizations ====&lt;br /&gt;
Two memory optimizations are used to reduce the number of memory requests in order to improve the memory bandwidth utilization. &lt;br /&gt;
* '''Coalesced accesses'''&lt;br /&gt;
The GPU feature of coalesced accesses is utilized to improve the memory performance. The memory accesses of each thread to the data arrays are designed according to the coalesced access pattern when applicable. Suppose there are T threads in total and the number of key/value pairs is N in the map stage. Thread i processes the (i + T • k )th (k=0,..,N/T) key/value pair. Due to the SIMD property of the GPU, the memory addresses from the threads within a thread group are consecutive and these accesses are coalesced into one. The figure below illustrates the map stage with and without the coalesced access optimization.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mars.jpg]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Accesses using built-in vector types'''&lt;br /&gt;
Accessing the values in the device memory can be costly, because the data values are often&lt;br /&gt;
of different sizes and the accesses are hardly coalesced. Fortunately, GPUs such as G80 support built-in vector types such as char4 and int4. Reading built-in vectors fetches the entire vector&lt;br /&gt;
in a single memory request. Compared with reading char or int, the number of memory requests is greatly reduced and the memory performance is improved.&lt;br /&gt;
&lt;br /&gt;
==== Thread parallelism ====&lt;br /&gt;
The thread configuration, i.e., the number of thread groups and the number of threads per thread group, is related to multiple factors including, (1) the hardware configuration such as the number of multiprocessors and the on-chip computation resources such as the number of registers on each multiprocessor, (2) the computation characteristics of the map and the reduce tasks, e.g., they are memory- or computation-intensive. Since the map and the reduce functions are implemented by the developer, and their costs are unknown to the runtime system, it is difficult to find the optimal setting for the thread configuration at&lt;br /&gt;
run time.&lt;br /&gt;
&lt;br /&gt;
==== Handling variable-sized types ==== &lt;br /&gt;
The variable-sized types are supported with the directory index. If two key/value pairs need to be swapped, their corresponding entries in the directory index are swapped without modifying the key and the value arrays. This choice is to save the swapping cost since the directory entries are typically much smaller than the key/value pairs. Even though swapping changes the order of entries in the directory index, the array layout is preserved and therefore accesses to the directory index can still be coalesced after swaps. Since strings are a typical variable-sized type, and string processing is common in web data analysis tasks, a GPU-based string manipulation library was developed for Mars. The operations in the library include strcmp, strcat, memset and so on. The APIs of these operations are consistent with those in C/C++ library on the CPU. The difference is that simple algorithms for these GPU-based string operations were used, since they usually handle small strings within a map or a reduce task. In addition, char4 is used to implement strings to optimize the memory performance.&lt;br /&gt;
&lt;br /&gt;
==== Hashing ====&lt;br /&gt;
Hashing is used in the sort algorithm to store the results with the same key value consecutively. In that case, it is not needed that the results with the key values are in their strict ascending/ decreasing order. The hashing technique that hashes a key into a 32-bit integer is used, and the records are sorted according to their hash values. When two records are compared, their hash values are compared first. Only when their hash values are the same, their keys are fetched and compared. Given a good hash function, the probability of comparing the keys is low.&lt;br /&gt;
&lt;br /&gt;
==== File manipulation ====&lt;br /&gt;
Currently, the GPU cannot directly access the data in the hard disk. Thus, the file manipulation with the assistance of the CPU is performed in three phases. First, the file I/O on the CPU is performed and the file data is loaded into a buffer in the main memory. To reduce the I/O stall, multiple threads are used to perform the I/O task. Second, the preprocessing on the buffered data is performed and the input key/value pairs are obtained. Finally, the input key/value pairs are copied to the GPU device memory.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Provides a performance speedup of accessing data by using built-in vector types. These vector types  reduces the number of memory requests and improves the bandwidth utilization.&lt;br /&gt;
# Applications written on Mars may or may not have the reduce stage and thus improves speedup.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# GPU based applications are much more complex&lt;br /&gt;
# Mars currently handles data that can fit into the device memory but has not yet been checked to support massive data sets&lt;br /&gt;
&lt;br /&gt;
= More Examples =&lt;br /&gt;
Below are a few simple examples of programs that can be easily expressed as MapReduce computations.&lt;br /&gt;
*Distributed [http://unixhelp.ed.ac.uk/CGI/man-cgi?grep Grep]: The map function emits a line if it matches a given pattern. The reduce function is an identity function that just copies the supplied intermediate data to the output. &amp;lt;br&amp;gt;&lt;br /&gt;
*Count of URL Access Frequency: The map function processes logs of web page requests and outputs &amp;lt;URL, 1&amp;gt;. The reduce function adds together all values for the same URL and emits a &amp;lt;URL, total count&amp;gt; pair. &amp;lt;br&amp;gt;&lt;br /&gt;
*[http://books.google.com/books?id=gJrmszNHQV4C&amp;amp;pg=PA376&amp;amp;lpg=PA376&amp;amp;dq=what+is+reverse+web+link+graph&amp;amp;source=bl&amp;amp;ots=rLQ2yuV6oc&amp;amp;sig=wimcG_7MR7d9g-ePGXkEK1ANmws&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ei=BtxBT5HkN42DtgefhbXRBQ&amp;amp;ved=0CEwQ6AEwBg#v=onepage&amp;amp;q=what%20is%20reverse%20web%20link%20graph&amp;amp;f=false Reverse Web-Link Graph]: The map function outputs &amp;lt;target, source&amp;gt; pairs for each link to a target URL found in a page named &amp;quot;source&amp;quot;. The reduce function concatenates the list of all source URLs associated with a given target URL and emits the pair: &amp;lt;target, list(source)&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
*Term-Vector per Host: A term vector summarizes the most important words that occur in a document or a set of documents as a list of &amp;lt;word, frequency&amp;gt; pairs. The map function emits a &amp;lt;hostname, term vector&amp;gt; pair for each input document (where the hostname is extracted from the URL of the document). The reduce function is passed all per-document term vectors for a given host. It adds these term vectors together, throwing away infrequent terms, and then emits a final &amp;lt;hostname, term vector&amp;gt; pair.&amp;lt;br&amp;gt;&lt;br /&gt;
*[http://nlp.stanford.edu/IR-book/html/htmledition/a-first-take-at-building-an-inverted-index-1.html Inverted Index]: The map function parses each document, and emits a sequence of &amp;lt;word, document ID&amp;gt; pairs. The reduce function accepts all pairs for a given word, sorts the corresponding document IDs and emits a &amp;lt;word, list(document ID)&amp;gt; pair. The set of all output pairs forms a simple inverted index. It is easy to augment this computation to keep track of word positions.&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Google’s MapReduce runtime implementation targets large clusters of Linux PCs connected through Ethernet switches. Tasks are forked using remote procedure calls. Buffering and communication occurs by reading and writing files on a distributed file system. The locality optimizations focus mostly on avoiding remote file accesses. While such a system is effective with distributed computing, it leads to very high overheads if used with shared-memory systems that facilitate communication through memory and are typically of much smaller scale.&lt;br /&gt;
&lt;br /&gt;
Phoenix, implementation of MapReduce uses shared memory and minimizes the overheads of task spawning and data communication. With Phoenix,the programmer can provide a simple, functional expression of the algorithm and leaves parallelization and scheduling to the runtime system.Phoenix leads to scalable performance for both multi-core chips and conventional symmetric multiprocessors. Phoenix automatically handles key scheduling decisions during parallel execution. Despite runtime overheads, results have shown that performance of Phoenix to that of parallel code written in P-threads API are almost similar. Nevertheless,there are also applications that do not fit naturally in the MapReduce model for which P-threads code performs significantly better.&lt;br /&gt;
&lt;br /&gt;
Graphics processors have emerged as a commodity platform for parallel computing. However, the developer requires the knowledge of the GPU architecture and much effort in developing GPU applications. Such difficulty is even more for complex and performance centric tasks such as web data analysis. Since MapReduce has been successful in easing the development of web data analysis tasks, one can use a GPU-based MapReduce for these applications. With the GPU-based framework, the developer writes their code using the simple and familiar MapReduce interfaces. The runtime on the GPU is completely hidden from the developer by the framework.&lt;br /&gt;
&lt;br /&gt;
The framework is followed by criticisms as well. Google was awarded the patent for MapReduce, but it can be argued that this technology is similar to many other already existing ones. There are programming models that are similar to MapReduce like Algorithm Skeletons (Parallelism Patterns), Sector/Sphere, Datameer Analytics Solution. Algorithm Skeletons are a high-level parallel programming model for parallel and distributed computing.This frameowrk libraries are used for a number of applications. Sector/Sphere is a distributed file system targeting data storage over a large number of commodity computers. Sphere is the programming framework that supports massive in-storage parallel data processing for data stored in Sector. Additionally, Sector/Sphere is unique in its ability to operate in a wide area network (WAN) setting. Datameer Analytics Solution (DAS) is a business integration platform for Hadoop and includes data source integration, an analytics engine with a spreadsheet interface designed for business users with over 180 analytic functions and visualization including reports, charts and dashboards.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Interesting Read =&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Algorithmic_skeleton#Frameworks_and_libraries Algorithm Skeleton]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Sector/Sphere Sector/Sphere]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Datameer Datameer Analytic Solution]&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73447</id>
		<title>CSC/ECE 506 Spring 2013/3b xz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73447"/>
		<updated>2013-02-21T01:06:18Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Apache’s Hadoop MapReduce */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to MapReduce =&lt;br /&gt;
MapReduce is a software framework introduced by Google in 2004 to support [http://publib.boulder.ibm.com/infocenter/txformp/v6r0m0/index.jsp?topic=%2Fcom.ibm.cics.te.doc%2Ferziaz0015.htm distributed computing] on large data sets on clusters of computers. &lt;br /&gt;
&lt;br /&gt;
MapReduce programming model consists of two major steps: &lt;br /&gt;
&lt;br /&gt;
* In the '''map''' step, the problem being solved is divided into a series of sub-problems and distributed to different workers. &lt;br /&gt;
&lt;br /&gt;
* After collecting results from workers, the computation enters the '''reduce''' step to combine and produce the final result.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of the Programming Model =&lt;br /&gt;
[[File:Mapreduce.png|thumbnail|MapReduce for a Shape Counter]]&lt;br /&gt;
The MapReduce programming model is inspired by [http://enfranchisedmind.com/blog/posts/what-is-a-functional-programming-language/ functional languages] and targets data-intensive computations. &lt;br /&gt;
&lt;br /&gt;
The input data format is application-specific, and is specified by the user. The output is a set of &amp;lt;key,value&amp;gt; pairs. The user expresses an algorithm using two functions, Map and Reduce. The Map function is applied on the input data and produces a list of intermediate &amp;lt;key,value&amp;gt; pairs. The Reduce function is applied to all intermediate pairs with the same key. It typically performs some kind of merging operation and produces zero or more output pairs. Finally, the output pairs are sorted by their key value. In the simplest form of MapReduce programs, the programmer provides just the Map function. All other functionality, including the grouping of the intermediate pairs which have the same key and the final sorting, is provided by the runtime.&lt;br /&gt;
&lt;br /&gt;
The programmer provides a simple description of the algorithm that focuses on functionality and not on parallelization. The actual parallelization and the details of concurrency management are left to the runtime system. Hence the program code is generic and easily portable across systems. Nevertheless, the model provides sufficient high-level information for parallelization. The Map function can be executed in parallel on non-overlapping portions of the input data and the Reduce function can be executed in parallel on each set of intermediate pairs with the same key. Similarly, since it is explicitly known which pairs each function will operate upon, one can employ pre-fetching or other scheduling optimizations for locality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Sample Code''&lt;br /&gt;
&lt;br /&gt;
The following pseudo-code shows the basic structure of a MapReduce program. &lt;br /&gt;
&lt;br /&gt;
Program to counts number of occurrences of each word in a collection of documents.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Input : a Document&lt;br /&gt;
//Intermediate Output: key = word, value = 1&lt;br /&gt;
Map(void * input){&lt;br /&gt;
   for each word w in Input&lt;br /&gt;
       Emit Intermediate(w,1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Intermediate Output key = word, value = 1&lt;br /&gt;
//Output : key = word, value = occurrences&lt;br /&gt;
Reduce(String key, Iterator values){&lt;br /&gt;
   int result = 0;&lt;br /&gt;
   for each v in values &lt;br /&gt;
       result += v&lt;br /&gt;
   Emit(w, result)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Role of the Run-time System =&lt;br /&gt;
In both steps of MapReduce, the run-time must decide on factors such as the size of the units, the number of nodes involved, how units are assigned to nodes dynamically, and how buffer space is allocated. The decisions can be fully automatic or guided by the programmer given application specific knowledge. These decisions allow the run-time to execute a program efficiently across a wide range of machines and data-set scenarios without modifications to the source code. Finally, the run-time must merge and sort the output pairs from all Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
= Implementations =&lt;br /&gt;
Many different implementations of the MapReduce interface are possible. The right choice depends on the environment. For example, one implementation may be suitable for a small shared-memory machine, another for a large [http://msdn.microsoft.com/en-us/library/ms178144.aspx NUMA] multi-processor, and yet another for an even larger collection of networked machines. &lt;br /&gt;
&lt;br /&gt;
* Google's MapReduce and [http://en.wikipedia.org/wiki/Apache_Hadoop Hadoop] implement map reduce for large clusters of commodity PCs connected together with switched Ethernet.&lt;br /&gt;
&lt;br /&gt;
* [http://mapreduce.stanford.edu/ Phoenix] implements MapReduce for shared-memory systems.&lt;br /&gt;
&lt;br /&gt;
* [http://www.cse.ust.hk/gpuqp/Mars.html Mars] is a MapReduce framework on graphics processors ([http://www.nvidia.com/object/gpu.html GPUs]).&lt;br /&gt;
&lt;br /&gt;
== Google's MapReduce ==&lt;br /&gt;
&lt;br /&gt;
=== Execution Overview ===&lt;br /&gt;
The Map invocations are distributed across multiple machines by automatically partitioning the input data into a set of M splits. The input splits can be processed in parallel by different machines. Reduce invocations are distributed by partitioning the intermediate key space into R pieces using a partitioning function (e.g., hash(key) mod R). The number of partitions (R) and the partitioning function are specified by the user. Below is a detailed look. &amp;lt;ref&amp;gt;http://static.usenix.org/event/osdi04/tech/full_papers/dean/dean.pdf Simplified Data Processing on Large Clusters&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Google Map Reduce.jpg|center|Google's MapReduce]] &amp;lt;br&amp;gt;&lt;br /&gt;
The figure above shows the overall flow of a MapReduce operation in Google's implementation. When the user program calls the MapReduce function, the following sequence of actions occurs (the numbered labels in the figure above correspond to the numbers in the list below):&lt;br /&gt;
&lt;br /&gt;
# The MapReduce library in the user program first splits the input files into M pieces of typically 16 megabytes to 64 megabytes (MB) per piece (controllable by the user via an optional parameter). It then starts up many copies of the program on a cluster of machines.&lt;br /&gt;
# One of the copies of the program is special, ''the master''. The rest are workers that are assigned work by the master. There are ''M'' map tasks and R reduce tasks to assign. The master picks idle workers and assigns each one a map task or a reduce task.&lt;br /&gt;
# A worker who is assigned a map task reads the contents of the corresponding input split. It parses ''key/value'' pairs out of the input data and passes each pair to the user-defined Map function. The intermediate ''key/value'' pairs produced by the Map function are buffered in memory. &lt;br /&gt;
# Periodically, the buffered pairs are written to local disk, partitioned into ''R'' regions by the partitioning function. The locations of these buffered pairs on the local disk are passed back to the master, who is responsible for forwarding these locations to the reduce workers. When a reduce worker is notified by the master about these locations, it uses remote procedure calls to read the buffered data from the local disks of the  map workers.&lt;br /&gt;
# When a reduce worker has read all intermediate data, it sorts it by the intermediate keys so that all occurrences of the same key are grouped together. The sorting is needed because typically many different keys map to the same reduce task. If the amount of intermediate data is too large to fit in memory, an external sort is used.&lt;br /&gt;
# The reduce worker iterates over the sorted intermediate data and for each unique intermediate key encountered, it passes the key and the corresponding set of intermediate values to the user's Reduce function. The output of the Reduce function is appended to a final output file for this reduce partition.&lt;br /&gt;
# When all map tasks and reduce tasks have been completed, the master wakes up the user program. At this point, the MapReduce call in the user program returns back to the user code.&lt;br /&gt;
# After successful completion, the output of the mapreduce execution is available in the ''R'' output files (one per reduce task, with file names as specified by the user). Typically, users do not need to combine these ''R'' output files into one file . They often pass these files as input to another MapReduce call, or use them from another distributed application that is able to deal with input that is partitioned into multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Data Structures: Master ===&lt;br /&gt;
&lt;br /&gt;
The master keeps several data structures. For each map task and reduce task, it stores the state (idle, in-progress, or completed), and the identity of the worker machine (for non-idle tasks).&lt;br /&gt;
The master is the conduit through which the location of intermediate file regions is propagated from map tasks to reduce tasks. Therefore, for each completed map task, the master stores the locations and sizes of the ''R'' intermediate file regions produced by the map task. Updates to this location and size information are received as map tasks are completed. The information is pushed incrementally to workers that have in-progress reduce tasks.&lt;br /&gt;
&lt;br /&gt;
=== Fault Tolerance ===&lt;br /&gt;
&lt;br /&gt;
Since the MapReduce library is designed to help process very large amounts of data using hundreds or thousands of machines, the library must tolerate machine failures gracefully.&lt;br /&gt;
&lt;br /&gt;
* '''Master Failure'''&lt;br /&gt;
&lt;br /&gt;
It is easy to make the master write periodic checkpoints of the master data structures. If the master task dies, a new copy can be started from the last checkpoint. However, given that there is only a single master, its failure is unlikely; therefore Google's current implementation aborts the MapReduce computation if the master fails. Clients can check for this condition and retry the MapReduce operation if they desire.&lt;br /&gt;
&lt;br /&gt;
* '''Worker Failure'''&lt;br /&gt;
&lt;br /&gt;
The master pings every worker periodically. If no response is received from a worker in a certain amount of time, the master marks the worker as failed. Any map tasks completed by the worker are reset back to their initial idle state, and therefore become eligible for scheduling&lt;br /&gt;
on other workers. Similarly, any map task or reduce task in progress on a failed worker is also reset to idle and becomes eligible for rescheduling. Completed map tasks are re-executed on a failure because their output is stored on the local disk(s) of the failed machine and is therefore inaccessible. Completed reduce tasks do not need to be re-executed since their output is stored in a global file system. When a map task is executed first by worker ''A'' and then later executed by worker ''B'' (because ''A'' failed), all workers executing reduce tasks are notified of the re-execution. Any reduce task that has not already read the data from worker ''A'' will read the data from worker ''B''. MapReduce is resilient to large-scale worker failures.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Large variety of problems are easily expressible as Map-Reduce computations. &lt;br /&gt;
# The model is easy to use, even for programmers without experience with parallel and distributed systems, since it hides the details of parallelization, fault tolerance, locality optimization, and load balancing. For example, Map-Reduce is used for the generation of data for Google’s production Web search service, for sorting, data mining, machine learning, and many other systems.&lt;br /&gt;
# Implementation of Map-Reduce can be scaled to large clusters of machines comprising thousands of machines.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# Restricted programming model puts bounds on the way you implement the framework. &lt;br /&gt;
# Since network bandwidth is scarce, a number of optimization in the system are therefore targeted at reducing the amount of data sent across the network.&lt;br /&gt;
&lt;br /&gt;
=== Apache’s Hadoop MapReduce ===&lt;br /&gt;
&lt;br /&gt;
Apache, after Google published the paper on MapReduce and Google File System (GFS &amp;lt;ref&amp;gt;http://www.cs.rochester.edu/meetings/sosp2003/papers/p125-ghemawat.pdf&amp;lt;/ref&amp;gt;) introduced it's own implementation of the same. The important thing to note here is that Apache made this framework open-source. This framework transparently provides both reliability and data motion to applications. Hadoop has prominent users such as Yahoo! and Facebook.&lt;br /&gt;
(Good Read!&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Apache_Hadoop Apache Hadoop&amp;lt;/ref&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Hadoop MapRed is based on a “pull” model where multiple “TaskTrackers” poll the “JobTracker” for tasks (either map task or reduce task).&lt;br /&gt;
&lt;br /&gt;
[[File:HMR.png|center|Apache Hadoop MapReduce]]&lt;br /&gt;
The figure above depicts the execution of the job.&amp;lt;ref&amp;gt;http://horicky.blogspot.com/2008/11/hadoop-mapreduce-implementation.html Pragmatic Guide&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Client program uploads files to the Hadoop Distributed File System (HDFS) location and notifies the JobTracker which in turn returns the Job ID to the client. &lt;br /&gt;
* The Jobtracker allocates map tasks to the TaskTrackers. &lt;br /&gt;
* JobTracker determines appropriate jobs based on how busy the TaskTracker is. &lt;br /&gt;
* TaskTracker forks MapTask which extracts input data and invokees the user provided &amp;quot;map&amp;quot; function which fills in the buffer with key/value pairs until it is full. &lt;br /&gt;
* The buffer is eventually flushed into two files. &lt;br /&gt;
* After all the MapTask completes (all splits are done), the TaskTracker will notify the JobTracker which keeps track of the overall progress of job.&lt;br /&gt;
* When done, the JobTracker notifies TaskTracker to jump to reduce phase. This again follows same method where reduce task is forked. &lt;br /&gt;
* The output of each reducer is written to a temporary output file in HDFS. When the reducer finishes processing all keys, the temp output file will be renamed atomically to its final output filename.&lt;br /&gt;
&lt;br /&gt;
== Phoenix ==&lt;br /&gt;
Phoenix&amp;lt;ref&amp;gt;&lt;br /&gt;
http://csl.stanford.edu/~christos/publications/2007.cmp_mapreduce.hpca.pdf Evaluating MapReduce for Multi-core and Multiprocessor Systems&amp;lt;/ref&amp;gt; implements MapReduce for shared-memory systems. Its goal is to support efficient execution on multiple cores without burdening the programmer with concurrency management. Phoenix consists of a simple API that is visible to application programmers and an efficient runtime that handles parallelization, resource management, and fault recovery.&lt;br /&gt;
&lt;br /&gt;
=== Phoenix API ===&lt;br /&gt;
The current Phoenix implementation provides an API for C and C++. &amp;lt;br&amp;gt;&lt;br /&gt;
* The first set is provided by Phoenix and is used by the programmer’s application code to initialize the system and emit output pairs (1 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
* The second set includes the functions that the programmer defines (3 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from the Map and Reduce functions, the user provides functions that partition the data before each step and a function that implements key comparison. The function arguments are declared as void pointers wherever possible to provide flexibility in their declaration and fast use without conversion overhead. The data structure used to communicate basic function information and buffer allocation between the user code and run-time is of type ''scheduler_args_t'' ([http://pages.cs.wisc.edu/~gibson/mapreduceexample/MapReduceScheduler.h.html MapReduce Header File]). There are additional data structure types to facilitate communication between the Splitter, Map, Partition, and Reduce functions. These types use pointers whenever possible to implement communication without actually copying significant amounts of data.&lt;br /&gt;
&lt;br /&gt;
The Phoenix API does not rely on any specific compiler options and does not require a parallelizing compiler. However, it assumes that its functions can freely use stack-allocated and heap-allocated structures for private data. It also assumes that there is no communication through shared-memory structures other than the input/output buffers for these functions. For C/C++, these assumptions cannot be checked statically for arbitrary programs. Although there are stringent checks within the system to ensure valid data are communicated between user and run-time code, eventually it is the task of user to provide functionally correct code. &lt;br /&gt;
&lt;br /&gt;
[[File:Phoenix.jpg|center|Phoenix MapReduce]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Phoenix run-time was developed on top of [http://en.wikipedia.org/wiki/POSIX_Threads POSIX threads], but can be easily ported to other shared memory thread packages. The figure above shows the basic data flow for the run-time system. &lt;br /&gt;
&lt;br /&gt;
* The run-time is controlled by the scheduler, which is initiated by user code. &lt;br /&gt;
* The scheduler creates and manages the threads that run all Map and Reduce tasks. It also manages the buffers used for task communication. &lt;br /&gt;
* The programmer provides the scheduler with all the required data and function pointers through the ''scheduler_args_t'' structure. &lt;br /&gt;
*After initialization, the scheduler determines the number of cores to use for this computation. For each core, it spawns a worker thread that is dynamically assigned some number of Map and Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
To start the '''Map''' stage, the scheduler uses the ''Splitter'' to divide input pairs into equally sized units to be processed by the Map tasks. The Splitter is called once per Map task and returns a pointer to the data the Map task will process. The Map tasks are allocated dynamically to workers and each one emits intermediate &amp;lt;key,value&amp;gt; pairs. The ''Partition'' function splits the intermediate pairs into units for the Reduce tasks. The function ensures all values of the same key go to the same unit. Within each buffer, values are ordered by key to assist with the final sorting. At this point, the Map stage is over. The scheduler must wait for all Map tasks to complete before initiating the Reduce stage.&lt;br /&gt;
&lt;br /&gt;
'''Reduce''' tasks are also assigned to workers dynamically, similar to Map tasks. The one difference is that, while with Map tasks there is complete freedom in distributing pairs across tasks, with Reduce all values for the same key must be processed in one task. Hence, the Reduce stage may exhibit higher imbalance across workers and dynamic scheduling is more important. The output of each Reduce task is already sorted by key. As the last step, the final output from all tasks is merged into a single buffer, sorted by keys.&lt;br /&gt;
&lt;br /&gt;
=== Buffer Management ===&lt;br /&gt;
Two types of temporary buffers are necessary to store data between the various stages. All buffers are allocated in shared memory but are accessed in a well specified way by a few functions. To re-arrange buffers (e.g., split across tasks), pointer manipulation is done instead of the actual pairs, which may be large in size. The intermediate buffers are not directly visible to user code. Map-Reduce buffers are used to store the intermediate output pairs. Each worker has its own set of buffers. The buffers are initially sized to a default value and then resized dynamically as needed. At this stage, there may be multiple pairs with the same key. To accelerate the Partition function, the Emit intermediate function stores all values for the same key in the same buffer. At the end of the Map task, each buffer is sorted by key order. Reduce- Merge buffers are used to store the outputs of Reduce tasks before they are sorted. At this stage, each key has only one value associated with it. After sorting, the final output is available in the user allocated Output data buffer.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Phoenix is fast and scalable across all workloads&lt;br /&gt;
# On clusters of machines, the combiner function reduces the number of key-value pairs that must be exchanged between machines. These combiners contribute to better data locality and lower memory allocation pressure, resulting in substantial number of applications being scalable.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&amp;lt;ref&amp;gt;http://csl.stanford.edu/~christos/publications/2011.phoenixplus.mapreduce.pdf Phoenix++: Modular MapReduce for Shared Memory Systems&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Due to shared memory there is an inefficient  key-Value storage since containers must provide fast lookup and retrieval over potentially large data-set, all the while coordinating accesses across multiple threads&lt;br /&gt;
#Ineffective Combiner : However, on SMP machines memory allocation costs tend to dominate, even more than the memory traffic. Combiners fail to reduce the memory allocation pressure, since generated key-value pairs must still be stored. Further, by the time the combiners are run, those pairs may no longer be in the cache causing expensive memory access penalties.&lt;br /&gt;
#Phoenix implements internally grouping tasks into chunks to reduce scheduling costs and amortize per-task overhead. This design enables the user-implemented optimizations described in the previous two sections. However, it also has two drawbacks. Firstly, since the code for grouping tasks is pushed into user code, map function becomes more complicated due to the extra code to deal with chunks. Secondly, if the user leverages the exposed chunk to improve performance, the framework can no longer freely adjust the chunk size since doing so will affect the efficiency of the map function.&lt;br /&gt;
&lt;br /&gt;
== Map Reduce on Graphics Processors ==&lt;br /&gt;
=== Challenges ===&lt;br /&gt;
&lt;br /&gt;
Compared with CPUs, the hardware architecture of GPUs differs significantly. For instance, current GPUs have over one hundred [http://encyclopedia.jrank.org/articles/pages/6904/SIMD-Single-Instruction-Multiple-Data-Processing.html SIMD (Single Instruction Multiple Data)] processors whereas current multi-core CPUs offer a much smaller number of cores. Moreover, most GPUs do not support atomic operations or locks. &lt;br /&gt;
&lt;br /&gt;
Due to the architectural differences, there are following three technical challenges in implementing the MapReduce framework on the GPU. &lt;br /&gt;
# The synchronization overhead in the run-time system of the framework must be low so that the system can scale to hundreds of processors.&lt;br /&gt;
# Due to the lack of dynamic thread scheduling on current GPUs, it is essential to allocate work evenly across threads on the GPU to exploit its massive thread parallelism. &lt;br /&gt;
# The core tasks of MapReduce programs, including string processing, file manipulation and concurrent reads and writes, are unconventional to GPUs and must be handled efficiently.&lt;br /&gt;
&lt;br /&gt;
'''''Mars''''', MapReduce framework on the GPU was designed and implemented with these challenges in mind.&amp;lt;ref&amp;gt;http://www.ece.rutgers.edu/~parashar/Classes/08-09/ece572/readings/mars-pact-08.pdf Mars: A MapReduce Framework on Graphic Processors&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mars API ===&lt;br /&gt;
&lt;br /&gt;
Mars provides a small set of APIs that are similar to those of CPU-based MapReduce. Run-time system utilizes a large number of GPU threads for Map or Reduce tasks, and automatically assigns each thread a small number of key/value pairs to work on. As a result, the massive thread parallelism on the GPU is well utilized. To avoid any conflict between concurrent writes,  Mars has a lock-free scheme with low runtime overhead on the massive thread parallelism of the GPU. This scheme guarantees the correctness of parallel execution with little synchronization overhead. &lt;br /&gt;
&lt;br /&gt;
Mars has two kinds of APIs, the ''user-implemented APIs'', which the users implement, and the ''system-provided APIs'', which the users can use as library calls. &lt;br /&gt;
&lt;br /&gt;
* Mars has the following user-implemented APIs. These APIs are implemented with C/C++. ''void*'' type has been used so that the developer can manipulate strings and other complex data types conveniently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//MAP_COUNT counts result size of the map function.&lt;br /&gt;
voidMAP_COUNT(void *key, void *val, int keySize, int valSize);&lt;br /&gt;
//The map function.&lt;br /&gt;
voidMAP(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
//REDUCE_COUNT counts result size of the reduce function.&lt;br /&gt;
void REDUCE_COUNT(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
//The reduce function.&lt;br /&gt;
void REDUCE(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Mars has the following four system-provided APIs. The emit functions are used in user-implemented map and reduce functions to output the intermediate/final results.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Emit the key size and the value size inMAP_COUNT.&lt;br /&gt;
void EMIT_INTERMEDIATE_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit an intermediate result in MAP.&lt;br /&gt;
void EMIT_INTERMEDIATE(void* key, void* val, int keySize, int valSize);&lt;br /&gt;
//Emit the key size and the value size in REDUCE_COUNT.&lt;br /&gt;
void EMIT_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit a final result in REDUCE.&lt;br /&gt;
void EMIT(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Overall, the APIs in Mars are similar to those in the existing MapReduce frameworks such as Hadoop and Phoenix. The major difference is that Mars needs two APIs to implement the functionality of each CPU-based API. One is to count the size of results, and the other one is to output the results. This is because the GPU does not support atomic operations, and the Mars runtime uses a two-step design for the result output.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Details ===&lt;br /&gt;
&lt;br /&gt;
* Since the GPU does not support dynamic memory allocation on the device memory during the execution of the GPU code, arrays are used as the main data structure. &lt;br /&gt;
* The input data, the intermediate result and the final result are stored in three kinds of arrays, i.e., the key array, the value array and the directory index. The directory index consists of an entry of &amp;lt;key offset, key size, value offset, value size&amp;gt; for each key/value pair. &lt;br /&gt;
* Given a directory index entry, the key or the value at the corresponding offset in the key array or the value array is fetched. &lt;br /&gt;
* With the array structure, for the input data as well as for the result output the space on the device memory is allocated before executing the GPU program. However, the sizes of the output from the map and the reduce stages are unknown. The output scheme for the map stage is similar to that for the reduce stage.&lt;br /&gt;
&lt;br /&gt;
First, each map task outputs three counts, i.e., the number of intermediate results, the total size of keys (in bytes) and the total size of values (in bytes) generated by the map task. Based on key sizes (or value sizes) of all map tasks, the run-time system computes a prefix sum on these sizes and produces an array of write locations. A write location is the start location in the output array for the corresponding map task to write. Based on the number of intermediate results, the run-time system computes a prefix sum and produces an array of start locations in the output directory index for the corresponding map task. Through these prefix sums, the sizes of the arrays for the intermediate result is also known. Thus, the run-time allocates arrays in the device memory with the exact size for storing the intermediate results.&lt;br /&gt;
&lt;br /&gt;
Second, each map task outputs the intermediate key/value pairs to the output array and updates the directory index. Since each map has its deterministic and non-overlapping positions to write to, the write conflicts are avoided. This two-step scheme does not require the hardware support of atomic functions. It is suitable for the massive thread parallelism on the GPU. However, it doubles the map computation in the worst case. The overhead of this scheme is application dependent, and is usually much smaller than that in the worst case.&lt;br /&gt;
&lt;br /&gt;
=== Optimization Techniques ===&lt;br /&gt;
==== Memory Optimizations ====&lt;br /&gt;
Two memory optimizations are used to reduce the number of memory requests in order to improve the memory bandwidth utilization. &lt;br /&gt;
* '''Coalesced accesses'''&lt;br /&gt;
The GPU feature of coalesced accesses is utilized to improve the memory performance. The memory accesses of each thread to the data arrays are designed according to the coalesced access pattern when applicable. Suppose there are T threads in total and the number of key/value pairs is N in the map stage. Thread i processes the (i + T • k )th (k=0,..,N/T) key/value pair. Due to the SIMD property of the GPU, the memory addresses from the threads within a thread group are consecutive and these accesses are coalesced into one. The figure below illustrates the map stage with and without the coalesced access optimization.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mars.jpg]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Accesses using built-in vector types'''&lt;br /&gt;
Accessing the values in the device memory can be costly, because the data values are often&lt;br /&gt;
of different sizes and the accesses are hardly coalesced. Fortunately, GPUs such as G80 support built-in vector types such as char4 and int4. Reading built-in vectors fetches the entire vector&lt;br /&gt;
in a single memory request. Compared with reading char or int, the number of memory requests is greatly reduced and the memory performance is improved.&lt;br /&gt;
&lt;br /&gt;
==== Thread parallelism ====&lt;br /&gt;
The thread configuration, i.e., the number of thread groups and the number of threads per thread group, is related to multiple factors including, (1) the hardware configuration such as the number of multiprocessors and the on-chip computation resources such as the number of registers on each multiprocessor, (2) the computation characteristics of the map and the reduce tasks, e.g., they are memory- or computation-intensive. Since the map and the reduce functions are implemented by the developer, and their costs are unknown to the runtime system, it is difficult to find the optimal setting for the thread configuration at&lt;br /&gt;
run time.&lt;br /&gt;
&lt;br /&gt;
==== Handling variable-sized types ==== &lt;br /&gt;
The variable-sized types are supported with the directory index. If two key/value pairs need to be swapped, their corresponding entries in the directory index are swapped without modifying the key and the value arrays. This choice is to save the swapping cost since the directory entries are typically much smaller than the key/value pairs. Even though swapping changes the order of entries in the directory index, the array layout is preserved and therefore accesses to the directory index can still be coalesced after swaps. Since strings are a typical variable-sized type, and string processing is common in web data analysis tasks, a GPU-based string manipulation library was developed for Mars. The operations in the library include strcmp, strcat, memset and so on. The APIs of these operations are consistent with those in C/C++ library on the CPU. The difference is that simple algorithms for these GPU-based string operations were used, since they usually handle small strings within a map or a reduce task. In addition, char4 is used to implement strings to optimize the memory performance.&lt;br /&gt;
&lt;br /&gt;
==== Hashing ====&lt;br /&gt;
Hashing is used in the sort algorithm to store the results with the same key value consecutively. In that case, it is not needed that the results with the key values are in their strict ascending/ decreasing order. The hashing technique that hashes a key into a 32-bit integer is used, and the records are sorted according to their hash values. When two records are compared, their hash values are compared first. Only when their hash values are the same, their keys are fetched and compared. Given a good hash function, the probability of comparing the keys is low.&lt;br /&gt;
&lt;br /&gt;
==== File manipulation ====&lt;br /&gt;
Currently, the GPU cannot directly access the data in the hard disk. Thus, the file manipulation with the assistance of the CPU is performed in three phases. First, the file I/O on the CPU is performed and the file data is loaded into a buffer in the main memory. To reduce the I/O stall, multiple threads are used to perform the I/O task. Second, the preprocessing on the buffered data is performed and the input key/value pairs are obtained. Finally, the input key/value pairs are copied to the GPU device memory.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Provides a performance speedup of accessing data by using built-in vector types. These vector types  reduces the number of memory requests and improves the bandwidth utilization.&lt;br /&gt;
# Applications written on Mars may or may not have the reduce stage and thus improves speedup.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# GPU based applications are much more complex&lt;br /&gt;
# Mars currently handles data that can fit into the device memory but has not yet been checked to support massive data sets&lt;br /&gt;
&lt;br /&gt;
= More Examples =&lt;br /&gt;
Below are a few simple examples of programs that can be easily expressed as MapReduce computations.&lt;br /&gt;
*Distributed [http://unixhelp.ed.ac.uk/CGI/man-cgi?grep Grep]: The map function emits a line if it matches a given pattern. The reduce function is an identity function that just copies the supplied intermediate data to the output. &amp;lt;br&amp;gt;&lt;br /&gt;
*Count of URL Access Frequency: The map function processes logs of web page requests and outputs &amp;lt;URL, 1&amp;gt;. The reduce function adds together all values for the same URL and emits a &amp;lt;URL, total count&amp;gt; pair. &amp;lt;br&amp;gt;&lt;br /&gt;
*[http://books.google.com/books?id=gJrmszNHQV4C&amp;amp;pg=PA376&amp;amp;lpg=PA376&amp;amp;dq=what+is+reverse+web+link+graph&amp;amp;source=bl&amp;amp;ots=rLQ2yuV6oc&amp;amp;sig=wimcG_7MR7d9g-ePGXkEK1ANmws&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ei=BtxBT5HkN42DtgefhbXRBQ&amp;amp;ved=0CEwQ6AEwBg#v=onepage&amp;amp;q=what%20is%20reverse%20web%20link%20graph&amp;amp;f=false Reverse Web-Link Graph]: The map function outputs &amp;lt;target, source&amp;gt; pairs for each link to a target URL found in a page named &amp;quot;source&amp;quot;. The reduce function concatenates the list of all source URLs associated with a given target URL and emits the pair: &amp;lt;target, list(source)&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
*Term-Vector per Host: A term vector summarizes the most important words that occur in a document or a set of documents as a list of &amp;lt;word, frequency&amp;gt; pairs. The map function emits a &amp;lt;hostname, term vector&amp;gt; pair for each input document (where the hostname is extracted from the URL of the document). The reduce function is passed all per-document term vectors for a given host. It adds these term vectors together, throwing away infrequent terms, and then emits a final &amp;lt;hostname, term vector&amp;gt; pair.&amp;lt;br&amp;gt;&lt;br /&gt;
*[http://nlp.stanford.edu/IR-book/html/htmledition/a-first-take-at-building-an-inverted-index-1.html Inverted Index]: The map function parses each document, and emits a sequence of &amp;lt;word, document ID&amp;gt; pairs. The reduce function accepts all pairs for a given word, sorts the corresponding document IDs and emits a &amp;lt;word, list(document ID)&amp;gt; pair. The set of all output pairs forms a simple inverted index. It is easy to augment this computation to keep track of word positions.&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Google’s MapReduce runtime implementation targets large clusters of Linux PCs connected through Ethernet switches. Tasks are forked using remote procedure calls. Buffering and communication occurs by reading and writing files on a distributed file system. The locality optimizations focus mostly on avoiding remote file accesses. While such a system is effective with distributed computing, it leads to very high overheads if used with shared-memory systems that facilitate communication through memory and are typically of much smaller scale.&lt;br /&gt;
&lt;br /&gt;
Phoenix, implementation of MapReduce uses shared memory and minimizes the overheads of task spawning and data communication. With Phoenix,the programmer can provide a simple, functional expression of the algorithm and leaves parallelization and scheduling to the runtime system.Phoenix leads to scalable performance for both multi-core chips and conventional symmetric multiprocessors. Phoenix automatically handles key scheduling decisions during parallel execution. Despite runtime overheads, results have shown that performance of Phoenix to that of parallel code written in P-threads API are almost similar. Nevertheless,there are also applications that do not fit naturally in the MapReduce model for which P-threads code performs significantly better.&lt;br /&gt;
&lt;br /&gt;
Graphics processors have emerged as a commodity platform for parallel computing. However, the developer requires the knowledge of the GPU architecture and much effort in developing GPU applications. Such difficulty is even more for complex and performance centric tasks such as web data analysis. Since MapReduce has been successful in easing the development of web data analysis tasks, one can use a GPU-based MapReduce for these applications. With the GPU-based framework, the developer writes their code using the simple and familiar MapReduce interfaces. The runtime on the GPU is completely hidden from the developer by the framework.&lt;br /&gt;
&lt;br /&gt;
The framework is followed by criticisms as well. Google was awarded the patent for MapReduce, but it can be argued that this technology is similar to many other already existing ones. There are programming models that are similar to MapReduce like Algorithm Skeletons (Parallelism Patterns), Sector/Sphere, Datameer Analytics Solution. Algorithm Skeletons are a high-level parallel programming model for parallel and distributed computing.This frameowrk libraries are used for a number of applications. Sector/Sphere is a distributed file system targeting data storage over a large number of commodity computers. Sphere is the programming framework that supports massive in-storage parallel data processing for data stored in Sector. Additionally, Sector/Sphere is unique in its ability to operate in a wide area network (WAN) setting. Datameer Analytics Solution (DAS) is a business integration platform for Hadoop and includes data source integration, an analytics engine with a spreadsheet interface designed for business users with over 180 analytic functions and visualization including reports, charts and dashboards.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Interesting Read =&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Algorithmic_skeleton#Frameworks_and_libraries Algorithm Skeleton]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Sector/Sphere Sector/Sphere]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Datameer Datameer Analytic Solution]&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73446</id>
		<title>CSC/ECE 506 Spring 2013/3b xz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73446"/>
		<updated>2013-02-21T01:04:29Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Apache’s Hadoop MapReduce */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to MapReduce =&lt;br /&gt;
MapReduce is a software framework introduced by Google in 2004 to support [http://publib.boulder.ibm.com/infocenter/txformp/v6r0m0/index.jsp?topic=%2Fcom.ibm.cics.te.doc%2Ferziaz0015.htm distributed computing] on large data sets on clusters of computers. &lt;br /&gt;
&lt;br /&gt;
MapReduce programming model consists of two major steps: &lt;br /&gt;
&lt;br /&gt;
* In the '''map''' step, the problem being solved is divided into a series of sub-problems and distributed to different workers. &lt;br /&gt;
&lt;br /&gt;
* After collecting results from workers, the computation enters the '''reduce''' step to combine and produce the final result.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of the Programming Model =&lt;br /&gt;
[[File:Mapreduce.png|thumbnail|MapReduce for a Shape Counter]]&lt;br /&gt;
The MapReduce programming model is inspired by [http://enfranchisedmind.com/blog/posts/what-is-a-functional-programming-language/ functional languages] and targets data-intensive computations. &lt;br /&gt;
&lt;br /&gt;
The input data format is application-specific, and is specified by the user. The output is a set of &amp;lt;key,value&amp;gt; pairs. The user expresses an algorithm using two functions, Map and Reduce. The Map function is applied on the input data and produces a list of intermediate &amp;lt;key,value&amp;gt; pairs. The Reduce function is applied to all intermediate pairs with the same key. It typically performs some kind of merging operation and produces zero or more output pairs. Finally, the output pairs are sorted by their key value. In the simplest form of MapReduce programs, the programmer provides just the Map function. All other functionality, including the grouping of the intermediate pairs which have the same key and the final sorting, is provided by the runtime.&lt;br /&gt;
&lt;br /&gt;
The programmer provides a simple description of the algorithm that focuses on functionality and not on parallelization. The actual parallelization and the details of concurrency management are left to the runtime system. Hence the program code is generic and easily portable across systems. Nevertheless, the model provides sufficient high-level information for parallelization. The Map function can be executed in parallel on non-overlapping portions of the input data and the Reduce function can be executed in parallel on each set of intermediate pairs with the same key. Similarly, since it is explicitly known which pairs each function will operate upon, one can employ pre-fetching or other scheduling optimizations for locality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Sample Code''&lt;br /&gt;
&lt;br /&gt;
The following pseudo-code shows the basic structure of a MapReduce program. &lt;br /&gt;
&lt;br /&gt;
Program to counts number of occurrences of each word in a collection of documents.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Input : a Document&lt;br /&gt;
//Intermediate Output: key = word, value = 1&lt;br /&gt;
Map(void * input){&lt;br /&gt;
   for each word w in Input&lt;br /&gt;
       Emit Intermediate(w,1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Intermediate Output key = word, value = 1&lt;br /&gt;
//Output : key = word, value = occurrences&lt;br /&gt;
Reduce(String key, Iterator values){&lt;br /&gt;
   int result = 0;&lt;br /&gt;
   for each v in values &lt;br /&gt;
       result += v&lt;br /&gt;
   Emit(w, result)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Role of the Run-time System =&lt;br /&gt;
In both steps of MapReduce, the run-time must decide on factors such as the size of the units, the number of nodes involved, how units are assigned to nodes dynamically, and how buffer space is allocated. The decisions can be fully automatic or guided by the programmer given application specific knowledge. These decisions allow the run-time to execute a program efficiently across a wide range of machines and data-set scenarios without modifications to the source code. Finally, the run-time must merge and sort the output pairs from all Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
= Implementations =&lt;br /&gt;
Many different implementations of the MapReduce interface are possible. The right choice depends on the environment. For example, one implementation may be suitable for a small shared-memory machine, another for a large [http://msdn.microsoft.com/en-us/library/ms178144.aspx NUMA] multi-processor, and yet another for an even larger collection of networked machines. &lt;br /&gt;
&lt;br /&gt;
* Google's MapReduce and [http://en.wikipedia.org/wiki/Apache_Hadoop Hadoop] implement map reduce for large clusters of commodity PCs connected together with switched Ethernet.&lt;br /&gt;
&lt;br /&gt;
* [http://mapreduce.stanford.edu/ Phoenix] implements MapReduce for shared-memory systems.&lt;br /&gt;
&lt;br /&gt;
* [http://www.cse.ust.hk/gpuqp/Mars.html Mars] is a MapReduce framework on graphics processors ([http://www.nvidia.com/object/gpu.html GPUs]).&lt;br /&gt;
&lt;br /&gt;
== Google's MapReduce ==&lt;br /&gt;
&lt;br /&gt;
=== Execution Overview ===&lt;br /&gt;
The Map invocations are distributed across multiple machines by automatically partitioning the input data into a set of M splits. The input splits can be processed in parallel by different machines. Reduce invocations are distributed by partitioning the intermediate key space into R pieces using a partitioning function (e.g., hash(key) mod R). The number of partitions (R) and the partitioning function are specified by the user. Below is a detailed look. &amp;lt;ref&amp;gt;http://static.usenix.org/event/osdi04/tech/full_papers/dean/dean.pdf Simplified Data Processing on Large Clusters&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Google Map Reduce.jpg|center|Google's MapReduce]] &amp;lt;br&amp;gt;&lt;br /&gt;
The figure above shows the overall flow of a MapReduce operation in Google's implementation. When the user program calls the MapReduce function, the following sequence of actions occurs (the numbered labels in the figure above correspond to the numbers in the list below):&lt;br /&gt;
&lt;br /&gt;
# The MapReduce library in the user program first splits the input files into M pieces of typically 16 megabytes to 64 megabytes (MB) per piece (controllable by the user via an optional parameter). It then starts up many copies of the program on a cluster of machines.&lt;br /&gt;
# One of the copies of the program is special, ''the master''. The rest are workers that are assigned work by the master. There are ''M'' map tasks and R reduce tasks to assign. The master picks idle workers and assigns each one a map task or a reduce task.&lt;br /&gt;
# A worker who is assigned a map task reads the contents of the corresponding input split. It parses ''key/value'' pairs out of the input data and passes each pair to the user-defined Map function. The intermediate ''key/value'' pairs produced by the Map function are buffered in memory. &lt;br /&gt;
# Periodically, the buffered pairs are written to local disk, partitioned into ''R'' regions by the partitioning function. The locations of these buffered pairs on the local disk are passed back to the master, who is responsible for forwarding these locations to the reduce workers. When a reduce worker is notified by the master about these locations, it uses remote procedure calls to read the buffered data from the local disks of the  map workers.&lt;br /&gt;
# When a reduce worker has read all intermediate data, it sorts it by the intermediate keys so that all occurrences of the same key are grouped together. The sorting is needed because typically many different keys map to the same reduce task. If the amount of intermediate data is too large to fit in memory, an external sort is used.&lt;br /&gt;
# The reduce worker iterates over the sorted intermediate data and for each unique intermediate key encountered, it passes the key and the corresponding set of intermediate values to the user's Reduce function. The output of the Reduce function is appended to a final output file for this reduce partition.&lt;br /&gt;
# When all map tasks and reduce tasks have been completed, the master wakes up the user program. At this point, the MapReduce call in the user program returns back to the user code.&lt;br /&gt;
# After successful completion, the output of the mapreduce execution is available in the ''R'' output files (one per reduce task, with file names as specified by the user). Typically, users do not need to combine these ''R'' output files into one file . They often pass these files as input to another MapReduce call, or use them from another distributed application that is able to deal with input that is partitioned into multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Data Structures: Master ===&lt;br /&gt;
&lt;br /&gt;
The master keeps several data structures. For each map task and reduce task, it stores the state (idle, in-progress, or completed), and the identity of the worker machine (for non-idle tasks).&lt;br /&gt;
The master is the conduit through which the location of intermediate file regions is propagated from map tasks to reduce tasks. Therefore, for each completed map task, the master stores the locations and sizes of the ''R'' intermediate file regions produced by the map task. Updates to this location and size information are received as map tasks are completed. The information is pushed incrementally to workers that have in-progress reduce tasks.&lt;br /&gt;
&lt;br /&gt;
=== Fault Tolerance ===&lt;br /&gt;
&lt;br /&gt;
Since the MapReduce library is designed to help process very large amounts of data using hundreds or thousands of machines, the library must tolerate machine failures gracefully.&lt;br /&gt;
&lt;br /&gt;
* '''Master Failure'''&lt;br /&gt;
&lt;br /&gt;
It is easy to make the master write periodic checkpoints of the master data structures. If the master task dies, a new copy can be started from the last checkpoint. However, given that there is only a single master, its failure is unlikely; therefore Google's current implementation aborts the MapReduce computation if the master fails. Clients can check for this condition and retry the MapReduce operation if they desire.&lt;br /&gt;
&lt;br /&gt;
* '''Worker Failure'''&lt;br /&gt;
&lt;br /&gt;
The master pings every worker periodically. If no response is received from a worker in a certain amount of time, the master marks the worker as failed. Any map tasks completed by the worker are reset back to their initial idle state, and therefore become eligible for scheduling&lt;br /&gt;
on other workers. Similarly, any map task or reduce task in progress on a failed worker is also reset to idle and becomes eligible for rescheduling. Completed map tasks are re-executed on a failure because their output is stored on the local disk(s) of the failed machine and is therefore inaccessible. Completed reduce tasks do not need to be re-executed since their output is stored in a global file system. When a map task is executed first by worker ''A'' and then later executed by worker ''B'' (because ''A'' failed), all workers executing reduce tasks are notified of the re-execution. Any reduce task that has not already read the data from worker ''A'' will read the data from worker ''B''. MapReduce is resilient to large-scale worker failures.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Large variety of problems are easily expressible as Map-Reduce computations. &lt;br /&gt;
# The model is easy to use, even for programmers without experience with parallel and distributed systems, since it hides the details of parallelization, fault tolerance, locality optimization, and load balancing. For example, Map-Reduce is used for the generation of data for Google’s production Web search service, for sorting, data mining, machine learning, and many other systems.&lt;br /&gt;
# Implementation of Map-Reduce can be scaled to large clusters of machines comprising thousands of machines.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# Restricted programming model puts bounds on the way you implement the framework. &lt;br /&gt;
# Since network bandwidth is scarce, a number of optimization in the system are therefore targeted at reducing the amount of data sent across the network.&lt;br /&gt;
&lt;br /&gt;
=== Apache’s Hadoop MapReduce ===&lt;br /&gt;
&lt;br /&gt;
Apache, after Google published the paper on MapReduce and Google File System (GFS &amp;lt;ref&amp;gt;http://www.cs.rochester.edu/meetings/sosp2003/papers/p125-ghemawat.pdf&amp;lt;/ref&amp;gt;) introduced it's own implementation of the same. The important thing to note here is that Apache made this framework open-source. This framework transparently provides both reliability and data motion to applications. Hadoop has prominent users such as Yahoo! and Facebook.&lt;br /&gt;
(Good Read!&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Apache_Hadoop Apache Hadoop&amp;lt;/ref&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Hadoop MapRed is based on a “pull” model where multiple “TaskTrackers” poll the “JobTracker” for tasks (either map task or reduce task).&lt;br /&gt;
&lt;br /&gt;
[[File:HMR.png|center|Apache Hadoop MapReduce]]&lt;br /&gt;
The figure above depicts the execution of the job. &lt;br /&gt;
* Client program uploads files to the Hadoop Distributed File System (HDFS) location and notifies the JobTracker which in turn returns the Job ID to the client. &lt;br /&gt;
* The Jobtracker allocates map tasks to the TaskTrackers. &lt;br /&gt;
* JobTracker determines appropriate jobs based on how busy the TaskTracker is. &lt;br /&gt;
* TaskTracker forks MapTask which extracts input data and invokees the user provided &amp;quot;map&amp;quot; function which fills in the buffer with key/value pairs until it is full. &lt;br /&gt;
* The buffer is eventually flushed into two files. &lt;br /&gt;
* After all the MapTask completes (all splits are done), the TaskTracker will notify the JobTracker which keeps track of the overall progress of job.&lt;br /&gt;
* When done, the JobTracker notifies TaskTracker to jump to reduce phase. This again follows same method where reduce task is forked. &lt;br /&gt;
* The output of each reducer is written to a temporary output file in HDFS. When the reducer finishes processing all keys, the temp output file will be renamed atomically to its final output filename.&lt;br /&gt;
&lt;br /&gt;
== Phoenix ==&lt;br /&gt;
Phoenix&amp;lt;ref&amp;gt;&lt;br /&gt;
http://csl.stanford.edu/~christos/publications/2007.cmp_mapreduce.hpca.pdf Evaluating MapReduce for Multi-core and Multiprocessor Systems&amp;lt;/ref&amp;gt; implements MapReduce for shared-memory systems. Its goal is to support efficient execution on multiple cores without burdening the programmer with concurrency management. Phoenix consists of a simple API that is visible to application programmers and an efficient runtime that handles parallelization, resource management, and fault recovery.&lt;br /&gt;
&lt;br /&gt;
=== Phoenix API ===&lt;br /&gt;
The current Phoenix implementation provides an API for C and C++. &amp;lt;br&amp;gt;&lt;br /&gt;
* The first set is provided by Phoenix and is used by the programmer’s application code to initialize the system and emit output pairs (1 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
* The second set includes the functions that the programmer defines (3 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from the Map and Reduce functions, the user provides functions that partition the data before each step and a function that implements key comparison. The function arguments are declared as void pointers wherever possible to provide flexibility in their declaration and fast use without conversion overhead. The data structure used to communicate basic function information and buffer allocation between the user code and run-time is of type ''scheduler_args_t'' ([http://pages.cs.wisc.edu/~gibson/mapreduceexample/MapReduceScheduler.h.html MapReduce Header File]). There are additional data structure types to facilitate communication between the Splitter, Map, Partition, and Reduce functions. These types use pointers whenever possible to implement communication without actually copying significant amounts of data.&lt;br /&gt;
&lt;br /&gt;
The Phoenix API does not rely on any specific compiler options and does not require a parallelizing compiler. However, it assumes that its functions can freely use stack-allocated and heap-allocated structures for private data. It also assumes that there is no communication through shared-memory structures other than the input/output buffers for these functions. For C/C++, these assumptions cannot be checked statically for arbitrary programs. Although there are stringent checks within the system to ensure valid data are communicated between user and run-time code, eventually it is the task of user to provide functionally correct code. &lt;br /&gt;
&lt;br /&gt;
[[File:Phoenix.jpg|center|Phoenix MapReduce]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Phoenix run-time was developed on top of [http://en.wikipedia.org/wiki/POSIX_Threads POSIX threads], but can be easily ported to other shared memory thread packages. The figure above shows the basic data flow for the run-time system. &lt;br /&gt;
&lt;br /&gt;
* The run-time is controlled by the scheduler, which is initiated by user code. &lt;br /&gt;
* The scheduler creates and manages the threads that run all Map and Reduce tasks. It also manages the buffers used for task communication. &lt;br /&gt;
* The programmer provides the scheduler with all the required data and function pointers through the ''scheduler_args_t'' structure. &lt;br /&gt;
*After initialization, the scheduler determines the number of cores to use for this computation. For each core, it spawns a worker thread that is dynamically assigned some number of Map and Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
To start the '''Map''' stage, the scheduler uses the ''Splitter'' to divide input pairs into equally sized units to be processed by the Map tasks. The Splitter is called once per Map task and returns a pointer to the data the Map task will process. The Map tasks are allocated dynamically to workers and each one emits intermediate &amp;lt;key,value&amp;gt; pairs. The ''Partition'' function splits the intermediate pairs into units for the Reduce tasks. The function ensures all values of the same key go to the same unit. Within each buffer, values are ordered by key to assist with the final sorting. At this point, the Map stage is over. The scheduler must wait for all Map tasks to complete before initiating the Reduce stage.&lt;br /&gt;
&lt;br /&gt;
'''Reduce''' tasks are also assigned to workers dynamically, similar to Map tasks. The one difference is that, while with Map tasks there is complete freedom in distributing pairs across tasks, with Reduce all values for the same key must be processed in one task. Hence, the Reduce stage may exhibit higher imbalance across workers and dynamic scheduling is more important. The output of each Reduce task is already sorted by key. As the last step, the final output from all tasks is merged into a single buffer, sorted by keys.&lt;br /&gt;
&lt;br /&gt;
=== Buffer Management ===&lt;br /&gt;
Two types of temporary buffers are necessary to store data between the various stages. All buffers are allocated in shared memory but are accessed in a well specified way by a few functions. To re-arrange buffers (e.g., split across tasks), pointer manipulation is done instead of the actual pairs, which may be large in size. The intermediate buffers are not directly visible to user code. Map-Reduce buffers are used to store the intermediate output pairs. Each worker has its own set of buffers. The buffers are initially sized to a default value and then resized dynamically as needed. At this stage, there may be multiple pairs with the same key. To accelerate the Partition function, the Emit intermediate function stores all values for the same key in the same buffer. At the end of the Map task, each buffer is sorted by key order. Reduce- Merge buffers are used to store the outputs of Reduce tasks before they are sorted. At this stage, each key has only one value associated with it. After sorting, the final output is available in the user allocated Output data buffer.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Phoenix is fast and scalable across all workloads&lt;br /&gt;
# On clusters of machines, the combiner function reduces the number of key-value pairs that must be exchanged between machines. These combiners contribute to better data locality and lower memory allocation pressure, resulting in substantial number of applications being scalable.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&amp;lt;ref&amp;gt;http://csl.stanford.edu/~christos/publications/2011.phoenixplus.mapreduce.pdf Phoenix++: Modular MapReduce for Shared Memory Systems&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Due to shared memory there is an inefficient  key-Value storage since containers must provide fast lookup and retrieval over potentially large data-set, all the while coordinating accesses across multiple threads&lt;br /&gt;
#Ineffective Combiner : However, on SMP machines memory allocation costs tend to dominate, even more than the memory traffic. Combiners fail to reduce the memory allocation pressure, since generated key-value pairs must still be stored. Further, by the time the combiners are run, those pairs may no longer be in the cache causing expensive memory access penalties.&lt;br /&gt;
#Phoenix implements internally grouping tasks into chunks to reduce scheduling costs and amortize per-task overhead. This design enables the user-implemented optimizations described in the previous two sections. However, it also has two drawbacks. Firstly, since the code for grouping tasks is pushed into user code, map function becomes more complicated due to the extra code to deal with chunks. Secondly, if the user leverages the exposed chunk to improve performance, the framework can no longer freely adjust the chunk size since doing so will affect the efficiency of the map function.&lt;br /&gt;
&lt;br /&gt;
== Map Reduce on Graphics Processors ==&lt;br /&gt;
=== Challenges ===&lt;br /&gt;
&lt;br /&gt;
Compared with CPUs, the hardware architecture of GPUs differs significantly. For instance, current GPUs have over one hundred [http://encyclopedia.jrank.org/articles/pages/6904/SIMD-Single-Instruction-Multiple-Data-Processing.html SIMD (Single Instruction Multiple Data)] processors whereas current multi-core CPUs offer a much smaller number of cores. Moreover, most GPUs do not support atomic operations or locks. &lt;br /&gt;
&lt;br /&gt;
Due to the architectural differences, there are following three technical challenges in implementing the MapReduce framework on the GPU. &lt;br /&gt;
# The synchronization overhead in the run-time system of the framework must be low so that the system can scale to hundreds of processors.&lt;br /&gt;
# Due to the lack of dynamic thread scheduling on current GPUs, it is essential to allocate work evenly across threads on the GPU to exploit its massive thread parallelism. &lt;br /&gt;
# The core tasks of MapReduce programs, including string processing, file manipulation and concurrent reads and writes, are unconventional to GPUs and must be handled efficiently.&lt;br /&gt;
&lt;br /&gt;
'''''Mars''''', MapReduce framework on the GPU was designed and implemented with these challenges in mind.&amp;lt;ref&amp;gt;http://www.ece.rutgers.edu/~parashar/Classes/08-09/ece572/readings/mars-pact-08.pdf Mars: A MapReduce Framework on Graphic Processors&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mars API ===&lt;br /&gt;
&lt;br /&gt;
Mars provides a small set of APIs that are similar to those of CPU-based MapReduce. Run-time system utilizes a large number of GPU threads for Map or Reduce tasks, and automatically assigns each thread a small number of key/value pairs to work on. As a result, the massive thread parallelism on the GPU is well utilized. To avoid any conflict between concurrent writes,  Mars has a lock-free scheme with low runtime overhead on the massive thread parallelism of the GPU. This scheme guarantees the correctness of parallel execution with little synchronization overhead. &lt;br /&gt;
&lt;br /&gt;
Mars has two kinds of APIs, the ''user-implemented APIs'', which the users implement, and the ''system-provided APIs'', which the users can use as library calls. &lt;br /&gt;
&lt;br /&gt;
* Mars has the following user-implemented APIs. These APIs are implemented with C/C++. ''void*'' type has been used so that the developer can manipulate strings and other complex data types conveniently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//MAP_COUNT counts result size of the map function.&lt;br /&gt;
voidMAP_COUNT(void *key, void *val, int keySize, int valSize);&lt;br /&gt;
//The map function.&lt;br /&gt;
voidMAP(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
//REDUCE_COUNT counts result size of the reduce function.&lt;br /&gt;
void REDUCE_COUNT(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
//The reduce function.&lt;br /&gt;
void REDUCE(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Mars has the following four system-provided APIs. The emit functions are used in user-implemented map and reduce functions to output the intermediate/final results.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Emit the key size and the value size inMAP_COUNT.&lt;br /&gt;
void EMIT_INTERMEDIATE_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit an intermediate result in MAP.&lt;br /&gt;
void EMIT_INTERMEDIATE(void* key, void* val, int keySize, int valSize);&lt;br /&gt;
//Emit the key size and the value size in REDUCE_COUNT.&lt;br /&gt;
void EMIT_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit a final result in REDUCE.&lt;br /&gt;
void EMIT(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Overall, the APIs in Mars are similar to those in the existing MapReduce frameworks such as Hadoop and Phoenix. The major difference is that Mars needs two APIs to implement the functionality of each CPU-based API. One is to count the size of results, and the other one is to output the results. This is because the GPU does not support atomic operations, and the Mars runtime uses a two-step design for the result output.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Details ===&lt;br /&gt;
&lt;br /&gt;
* Since the GPU does not support dynamic memory allocation on the device memory during the execution of the GPU code, arrays are used as the main data structure. &lt;br /&gt;
* The input data, the intermediate result and the final result are stored in three kinds of arrays, i.e., the key array, the value array and the directory index. The directory index consists of an entry of &amp;lt;key offset, key size, value offset, value size&amp;gt; for each key/value pair. &lt;br /&gt;
* Given a directory index entry, the key or the value at the corresponding offset in the key array or the value array is fetched. &lt;br /&gt;
* With the array structure, for the input data as well as for the result output the space on the device memory is allocated before executing the GPU program. However, the sizes of the output from the map and the reduce stages are unknown. The output scheme for the map stage is similar to that for the reduce stage.&lt;br /&gt;
&lt;br /&gt;
First, each map task outputs three counts, i.e., the number of intermediate results, the total size of keys (in bytes) and the total size of values (in bytes) generated by the map task. Based on key sizes (or value sizes) of all map tasks, the run-time system computes a prefix sum on these sizes and produces an array of write locations. A write location is the start location in the output array for the corresponding map task to write. Based on the number of intermediate results, the run-time system computes a prefix sum and produces an array of start locations in the output directory index for the corresponding map task. Through these prefix sums, the sizes of the arrays for the intermediate result is also known. Thus, the run-time allocates arrays in the device memory with the exact size for storing the intermediate results.&lt;br /&gt;
&lt;br /&gt;
Second, each map task outputs the intermediate key/value pairs to the output array and updates the directory index. Since each map has its deterministic and non-overlapping positions to write to, the write conflicts are avoided. This two-step scheme does not require the hardware support of atomic functions. It is suitable for the massive thread parallelism on the GPU. However, it doubles the map computation in the worst case. The overhead of this scheme is application dependent, and is usually much smaller than that in the worst case.&lt;br /&gt;
&lt;br /&gt;
=== Optimization Techniques ===&lt;br /&gt;
==== Memory Optimizations ====&lt;br /&gt;
Two memory optimizations are used to reduce the number of memory requests in order to improve the memory bandwidth utilization. &lt;br /&gt;
* '''Coalesced accesses'''&lt;br /&gt;
The GPU feature of coalesced accesses is utilized to improve the memory performance. The memory accesses of each thread to the data arrays are designed according to the coalesced access pattern when applicable. Suppose there are T threads in total and the number of key/value pairs is N in the map stage. Thread i processes the (i + T • k )th (k=0,..,N/T) key/value pair. Due to the SIMD property of the GPU, the memory addresses from the threads within a thread group are consecutive and these accesses are coalesced into one. The figure below illustrates the map stage with and without the coalesced access optimization.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mars.jpg]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Accesses using built-in vector types'''&lt;br /&gt;
Accessing the values in the device memory can be costly, because the data values are often&lt;br /&gt;
of different sizes and the accesses are hardly coalesced. Fortunately, GPUs such as G80 support built-in vector types such as char4 and int4. Reading built-in vectors fetches the entire vector&lt;br /&gt;
in a single memory request. Compared with reading char or int, the number of memory requests is greatly reduced and the memory performance is improved.&lt;br /&gt;
&lt;br /&gt;
==== Thread parallelism ====&lt;br /&gt;
The thread configuration, i.e., the number of thread groups and the number of threads per thread group, is related to multiple factors including, (1) the hardware configuration such as the number of multiprocessors and the on-chip computation resources such as the number of registers on each multiprocessor, (2) the computation characteristics of the map and the reduce tasks, e.g., they are memory- or computation-intensive. Since the map and the reduce functions are implemented by the developer, and their costs are unknown to the runtime system, it is difficult to find the optimal setting for the thread configuration at&lt;br /&gt;
run time.&lt;br /&gt;
&lt;br /&gt;
==== Handling variable-sized types ==== &lt;br /&gt;
The variable-sized types are supported with the directory index. If two key/value pairs need to be swapped, their corresponding entries in the directory index are swapped without modifying the key and the value arrays. This choice is to save the swapping cost since the directory entries are typically much smaller than the key/value pairs. Even though swapping changes the order of entries in the directory index, the array layout is preserved and therefore accesses to the directory index can still be coalesced after swaps. Since strings are a typical variable-sized type, and string processing is common in web data analysis tasks, a GPU-based string manipulation library was developed for Mars. The operations in the library include strcmp, strcat, memset and so on. The APIs of these operations are consistent with those in C/C++ library on the CPU. The difference is that simple algorithms for these GPU-based string operations were used, since they usually handle small strings within a map or a reduce task. In addition, char4 is used to implement strings to optimize the memory performance.&lt;br /&gt;
&lt;br /&gt;
==== Hashing ====&lt;br /&gt;
Hashing is used in the sort algorithm to store the results with the same key value consecutively. In that case, it is not needed that the results with the key values are in their strict ascending/ decreasing order. The hashing technique that hashes a key into a 32-bit integer is used, and the records are sorted according to their hash values. When two records are compared, their hash values are compared first. Only when their hash values are the same, their keys are fetched and compared. Given a good hash function, the probability of comparing the keys is low.&lt;br /&gt;
&lt;br /&gt;
==== File manipulation ====&lt;br /&gt;
Currently, the GPU cannot directly access the data in the hard disk. Thus, the file manipulation with the assistance of the CPU is performed in three phases. First, the file I/O on the CPU is performed and the file data is loaded into a buffer in the main memory. To reduce the I/O stall, multiple threads are used to perform the I/O task. Second, the preprocessing on the buffered data is performed and the input key/value pairs are obtained. Finally, the input key/value pairs are copied to the GPU device memory.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Provides a performance speedup of accessing data by using built-in vector types. These vector types  reduces the number of memory requests and improves the bandwidth utilization.&lt;br /&gt;
# Applications written on Mars may or may not have the reduce stage and thus improves speedup.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# GPU based applications are much more complex&lt;br /&gt;
# Mars currently handles data that can fit into the device memory but has not yet been checked to support massive data sets&lt;br /&gt;
&lt;br /&gt;
= More Examples =&lt;br /&gt;
Below are a few simple examples of programs that can be easily expressed as MapReduce computations.&lt;br /&gt;
*Distributed [http://unixhelp.ed.ac.uk/CGI/man-cgi?grep Grep]: The map function emits a line if it matches a given pattern. The reduce function is an identity function that just copies the supplied intermediate data to the output. &amp;lt;br&amp;gt;&lt;br /&gt;
*Count of URL Access Frequency: The map function processes logs of web page requests and outputs &amp;lt;URL, 1&amp;gt;. The reduce function adds together all values for the same URL and emits a &amp;lt;URL, total count&amp;gt; pair. &amp;lt;br&amp;gt;&lt;br /&gt;
*[http://books.google.com/books?id=gJrmszNHQV4C&amp;amp;pg=PA376&amp;amp;lpg=PA376&amp;amp;dq=what+is+reverse+web+link+graph&amp;amp;source=bl&amp;amp;ots=rLQ2yuV6oc&amp;amp;sig=wimcG_7MR7d9g-ePGXkEK1ANmws&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ei=BtxBT5HkN42DtgefhbXRBQ&amp;amp;ved=0CEwQ6AEwBg#v=onepage&amp;amp;q=what%20is%20reverse%20web%20link%20graph&amp;amp;f=false Reverse Web-Link Graph]: The map function outputs &amp;lt;target, source&amp;gt; pairs for each link to a target URL found in a page named &amp;quot;source&amp;quot;. The reduce function concatenates the list of all source URLs associated with a given target URL and emits the pair: &amp;lt;target, list(source)&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
*Term-Vector per Host: A term vector summarizes the most important words that occur in a document or a set of documents as a list of &amp;lt;word, frequency&amp;gt; pairs. The map function emits a &amp;lt;hostname, term vector&amp;gt; pair for each input document (where the hostname is extracted from the URL of the document). The reduce function is passed all per-document term vectors for a given host. It adds these term vectors together, throwing away infrequent terms, and then emits a final &amp;lt;hostname, term vector&amp;gt; pair.&amp;lt;br&amp;gt;&lt;br /&gt;
*[http://nlp.stanford.edu/IR-book/html/htmledition/a-first-take-at-building-an-inverted-index-1.html Inverted Index]: The map function parses each document, and emits a sequence of &amp;lt;word, document ID&amp;gt; pairs. The reduce function accepts all pairs for a given word, sorts the corresponding document IDs and emits a &amp;lt;word, list(document ID)&amp;gt; pair. The set of all output pairs forms a simple inverted index. It is easy to augment this computation to keep track of word positions.&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Google’s MapReduce runtime implementation targets large clusters of Linux PCs connected through Ethernet switches. Tasks are forked using remote procedure calls. Buffering and communication occurs by reading and writing files on a distributed file system. The locality optimizations focus mostly on avoiding remote file accesses. While such a system is effective with distributed computing, it leads to very high overheads if used with shared-memory systems that facilitate communication through memory and are typically of much smaller scale.&lt;br /&gt;
&lt;br /&gt;
Phoenix, implementation of MapReduce uses shared memory and minimizes the overheads of task spawning and data communication. With Phoenix,the programmer can provide a simple, functional expression of the algorithm and leaves parallelization and scheduling to the runtime system.Phoenix leads to scalable performance for both multi-core chips and conventional symmetric multiprocessors. Phoenix automatically handles key scheduling decisions during parallel execution. Despite runtime overheads, results have shown that performance of Phoenix to that of parallel code written in P-threads API are almost similar. Nevertheless,there are also applications that do not fit naturally in the MapReduce model for which P-threads code performs significantly better.&lt;br /&gt;
&lt;br /&gt;
Graphics processors have emerged as a commodity platform for parallel computing. However, the developer requires the knowledge of the GPU architecture and much effort in developing GPU applications. Such difficulty is even more for complex and performance centric tasks such as web data analysis. Since MapReduce has been successful in easing the development of web data analysis tasks, one can use a GPU-based MapReduce for these applications. With the GPU-based framework, the developer writes their code using the simple and familiar MapReduce interfaces. The runtime on the GPU is completely hidden from the developer by the framework.&lt;br /&gt;
&lt;br /&gt;
The framework is followed by criticisms as well. Google was awarded the patent for MapReduce, but it can be argued that this technology is similar to many other already existing ones. There are programming models that are similar to MapReduce like Algorithm Skeletons (Parallelism Patterns), Sector/Sphere, Datameer Analytics Solution. Algorithm Skeletons are a high-level parallel programming model for parallel and distributed computing.This frameowrk libraries are used for a number of applications. Sector/Sphere is a distributed file system targeting data storage over a large number of commodity computers. Sphere is the programming framework that supports massive in-storage parallel data processing for data stored in Sector. Additionally, Sector/Sphere is unique in its ability to operate in a wide area network (WAN) setting. Datameer Analytics Solution (DAS) is a business integration platform for Hadoop and includes data source integration, an analytics engine with a spreadsheet interface designed for business users with over 180 analytic functions and visualization including reports, charts and dashboards.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Interesting Read =&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Algorithmic_skeleton#Frameworks_and_libraries Algorithm Skeleton]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Sector/Sphere Sector/Sphere]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Datameer Datameer Analytic Solution]&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:HMR.png&amp;diff=73444</id>
		<title>File:HMR.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:HMR.png&amp;diff=73444"/>
		<updated>2013-02-21T01:00:22Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73443</id>
		<title>CSC/ECE 506 Spring 2013/3b xz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73443"/>
		<updated>2013-02-21T01:00:15Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Apache’s Hadoop MapReduce */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to MapReduce =&lt;br /&gt;
MapReduce is a software framework introduced by Google in 2004 to support [http://publib.boulder.ibm.com/infocenter/txformp/v6r0m0/index.jsp?topic=%2Fcom.ibm.cics.te.doc%2Ferziaz0015.htm distributed computing] on large data sets on clusters of computers. &lt;br /&gt;
&lt;br /&gt;
MapReduce programming model consists of two major steps: &lt;br /&gt;
&lt;br /&gt;
* In the '''map''' step, the problem being solved is divided into a series of sub-problems and distributed to different workers. &lt;br /&gt;
&lt;br /&gt;
* After collecting results from workers, the computation enters the '''reduce''' step to combine and produce the final result.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of the Programming Model =&lt;br /&gt;
[[File:Mapreduce.png|thumbnail|MapReduce for a Shape Counter]]&lt;br /&gt;
The MapReduce programming model is inspired by [http://enfranchisedmind.com/blog/posts/what-is-a-functional-programming-language/ functional languages] and targets data-intensive computations. &lt;br /&gt;
&lt;br /&gt;
The input data format is application-specific, and is specified by the user. The output is a set of &amp;lt;key,value&amp;gt; pairs. The user expresses an algorithm using two functions, Map and Reduce. The Map function is applied on the input data and produces a list of intermediate &amp;lt;key,value&amp;gt; pairs. The Reduce function is applied to all intermediate pairs with the same key. It typically performs some kind of merging operation and produces zero or more output pairs. Finally, the output pairs are sorted by their key value. In the simplest form of MapReduce programs, the programmer provides just the Map function. All other functionality, including the grouping of the intermediate pairs which have the same key and the final sorting, is provided by the runtime.&lt;br /&gt;
&lt;br /&gt;
The programmer provides a simple description of the algorithm that focuses on functionality and not on parallelization. The actual parallelization and the details of concurrency management are left to the runtime system. Hence the program code is generic and easily portable across systems. Nevertheless, the model provides sufficient high-level information for parallelization. The Map function can be executed in parallel on non-overlapping portions of the input data and the Reduce function can be executed in parallel on each set of intermediate pairs with the same key. Similarly, since it is explicitly known which pairs each function will operate upon, one can employ pre-fetching or other scheduling optimizations for locality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Sample Code''&lt;br /&gt;
&lt;br /&gt;
The following pseudo-code shows the basic structure of a MapReduce program. &lt;br /&gt;
&lt;br /&gt;
Program to counts number of occurrences of each word in a collection of documents.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Input : a Document&lt;br /&gt;
//Intermediate Output: key = word, value = 1&lt;br /&gt;
Map(void * input){&lt;br /&gt;
   for each word w in Input&lt;br /&gt;
       Emit Intermediate(w,1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Intermediate Output key = word, value = 1&lt;br /&gt;
//Output : key = word, value = occurrences&lt;br /&gt;
Reduce(String key, Iterator values){&lt;br /&gt;
   int result = 0;&lt;br /&gt;
   for each v in values &lt;br /&gt;
       result += v&lt;br /&gt;
   Emit(w, result)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Role of the Run-time System =&lt;br /&gt;
In both steps of MapReduce, the run-time must decide on factors such as the size of the units, the number of nodes involved, how units are assigned to nodes dynamically, and how buffer space is allocated. The decisions can be fully automatic or guided by the programmer given application specific knowledge. These decisions allow the run-time to execute a program efficiently across a wide range of machines and data-set scenarios without modifications to the source code. Finally, the run-time must merge and sort the output pairs from all Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
= Implementations =&lt;br /&gt;
Many different implementations of the MapReduce interface are possible. The right choice depends on the environment. For example, one implementation may be suitable for a small shared-memory machine, another for a large [http://msdn.microsoft.com/en-us/library/ms178144.aspx NUMA] multi-processor, and yet another for an even larger collection of networked machines. &lt;br /&gt;
&lt;br /&gt;
* Google's MapReduce and [http://en.wikipedia.org/wiki/Apache_Hadoop Hadoop] implement map reduce for large clusters of commodity PCs connected together with switched Ethernet.&lt;br /&gt;
&lt;br /&gt;
* [http://mapreduce.stanford.edu/ Phoenix] implements MapReduce for shared-memory systems.&lt;br /&gt;
&lt;br /&gt;
* [http://www.cse.ust.hk/gpuqp/Mars.html Mars] is a MapReduce framework on graphics processors ([http://www.nvidia.com/object/gpu.html GPUs]).&lt;br /&gt;
&lt;br /&gt;
== Google's MapReduce ==&lt;br /&gt;
&lt;br /&gt;
=== Execution Overview ===&lt;br /&gt;
The Map invocations are distributed across multiple machines by automatically partitioning the input data into a set of M splits. The input splits can be processed in parallel by different machines. Reduce invocations are distributed by partitioning the intermediate key space into R pieces using a partitioning function (e.g., hash(key) mod R). The number of partitions (R) and the partitioning function are specified by the user. Below is a detailed look. &amp;lt;ref&amp;gt;http://static.usenix.org/event/osdi04/tech/full_papers/dean/dean.pdf Simplified Data Processing on Large Clusters&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Google Map Reduce.jpg|center|Google's MapReduce]] &amp;lt;br&amp;gt;&lt;br /&gt;
The figure above shows the overall flow of a MapReduce operation in Google's implementation. When the user program calls the MapReduce function, the following sequence of actions occurs (the numbered labels in the figure above correspond to the numbers in the list below):&lt;br /&gt;
&lt;br /&gt;
# The MapReduce library in the user program first splits the input files into M pieces of typically 16 megabytes to 64 megabytes (MB) per piece (controllable by the user via an optional parameter). It then starts up many copies of the program on a cluster of machines.&lt;br /&gt;
# One of the copies of the program is special, ''the master''. The rest are workers that are assigned work by the master. There are ''M'' map tasks and R reduce tasks to assign. The master picks idle workers and assigns each one a map task or a reduce task.&lt;br /&gt;
# A worker who is assigned a map task reads the contents of the corresponding input split. It parses ''key/value'' pairs out of the input data and passes each pair to the user-defined Map function. The intermediate ''key/value'' pairs produced by the Map function are buffered in memory. &lt;br /&gt;
# Periodically, the buffered pairs are written to local disk, partitioned into ''R'' regions by the partitioning function. The locations of these buffered pairs on the local disk are passed back to the master, who is responsible for forwarding these locations to the reduce workers. When a reduce worker is notified by the master about these locations, it uses remote procedure calls to read the buffered data from the local disks of the  map workers.&lt;br /&gt;
# When a reduce worker has read all intermediate data, it sorts it by the intermediate keys so that all occurrences of the same key are grouped together. The sorting is needed because typically many different keys map to the same reduce task. If the amount of intermediate data is too large to fit in memory, an external sort is used.&lt;br /&gt;
# The reduce worker iterates over the sorted intermediate data and for each unique intermediate key encountered, it passes the key and the corresponding set of intermediate values to the user's Reduce function. The output of the Reduce function is appended to a final output file for this reduce partition.&lt;br /&gt;
# When all map tasks and reduce tasks have been completed, the master wakes up the user program. At this point, the MapReduce call in the user program returns back to the user code.&lt;br /&gt;
# After successful completion, the output of the mapreduce execution is available in the ''R'' output files (one per reduce task, with file names as specified by the user). Typically, users do not need to combine these ''R'' output files into one file . They often pass these files as input to another MapReduce call, or use them from another distributed application that is able to deal with input that is partitioned into multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Data Structures: Master ===&lt;br /&gt;
&lt;br /&gt;
The master keeps several data structures. For each map task and reduce task, it stores the state (idle, in-progress, or completed), and the identity of the worker machine (for non-idle tasks).&lt;br /&gt;
The master is the conduit through which the location of intermediate file regions is propagated from map tasks to reduce tasks. Therefore, for each completed map task, the master stores the locations and sizes of the ''R'' intermediate file regions produced by the map task. Updates to this location and size information are received as map tasks are completed. The information is pushed incrementally to workers that have in-progress reduce tasks.&lt;br /&gt;
&lt;br /&gt;
=== Fault Tolerance ===&lt;br /&gt;
&lt;br /&gt;
Since the MapReduce library is designed to help process very large amounts of data using hundreds or thousands of machines, the library must tolerate machine failures gracefully.&lt;br /&gt;
&lt;br /&gt;
* '''Master Failure'''&lt;br /&gt;
&lt;br /&gt;
It is easy to make the master write periodic checkpoints of the master data structures. If the master task dies, a new copy can be started from the last checkpoint. However, given that there is only a single master, its failure is unlikely; therefore Google's current implementation aborts the MapReduce computation if the master fails. Clients can check for this condition and retry the MapReduce operation if they desire.&lt;br /&gt;
&lt;br /&gt;
* '''Worker Failure'''&lt;br /&gt;
&lt;br /&gt;
The master pings every worker periodically. If no response is received from a worker in a certain amount of time, the master marks the worker as failed. Any map tasks completed by the worker are reset back to their initial idle state, and therefore become eligible for scheduling&lt;br /&gt;
on other workers. Similarly, any map task or reduce task in progress on a failed worker is also reset to idle and becomes eligible for rescheduling. Completed map tasks are re-executed on a failure because their output is stored on the local disk(s) of the failed machine and is therefore inaccessible. Completed reduce tasks do not need to be re-executed since their output is stored in a global file system. When a map task is executed first by worker ''A'' and then later executed by worker ''B'' (because ''A'' failed), all workers executing reduce tasks are notified of the re-execution. Any reduce task that has not already read the data from worker ''A'' will read the data from worker ''B''. MapReduce is resilient to large-scale worker failures.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Large variety of problems are easily expressible as Map-Reduce computations. &lt;br /&gt;
# The model is easy to use, even for programmers without experience with parallel and distributed systems, since it hides the details of parallelization, fault tolerance, locality optimization, and load balancing. For example, Map-Reduce is used for the generation of data for Google’s production Web search service, for sorting, data mining, machine learning, and many other systems.&lt;br /&gt;
# Implementation of Map-Reduce can be scaled to large clusters of machines comprising thousands of machines.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# Restricted programming model puts bounds on the way you implement the framework. &lt;br /&gt;
# Since network bandwidth is scarce, a number of optimization in the system are therefore targeted at reducing the amount of data sent across the network.&lt;br /&gt;
&lt;br /&gt;
=== Apache’s Hadoop MapReduce ===&lt;br /&gt;
&lt;br /&gt;
Apache, after Google published the paper on MapReduce and Google File System (GFS &amp;lt;ref&amp;gt;http://www.cs.rochester.edu/meetings/sosp2003/papers/p125-ghemawat.pdf&amp;lt;/ref&amp;gt;) introduced it's own implementation of the same. The important thing to note here is that Apache made this framework open-source. This framework transparently provides both reliability and data motion to applications. Hadoop has prominent users such as Yahoo! and Facebook.&lt;br /&gt;
(Good Read!&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Apache_Hadoop Apache Hadoop&amp;lt;/ref&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Hadoop MapRed is based on a “pull” model where multiple “TaskTrackers” poll the “JobTracker” for tasks (either map task or reduce task).&lt;br /&gt;
&lt;br /&gt;
[[File:HMR.png|center|Apache Hadoop MapReduce]]&lt;br /&gt;
The figure above depicts the execution of thejob. Client program uploads files to the HDFS location and notifies the JobTracker which in turn returns the Job ID to the client. The Jobtracker allocates map tasks to the TaskTrackers. JobTracker determines appropriate jobs based on how busy the TaskTracker is. &lt;br /&gt;
&lt;br /&gt;
TaskTracker forks MapTask which extracts input data and invokees the user provided &amp;quot;map&amp;quot; function which fills in the buffer with key/value pairs until it is full. The buffer is eventually flushed into two files. After all the MapTask completes (all splits are done), the TaskTracker will notify the JobTracker which keeps track of the overall progress of job.&lt;br /&gt;
&lt;br /&gt;
When done, the JobTracker notifies TaskTracker to jump to reduce phase. This again follows same method where reduce task is forked. The output of each reducer is written to a temporary output file in HDFS. When the reducer finishes processing all keys, the temp output file will be renamed atomically to its final output filename.&lt;br /&gt;
&lt;br /&gt;
== Phoenix ==&lt;br /&gt;
Phoenix&amp;lt;ref&amp;gt;&lt;br /&gt;
http://csl.stanford.edu/~christos/publications/2007.cmp_mapreduce.hpca.pdf Evaluating MapReduce for Multi-core and Multiprocessor Systems&amp;lt;/ref&amp;gt; implements MapReduce for shared-memory systems. Its goal is to support efficient execution on multiple cores without burdening the programmer with concurrency management. Phoenix consists of a simple API that is visible to application programmers and an efficient runtime that handles parallelization, resource management, and fault recovery.&lt;br /&gt;
&lt;br /&gt;
=== Phoenix API ===&lt;br /&gt;
The current Phoenix implementation provides an API for C and C++. &amp;lt;br&amp;gt;&lt;br /&gt;
* The first set is provided by Phoenix and is used by the programmer’s application code to initialize the system and emit output pairs (1 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
* The second set includes the functions that the programmer defines (3 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from the Map and Reduce functions, the user provides functions that partition the data before each step and a function that implements key comparison. The function arguments are declared as void pointers wherever possible to provide flexibility in their declaration and fast use without conversion overhead. The data structure used to communicate basic function information and buffer allocation between the user code and run-time is of type ''scheduler_args_t'' ([http://pages.cs.wisc.edu/~gibson/mapreduceexample/MapReduceScheduler.h.html MapReduce Header File]). There are additional data structure types to facilitate communication between the Splitter, Map, Partition, and Reduce functions. These types use pointers whenever possible to implement communication without actually copying significant amounts of data.&lt;br /&gt;
&lt;br /&gt;
The Phoenix API does not rely on any specific compiler options and does not require a parallelizing compiler. However, it assumes that its functions can freely use stack-allocated and heap-allocated structures for private data. It also assumes that there is no communication through shared-memory structures other than the input/output buffers for these functions. For C/C++, these assumptions cannot be checked statically for arbitrary programs. Although there are stringent checks within the system to ensure valid data are communicated between user and run-time code, eventually it is the task of user to provide functionally correct code. &lt;br /&gt;
&lt;br /&gt;
[[File:Phoenix.jpg|center|Phoenix MapReduce]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Phoenix run-time was developed on top of [http://en.wikipedia.org/wiki/POSIX_Threads POSIX threads], but can be easily ported to other shared memory thread packages. The figure above shows the basic data flow for the run-time system. &lt;br /&gt;
&lt;br /&gt;
* The run-time is controlled by the scheduler, which is initiated by user code. &lt;br /&gt;
* The scheduler creates and manages the threads that run all Map and Reduce tasks. It also manages the buffers used for task communication. &lt;br /&gt;
* The programmer provides the scheduler with all the required data and function pointers through the ''scheduler_args_t'' structure. &lt;br /&gt;
*After initialization, the scheduler determines the number of cores to use for this computation. For each core, it spawns a worker thread that is dynamically assigned some number of Map and Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
To start the '''Map''' stage, the scheduler uses the ''Splitter'' to divide input pairs into equally sized units to be processed by the Map tasks. The Splitter is called once per Map task and returns a pointer to the data the Map task will process. The Map tasks are allocated dynamically to workers and each one emits intermediate &amp;lt;key,value&amp;gt; pairs. The ''Partition'' function splits the intermediate pairs into units for the Reduce tasks. The function ensures all values of the same key go to the same unit. Within each buffer, values are ordered by key to assist with the final sorting. At this point, the Map stage is over. The scheduler must wait for all Map tasks to complete before initiating the Reduce stage.&lt;br /&gt;
&lt;br /&gt;
'''Reduce''' tasks are also assigned to workers dynamically, similar to Map tasks. The one difference is that, while with Map tasks there is complete freedom in distributing pairs across tasks, with Reduce all values for the same key must be processed in one task. Hence, the Reduce stage may exhibit higher imbalance across workers and dynamic scheduling is more important. The output of each Reduce task is already sorted by key. As the last step, the final output from all tasks is merged into a single buffer, sorted by keys.&lt;br /&gt;
&lt;br /&gt;
=== Buffer Management ===&lt;br /&gt;
Two types of temporary buffers are necessary to store data between the various stages. All buffers are allocated in shared memory but are accessed in a well specified way by a few functions. To re-arrange buffers (e.g., split across tasks), pointer manipulation is done instead of the actual pairs, which may be large in size. The intermediate buffers are not directly visible to user code. Map-Reduce buffers are used to store the intermediate output pairs. Each worker has its own set of buffers. The buffers are initially sized to a default value and then resized dynamically as needed. At this stage, there may be multiple pairs with the same key. To accelerate the Partition function, the Emit intermediate function stores all values for the same key in the same buffer. At the end of the Map task, each buffer is sorted by key order. Reduce- Merge buffers are used to store the outputs of Reduce tasks before they are sorted. At this stage, each key has only one value associated with it. After sorting, the final output is available in the user allocated Output data buffer.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Phoenix is fast and scalable across all workloads&lt;br /&gt;
# On clusters of machines, the combiner function reduces the number of key-value pairs that must be exchanged between machines. These combiners contribute to better data locality and lower memory allocation pressure, resulting in substantial number of applications being scalable.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&amp;lt;ref&amp;gt;http://csl.stanford.edu/~christos/publications/2011.phoenixplus.mapreduce.pdf Phoenix++: Modular MapReduce for Shared Memory Systems&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Due to shared memory there is an inefficient  key-Value storage since containers must provide fast lookup and retrieval over potentially large data-set, all the while coordinating accesses across multiple threads&lt;br /&gt;
#Ineffective Combiner : However, on SMP machines memory allocation costs tend to dominate, even more than the memory traffic. Combiners fail to reduce the memory allocation pressure, since generated key-value pairs must still be stored. Further, by the time the combiners are run, those pairs may no longer be in the cache causing expensive memory access penalties.&lt;br /&gt;
#Phoenix implements internally grouping tasks into chunks to reduce scheduling costs and amortize per-task overhead. This design enables the user-implemented optimizations described in the previous two sections. However, it also has two drawbacks. Firstly, since the code for grouping tasks is pushed into user code, map function becomes more complicated due to the extra code to deal with chunks. Secondly, if the user leverages the exposed chunk to improve performance, the framework can no longer freely adjust the chunk size since doing so will affect the efficiency of the map function.&lt;br /&gt;
&lt;br /&gt;
== Map Reduce on Graphics Processors ==&lt;br /&gt;
=== Challenges ===&lt;br /&gt;
&lt;br /&gt;
Compared with CPUs, the hardware architecture of GPUs differs significantly. For instance, current GPUs have over one hundred [http://encyclopedia.jrank.org/articles/pages/6904/SIMD-Single-Instruction-Multiple-Data-Processing.html SIMD (Single Instruction Multiple Data)] processors whereas current multi-core CPUs offer a much smaller number of cores. Moreover, most GPUs do not support atomic operations or locks. &lt;br /&gt;
&lt;br /&gt;
Due to the architectural differences, there are following three technical challenges in implementing the MapReduce framework on the GPU. &lt;br /&gt;
# The synchronization overhead in the run-time system of the framework must be low so that the system can scale to hundreds of processors.&lt;br /&gt;
# Due to the lack of dynamic thread scheduling on current GPUs, it is essential to allocate work evenly across threads on the GPU to exploit its massive thread parallelism. &lt;br /&gt;
# The core tasks of MapReduce programs, including string processing, file manipulation and concurrent reads and writes, are unconventional to GPUs and must be handled efficiently.&lt;br /&gt;
&lt;br /&gt;
'''''Mars''''', MapReduce framework on the GPU was designed and implemented with these challenges in mind.&amp;lt;ref&amp;gt;http://www.ece.rutgers.edu/~parashar/Classes/08-09/ece572/readings/mars-pact-08.pdf Mars: A MapReduce Framework on Graphic Processors&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mars API ===&lt;br /&gt;
&lt;br /&gt;
Mars provides a small set of APIs that are similar to those of CPU-based MapReduce. Run-time system utilizes a large number of GPU threads for Map or Reduce tasks, and automatically assigns each thread a small number of key/value pairs to work on. As a result, the massive thread parallelism on the GPU is well utilized. To avoid any conflict between concurrent writes,  Mars has a lock-free scheme with low runtime overhead on the massive thread parallelism of the GPU. This scheme guarantees the correctness of parallel execution with little synchronization overhead. &lt;br /&gt;
&lt;br /&gt;
Mars has two kinds of APIs, the ''user-implemented APIs'', which the users implement, and the ''system-provided APIs'', which the users can use as library calls. &lt;br /&gt;
&lt;br /&gt;
* Mars has the following user-implemented APIs. These APIs are implemented with C/C++. ''void*'' type has been used so that the developer can manipulate strings and other complex data types conveniently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//MAP_COUNT counts result size of the map function.&lt;br /&gt;
voidMAP_COUNT(void *key, void *val, int keySize, int valSize);&lt;br /&gt;
//The map function.&lt;br /&gt;
voidMAP(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
//REDUCE_COUNT counts result size of the reduce function.&lt;br /&gt;
void REDUCE_COUNT(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
//The reduce function.&lt;br /&gt;
void REDUCE(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Mars has the following four system-provided APIs. The emit functions are used in user-implemented map and reduce functions to output the intermediate/final results.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Emit the key size and the value size inMAP_COUNT.&lt;br /&gt;
void EMIT_INTERMEDIATE_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit an intermediate result in MAP.&lt;br /&gt;
void EMIT_INTERMEDIATE(void* key, void* val, int keySize, int valSize);&lt;br /&gt;
//Emit the key size and the value size in REDUCE_COUNT.&lt;br /&gt;
void EMIT_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit a final result in REDUCE.&lt;br /&gt;
void EMIT(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Overall, the APIs in Mars are similar to those in the existing MapReduce frameworks such as Hadoop and Phoenix. The major difference is that Mars needs two APIs to implement the functionality of each CPU-based API. One is to count the size of results, and the other one is to output the results. This is because the GPU does not support atomic operations, and the Mars runtime uses a two-step design for the result output.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Details ===&lt;br /&gt;
&lt;br /&gt;
* Since the GPU does not support dynamic memory allocation on the device memory during the execution of the GPU code, arrays are used as the main data structure. &lt;br /&gt;
* The input data, the intermediate result and the final result are stored in three kinds of arrays, i.e., the key array, the value array and the directory index. The directory index consists of an entry of &amp;lt;key offset, key size, value offset, value size&amp;gt; for each key/value pair. &lt;br /&gt;
* Given a directory index entry, the key or the value at the corresponding offset in the key array or the value array is fetched. &lt;br /&gt;
* With the array structure, for the input data as well as for the result output the space on the device memory is allocated before executing the GPU program. However, the sizes of the output from the map and the reduce stages are unknown. The output scheme for the map stage is similar to that for the reduce stage.&lt;br /&gt;
&lt;br /&gt;
First, each map task outputs three counts, i.e., the number of intermediate results, the total size of keys (in bytes) and the total size of values (in bytes) generated by the map task. Based on key sizes (or value sizes) of all map tasks, the run-time system computes a prefix sum on these sizes and produces an array of write locations. A write location is the start location in the output array for the corresponding map task to write. Based on the number of intermediate results, the run-time system computes a prefix sum and produces an array of start locations in the output directory index for the corresponding map task. Through these prefix sums, the sizes of the arrays for the intermediate result is also known. Thus, the run-time allocates arrays in the device memory with the exact size for storing the intermediate results.&lt;br /&gt;
&lt;br /&gt;
Second, each map task outputs the intermediate key/value pairs to the output array and updates the directory index. Since each map has its deterministic and non-overlapping positions to write to, the write conflicts are avoided. This two-step scheme does not require the hardware support of atomic functions. It is suitable for the massive thread parallelism on the GPU. However, it doubles the map computation in the worst case. The overhead of this scheme is application dependent, and is usually much smaller than that in the worst case.&lt;br /&gt;
&lt;br /&gt;
=== Optimization Techniques ===&lt;br /&gt;
==== Memory Optimizations ====&lt;br /&gt;
Two memory optimizations are used to reduce the number of memory requests in order to improve the memory bandwidth utilization. &lt;br /&gt;
* '''Coalesced accesses'''&lt;br /&gt;
The GPU feature of coalesced accesses is utilized to improve the memory performance. The memory accesses of each thread to the data arrays are designed according to the coalesced access pattern when applicable. Suppose there are T threads in total and the number of key/value pairs is N in the map stage. Thread i processes the (i + T • k )th (k=0,..,N/T) key/value pair. Due to the SIMD property of the GPU, the memory addresses from the threads within a thread group are consecutive and these accesses are coalesced into one. The figure below illustrates the map stage with and without the coalesced access optimization.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mars.jpg]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Accesses using built-in vector types'''&lt;br /&gt;
Accessing the values in the device memory can be costly, because the data values are often&lt;br /&gt;
of different sizes and the accesses are hardly coalesced. Fortunately, GPUs such as G80 support built-in vector types such as char4 and int4. Reading built-in vectors fetches the entire vector&lt;br /&gt;
in a single memory request. Compared with reading char or int, the number of memory requests is greatly reduced and the memory performance is improved.&lt;br /&gt;
&lt;br /&gt;
==== Thread parallelism ====&lt;br /&gt;
The thread configuration, i.e., the number of thread groups and the number of threads per thread group, is related to multiple factors including, (1) the hardware configuration such as the number of multiprocessors and the on-chip computation resources such as the number of registers on each multiprocessor, (2) the computation characteristics of the map and the reduce tasks, e.g., they are memory- or computation-intensive. Since the map and the reduce functions are implemented by the developer, and their costs are unknown to the runtime system, it is difficult to find the optimal setting for the thread configuration at&lt;br /&gt;
run time.&lt;br /&gt;
&lt;br /&gt;
==== Handling variable-sized types ==== &lt;br /&gt;
The variable-sized types are supported with the directory index. If two key/value pairs need to be swapped, their corresponding entries in the directory index are swapped without modifying the key and the value arrays. This choice is to save the swapping cost since the directory entries are typically much smaller than the key/value pairs. Even though swapping changes the order of entries in the directory index, the array layout is preserved and therefore accesses to the directory index can still be coalesced after swaps. Since strings are a typical variable-sized type, and string processing is common in web data analysis tasks, a GPU-based string manipulation library was developed for Mars. The operations in the library include strcmp, strcat, memset and so on. The APIs of these operations are consistent with those in C/C++ library on the CPU. The difference is that simple algorithms for these GPU-based string operations were used, since they usually handle small strings within a map or a reduce task. In addition, char4 is used to implement strings to optimize the memory performance.&lt;br /&gt;
&lt;br /&gt;
==== Hashing ====&lt;br /&gt;
Hashing is used in the sort algorithm to store the results with the same key value consecutively. In that case, it is not needed that the results with the key values are in their strict ascending/ decreasing order. The hashing technique that hashes a key into a 32-bit integer is used, and the records are sorted according to their hash values. When two records are compared, their hash values are compared first. Only when their hash values are the same, their keys are fetched and compared. Given a good hash function, the probability of comparing the keys is low.&lt;br /&gt;
&lt;br /&gt;
==== File manipulation ====&lt;br /&gt;
Currently, the GPU cannot directly access the data in the hard disk. Thus, the file manipulation with the assistance of the CPU is performed in three phases. First, the file I/O on the CPU is performed and the file data is loaded into a buffer in the main memory. To reduce the I/O stall, multiple threads are used to perform the I/O task. Second, the preprocessing on the buffered data is performed and the input key/value pairs are obtained. Finally, the input key/value pairs are copied to the GPU device memory.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Provides a performance speedup of accessing data by using built-in vector types. These vector types  reduces the number of memory requests and improves the bandwidth utilization.&lt;br /&gt;
# Applications written on Mars may or may not have the reduce stage and thus improves speedup.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# GPU based applications are much more complex&lt;br /&gt;
# Mars currently handles data that can fit into the device memory but has not yet been checked to support massive data sets&lt;br /&gt;
&lt;br /&gt;
= More Examples =&lt;br /&gt;
Below are a few simple examples of programs that can be easily expressed as MapReduce computations.&lt;br /&gt;
*Distributed [http://unixhelp.ed.ac.uk/CGI/man-cgi?grep Grep]: The map function emits a line if it matches a given pattern. The reduce function is an identity function that just copies the supplied intermediate data to the output. &amp;lt;br&amp;gt;&lt;br /&gt;
*Count of URL Access Frequency: The map function processes logs of web page requests and outputs &amp;lt;URL, 1&amp;gt;. The reduce function adds together all values for the same URL and emits a &amp;lt;URL, total count&amp;gt; pair. &amp;lt;br&amp;gt;&lt;br /&gt;
*[http://books.google.com/books?id=gJrmszNHQV4C&amp;amp;pg=PA376&amp;amp;lpg=PA376&amp;amp;dq=what+is+reverse+web+link+graph&amp;amp;source=bl&amp;amp;ots=rLQ2yuV6oc&amp;amp;sig=wimcG_7MR7d9g-ePGXkEK1ANmws&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ei=BtxBT5HkN42DtgefhbXRBQ&amp;amp;ved=0CEwQ6AEwBg#v=onepage&amp;amp;q=what%20is%20reverse%20web%20link%20graph&amp;amp;f=false Reverse Web-Link Graph]: The map function outputs &amp;lt;target, source&amp;gt; pairs for each link to a target URL found in a page named &amp;quot;source&amp;quot;. The reduce function concatenates the list of all source URLs associated with a given target URL and emits the pair: &amp;lt;target, list(source)&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
*Term-Vector per Host: A term vector summarizes the most important words that occur in a document or a set of documents as a list of &amp;lt;word, frequency&amp;gt; pairs. The map function emits a &amp;lt;hostname, term vector&amp;gt; pair for each input document (where the hostname is extracted from the URL of the document). The reduce function is passed all per-document term vectors for a given host. It adds these term vectors together, throwing away infrequent terms, and then emits a final &amp;lt;hostname, term vector&amp;gt; pair.&amp;lt;br&amp;gt;&lt;br /&gt;
*[http://nlp.stanford.edu/IR-book/html/htmledition/a-first-take-at-building-an-inverted-index-1.html Inverted Index]: The map function parses each document, and emits a sequence of &amp;lt;word, document ID&amp;gt; pairs. The reduce function accepts all pairs for a given word, sorts the corresponding document IDs and emits a &amp;lt;word, list(document ID)&amp;gt; pair. The set of all output pairs forms a simple inverted index. It is easy to augment this computation to keep track of word positions.&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Google’s MapReduce runtime implementation targets large clusters of Linux PCs connected through Ethernet switches. Tasks are forked using remote procedure calls. Buffering and communication occurs by reading and writing files on a distributed file system. The locality optimizations focus mostly on avoiding remote file accesses. While such a system is effective with distributed computing, it leads to very high overheads if used with shared-memory systems that facilitate communication through memory and are typically of much smaller scale.&lt;br /&gt;
&lt;br /&gt;
Phoenix, implementation of MapReduce uses shared memory and minimizes the overheads of task spawning and data communication. With Phoenix,the programmer can provide a simple, functional expression of the algorithm and leaves parallelization and scheduling to the runtime system.Phoenix leads to scalable performance for both multi-core chips and conventional symmetric multiprocessors. Phoenix automatically handles key scheduling decisions during parallel execution. Despite runtime overheads, results have shown that performance of Phoenix to that of parallel code written in P-threads API are almost similar. Nevertheless,there are also applications that do not fit naturally in the MapReduce model for which P-threads code performs significantly better.&lt;br /&gt;
&lt;br /&gt;
Graphics processors have emerged as a commodity platform for parallel computing. However, the developer requires the knowledge of the GPU architecture and much effort in developing GPU applications. Such difficulty is even more for complex and performance centric tasks such as web data analysis. Since MapReduce has been successful in easing the development of web data analysis tasks, one can use a GPU-based MapReduce for these applications. With the GPU-based framework, the developer writes their code using the simple and familiar MapReduce interfaces. The runtime on the GPU is completely hidden from the developer by the framework.&lt;br /&gt;
&lt;br /&gt;
The framework is followed by criticisms as well. Google was awarded the patent for MapReduce, but it can be argued that this technology is similar to many other already existing ones. There are programming models that are similar to MapReduce like Algorithm Skeletons (Parallelism Patterns), Sector/Sphere, Datameer Analytics Solution. Algorithm Skeletons are a high-level parallel programming model for parallel and distributed computing.This frameowrk libraries are used for a number of applications. Sector/Sphere is a distributed file system targeting data storage over a large number of commodity computers. Sphere is the programming framework that supports massive in-storage parallel data processing for data stored in Sector. Additionally, Sector/Sphere is unique in its ability to operate in a wide area network (WAN) setting. Datameer Analytics Solution (DAS) is a business integration platform for Hadoop and includes data source integration, an analytics engine with a spreadsheet interface designed for business users with over 180 analytic functions and visualization including reports, charts and dashboards.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Interesting Read =&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Algorithmic_skeleton#Frameworks_and_libraries Algorithm Skeleton]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Sector/Sphere Sector/Sphere]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Datameer Datameer Analytic Solution]&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73441</id>
		<title>CSC/ECE 506 Spring 2013/3b xz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_506_Spring_2013/3b_xz&amp;diff=73441"/>
		<updated>2013-02-21T00:58:30Z</updated>

		<summary type="html">&lt;p&gt;Amahaba: /* Apache’s Hadoop MapReduce */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to MapReduce =&lt;br /&gt;
MapReduce is a software framework introduced by Google in 2004 to support [http://publib.boulder.ibm.com/infocenter/txformp/v6r0m0/index.jsp?topic=%2Fcom.ibm.cics.te.doc%2Ferziaz0015.htm distributed computing] on large data sets on clusters of computers. &lt;br /&gt;
&lt;br /&gt;
MapReduce programming model consists of two major steps: &lt;br /&gt;
&lt;br /&gt;
* In the '''map''' step, the problem being solved is divided into a series of sub-problems and distributed to different workers. &lt;br /&gt;
&lt;br /&gt;
* After collecting results from workers, the computation enters the '''reduce''' step to combine and produce the final result.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of the Programming Model =&lt;br /&gt;
[[File:Mapreduce.png|thumbnail|MapReduce for a Shape Counter]]&lt;br /&gt;
The MapReduce programming model is inspired by [http://enfranchisedmind.com/blog/posts/what-is-a-functional-programming-language/ functional languages] and targets data-intensive computations. &lt;br /&gt;
&lt;br /&gt;
The input data format is application-specific, and is specified by the user. The output is a set of &amp;lt;key,value&amp;gt; pairs. The user expresses an algorithm using two functions, Map and Reduce. The Map function is applied on the input data and produces a list of intermediate &amp;lt;key,value&amp;gt; pairs. The Reduce function is applied to all intermediate pairs with the same key. It typically performs some kind of merging operation and produces zero or more output pairs. Finally, the output pairs are sorted by their key value. In the simplest form of MapReduce programs, the programmer provides just the Map function. All other functionality, including the grouping of the intermediate pairs which have the same key and the final sorting, is provided by the runtime.&lt;br /&gt;
&lt;br /&gt;
The programmer provides a simple description of the algorithm that focuses on functionality and not on parallelization. The actual parallelization and the details of concurrency management are left to the runtime system. Hence the program code is generic and easily portable across systems. Nevertheless, the model provides sufficient high-level information for parallelization. The Map function can be executed in parallel on non-overlapping portions of the input data and the Reduce function can be executed in parallel on each set of intermediate pairs with the same key. Similarly, since it is explicitly known which pairs each function will operate upon, one can employ pre-fetching or other scheduling optimizations for locality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Sample Code''&lt;br /&gt;
&lt;br /&gt;
The following pseudo-code shows the basic structure of a MapReduce program. &lt;br /&gt;
&lt;br /&gt;
Program to counts number of occurrences of each word in a collection of documents.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Input : a Document&lt;br /&gt;
//Intermediate Output: key = word, value = 1&lt;br /&gt;
Map(void * input){&lt;br /&gt;
   for each word w in Input&lt;br /&gt;
       Emit Intermediate(w,1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Intermediate Output key = word, value = 1&lt;br /&gt;
//Output : key = word, value = occurrences&lt;br /&gt;
Reduce(String key, Iterator values){&lt;br /&gt;
   int result = 0;&lt;br /&gt;
   for each v in values &lt;br /&gt;
       result += v&lt;br /&gt;
   Emit(w, result)&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Role of the Run-time System =&lt;br /&gt;
In both steps of MapReduce, the run-time must decide on factors such as the size of the units, the number of nodes involved, how units are assigned to nodes dynamically, and how buffer space is allocated. The decisions can be fully automatic or guided by the programmer given application specific knowledge. These decisions allow the run-time to execute a program efficiently across a wide range of machines and data-set scenarios without modifications to the source code. Finally, the run-time must merge and sort the output pairs from all Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
= Implementations =&lt;br /&gt;
Many different implementations of the MapReduce interface are possible. The right choice depends on the environment. For example, one implementation may be suitable for a small shared-memory machine, another for a large [http://msdn.microsoft.com/en-us/library/ms178144.aspx NUMA] multi-processor, and yet another for an even larger collection of networked machines. &lt;br /&gt;
&lt;br /&gt;
* Google's MapReduce and [http://en.wikipedia.org/wiki/Apache_Hadoop Hadoop] implement map reduce for large clusters of commodity PCs connected together with switched Ethernet.&lt;br /&gt;
&lt;br /&gt;
* [http://mapreduce.stanford.edu/ Phoenix] implements MapReduce for shared-memory systems.&lt;br /&gt;
&lt;br /&gt;
* [http://www.cse.ust.hk/gpuqp/Mars.html Mars] is a MapReduce framework on graphics processors ([http://www.nvidia.com/object/gpu.html GPUs]).&lt;br /&gt;
&lt;br /&gt;
== Google's MapReduce ==&lt;br /&gt;
&lt;br /&gt;
=== Execution Overview ===&lt;br /&gt;
The Map invocations are distributed across multiple machines by automatically partitioning the input data into a set of M splits. The input splits can be processed in parallel by different machines. Reduce invocations are distributed by partitioning the intermediate key space into R pieces using a partitioning function (e.g., hash(key) mod R). The number of partitions (R) and the partitioning function are specified by the user. Below is a detailed look. &amp;lt;ref&amp;gt;http://static.usenix.org/event/osdi04/tech/full_papers/dean/dean.pdf Simplified Data Processing on Large Clusters&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Google Map Reduce.jpg|center|Google's MapReduce]] &amp;lt;br&amp;gt;&lt;br /&gt;
The figure above shows the overall flow of a MapReduce operation in Google's implementation. When the user program calls the MapReduce function, the following sequence of actions occurs (the numbered labels in the figure above correspond to the numbers in the list below):&lt;br /&gt;
&lt;br /&gt;
# The MapReduce library in the user program first splits the input files into M pieces of typically 16 megabytes to 64 megabytes (MB) per piece (controllable by the user via an optional parameter). It then starts up many copies of the program on a cluster of machines.&lt;br /&gt;
# One of the copies of the program is special, ''the master''. The rest are workers that are assigned work by the master. There are ''M'' map tasks and R reduce tasks to assign. The master picks idle workers and assigns each one a map task or a reduce task.&lt;br /&gt;
# A worker who is assigned a map task reads the contents of the corresponding input split. It parses ''key/value'' pairs out of the input data and passes each pair to the user-defined Map function. The intermediate ''key/value'' pairs produced by the Map function are buffered in memory. &lt;br /&gt;
# Periodically, the buffered pairs are written to local disk, partitioned into ''R'' regions by the partitioning function. The locations of these buffered pairs on the local disk are passed back to the master, who is responsible for forwarding these locations to the reduce workers. When a reduce worker is notified by the master about these locations, it uses remote procedure calls to read the buffered data from the local disks of the  map workers.&lt;br /&gt;
# When a reduce worker has read all intermediate data, it sorts it by the intermediate keys so that all occurrences of the same key are grouped together. The sorting is needed because typically many different keys map to the same reduce task. If the amount of intermediate data is too large to fit in memory, an external sort is used.&lt;br /&gt;
# The reduce worker iterates over the sorted intermediate data and for each unique intermediate key encountered, it passes the key and the corresponding set of intermediate values to the user's Reduce function. The output of the Reduce function is appended to a final output file for this reduce partition.&lt;br /&gt;
# When all map tasks and reduce tasks have been completed, the master wakes up the user program. At this point, the MapReduce call in the user program returns back to the user code.&lt;br /&gt;
# After successful completion, the output of the mapreduce execution is available in the ''R'' output files (one per reduce task, with file names as specified by the user). Typically, users do not need to combine these ''R'' output files into one file . They often pass these files as input to another MapReduce call, or use them from another distributed application that is able to deal with input that is partitioned into multiple files.&lt;br /&gt;
&lt;br /&gt;
=== Data Structures: Master ===&lt;br /&gt;
&lt;br /&gt;
The master keeps several data structures. For each map task and reduce task, it stores the state (idle, in-progress, or completed), and the identity of the worker machine (for non-idle tasks).&lt;br /&gt;
The master is the conduit through which the location of intermediate file regions is propagated from map tasks to reduce tasks. Therefore, for each completed map task, the master stores the locations and sizes of the ''R'' intermediate file regions produced by the map task. Updates to this location and size information are received as map tasks are completed. The information is pushed incrementally to workers that have in-progress reduce tasks.&lt;br /&gt;
&lt;br /&gt;
=== Fault Tolerance ===&lt;br /&gt;
&lt;br /&gt;
Since the MapReduce library is designed to help process very large amounts of data using hundreds or thousands of machines, the library must tolerate machine failures gracefully.&lt;br /&gt;
&lt;br /&gt;
* '''Master Failure'''&lt;br /&gt;
&lt;br /&gt;
It is easy to make the master write periodic checkpoints of the master data structures. If the master task dies, a new copy can be started from the last checkpoint. However, given that there is only a single master, its failure is unlikely; therefore Google's current implementation aborts the MapReduce computation if the master fails. Clients can check for this condition and retry the MapReduce operation if they desire.&lt;br /&gt;
&lt;br /&gt;
* '''Worker Failure'''&lt;br /&gt;
&lt;br /&gt;
The master pings every worker periodically. If no response is received from a worker in a certain amount of time, the master marks the worker as failed. Any map tasks completed by the worker are reset back to their initial idle state, and therefore become eligible for scheduling&lt;br /&gt;
on other workers. Similarly, any map task or reduce task in progress on a failed worker is also reset to idle and becomes eligible for rescheduling. Completed map tasks are re-executed on a failure because their output is stored on the local disk(s) of the failed machine and is therefore inaccessible. Completed reduce tasks do not need to be re-executed since their output is stored in a global file system. When a map task is executed first by worker ''A'' and then later executed by worker ''B'' (because ''A'' failed), all workers executing reduce tasks are notified of the re-execution. Any reduce task that has not already read the data from worker ''A'' will read the data from worker ''B''. MapReduce is resilient to large-scale worker failures.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Large variety of problems are easily expressible as Map-Reduce computations. &lt;br /&gt;
# The model is easy to use, even for programmers without experience with parallel and distributed systems, since it hides the details of parallelization, fault tolerance, locality optimization, and load balancing. For example, Map-Reduce is used for the generation of data for Google’s production Web search service, for sorting, data mining, machine learning, and many other systems.&lt;br /&gt;
# Implementation of Map-Reduce can be scaled to large clusters of machines comprising thousands of machines.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# Restricted programming model puts bounds on the way you implement the framework. &lt;br /&gt;
# Since network bandwidth is scarce, a number of optimization in the system are therefore targeted at reducing the amount of data sent across the network.&lt;br /&gt;
&lt;br /&gt;
=== Apache’s Hadoop MapReduce ===&lt;br /&gt;
&lt;br /&gt;
Apache, after Google published the paper on MapReduce and Google File System (GFS &amp;lt;ref&amp;gt;http://www.cs.rochester.edu/meetings/sosp2003/papers/p125-ghemawat.pdf&amp;lt;/ref&amp;gt;) introduced it's own implementation of the same. The important thing to note here is that Apache made this framework open-source. This framework transparently provides both reliability and data motion to applications. Hadoop has prominent users such as Yahoo! and Facebook.&lt;br /&gt;
(Good Read!&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Apache_Hadoop Apache Hadoop&amp;lt;/ref&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Hadoop MapRed is based on a “pull” model where multiple “TaskTrackers” poll the “JobTracker” for tasks (either map task or reduce task).&lt;br /&gt;
&lt;br /&gt;
[[File:HMP.jpg|center|Google's MapReduce]]&lt;br /&gt;
The figure above depicts the execution of thejob. Client program uploads files to the HDFS location and notifies the JobTracker which in turn returns the Job ID to the client. The Jobtracker allocates map tasks to the TaskTrackers. JobTracker determines appropriate jobs based on how busy the TaskTracker is. &lt;br /&gt;
&lt;br /&gt;
TaskTracker forks MapTask which extracts input data and invokees the user provided &amp;quot;map&amp;quot; function which fills in the buffer with key/value pairs until it is full. The buffer is eventually flushed into two files. After all the MapTask completes (all splits are done), the TaskTracker will notify the JobTracker which keeps track of the overall progress of job.&lt;br /&gt;
&lt;br /&gt;
When done, the JobTracker notifies TaskTracker to jump to reduce phase. This again follows same method where reduce task is forked. The output of each reducer is written to a temporary output file in HDFS. When the reducer finishes processing all keys, the temp output file will be renamed atomically to its final output filename.&lt;br /&gt;
&lt;br /&gt;
== Phoenix ==&lt;br /&gt;
Phoenix&amp;lt;ref&amp;gt;&lt;br /&gt;
http://csl.stanford.edu/~christos/publications/2007.cmp_mapreduce.hpca.pdf Evaluating MapReduce for Multi-core and Multiprocessor Systems&amp;lt;/ref&amp;gt; implements MapReduce for shared-memory systems. Its goal is to support efficient execution on multiple cores without burdening the programmer with concurrency management. Phoenix consists of a simple API that is visible to application programmers and an efficient runtime that handles parallelization, resource management, and fault recovery.&lt;br /&gt;
&lt;br /&gt;
=== Phoenix API ===&lt;br /&gt;
The current Phoenix implementation provides an API for C and C++. &amp;lt;br&amp;gt;&lt;br /&gt;
* The first set is provided by Phoenix and is used by the programmer’s application code to initialize the system and emit output pairs (1 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
* The second set includes the functions that the programmer defines (3 required and 2 optional functions). &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apart from the Map and Reduce functions, the user provides functions that partition the data before each step and a function that implements key comparison. The function arguments are declared as void pointers wherever possible to provide flexibility in their declaration and fast use without conversion overhead. The data structure used to communicate basic function information and buffer allocation between the user code and run-time is of type ''scheduler_args_t'' ([http://pages.cs.wisc.edu/~gibson/mapreduceexample/MapReduceScheduler.h.html MapReduce Header File]). There are additional data structure types to facilitate communication between the Splitter, Map, Partition, and Reduce functions. These types use pointers whenever possible to implement communication without actually copying significant amounts of data.&lt;br /&gt;
&lt;br /&gt;
The Phoenix API does not rely on any specific compiler options and does not require a parallelizing compiler. However, it assumes that its functions can freely use stack-allocated and heap-allocated structures for private data. It also assumes that there is no communication through shared-memory structures other than the input/output buffers for these functions. For C/C++, these assumptions cannot be checked statically for arbitrary programs. Although there are stringent checks within the system to ensure valid data are communicated between user and run-time code, eventually it is the task of user to provide functionally correct code. &lt;br /&gt;
&lt;br /&gt;
[[File:Phoenix.jpg|center|Phoenix MapReduce]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Phoenix run-time was developed on top of [http://en.wikipedia.org/wiki/POSIX_Threads POSIX threads], but can be easily ported to other shared memory thread packages. The figure above shows the basic data flow for the run-time system. &lt;br /&gt;
&lt;br /&gt;
* The run-time is controlled by the scheduler, which is initiated by user code. &lt;br /&gt;
* The scheduler creates and manages the threads that run all Map and Reduce tasks. It also manages the buffers used for task communication. &lt;br /&gt;
* The programmer provides the scheduler with all the required data and function pointers through the ''scheduler_args_t'' structure. &lt;br /&gt;
*After initialization, the scheduler determines the number of cores to use for this computation. For each core, it spawns a worker thread that is dynamically assigned some number of Map and Reduce tasks.&lt;br /&gt;
&lt;br /&gt;
To start the '''Map''' stage, the scheduler uses the ''Splitter'' to divide input pairs into equally sized units to be processed by the Map tasks. The Splitter is called once per Map task and returns a pointer to the data the Map task will process. The Map tasks are allocated dynamically to workers and each one emits intermediate &amp;lt;key,value&amp;gt; pairs. The ''Partition'' function splits the intermediate pairs into units for the Reduce tasks. The function ensures all values of the same key go to the same unit. Within each buffer, values are ordered by key to assist with the final sorting. At this point, the Map stage is over. The scheduler must wait for all Map tasks to complete before initiating the Reduce stage.&lt;br /&gt;
&lt;br /&gt;
'''Reduce''' tasks are also assigned to workers dynamically, similar to Map tasks. The one difference is that, while with Map tasks there is complete freedom in distributing pairs across tasks, with Reduce all values for the same key must be processed in one task. Hence, the Reduce stage may exhibit higher imbalance across workers and dynamic scheduling is more important. The output of each Reduce task is already sorted by key. As the last step, the final output from all tasks is merged into a single buffer, sorted by keys.&lt;br /&gt;
&lt;br /&gt;
=== Buffer Management ===&lt;br /&gt;
Two types of temporary buffers are necessary to store data between the various stages. All buffers are allocated in shared memory but are accessed in a well specified way by a few functions. To re-arrange buffers (e.g., split across tasks), pointer manipulation is done instead of the actual pairs, which may be large in size. The intermediate buffers are not directly visible to user code. Map-Reduce buffers are used to store the intermediate output pairs. Each worker has its own set of buffers. The buffers are initially sized to a default value and then resized dynamically as needed. At this stage, there may be multiple pairs with the same key. To accelerate the Partition function, the Emit intermediate function stores all values for the same key in the same buffer. At the end of the Map task, each buffer is sorted by key order. Reduce- Merge buffers are used to store the outputs of Reduce tasks before they are sorted. At this stage, each key has only one value associated with it. After sorting, the final output is available in the user allocated Output data buffer.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Phoenix is fast and scalable across all workloads&lt;br /&gt;
# On clusters of machines, the combiner function reduces the number of key-value pairs that must be exchanged between machines. These combiners contribute to better data locality and lower memory allocation pressure, resulting in substantial number of applications being scalable.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&amp;lt;ref&amp;gt;http://csl.stanford.edu/~christos/publications/2011.phoenixplus.mapreduce.pdf Phoenix++: Modular MapReduce for Shared Memory Systems&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Due to shared memory there is an inefficient  key-Value storage since containers must provide fast lookup and retrieval over potentially large data-set, all the while coordinating accesses across multiple threads&lt;br /&gt;
#Ineffective Combiner : However, on SMP machines memory allocation costs tend to dominate, even more than the memory traffic. Combiners fail to reduce the memory allocation pressure, since generated key-value pairs must still be stored. Further, by the time the combiners are run, those pairs may no longer be in the cache causing expensive memory access penalties.&lt;br /&gt;
#Phoenix implements internally grouping tasks into chunks to reduce scheduling costs and amortize per-task overhead. This design enables the user-implemented optimizations described in the previous two sections. However, it also has two drawbacks. Firstly, since the code for grouping tasks is pushed into user code, map function becomes more complicated due to the extra code to deal with chunks. Secondly, if the user leverages the exposed chunk to improve performance, the framework can no longer freely adjust the chunk size since doing so will affect the efficiency of the map function.&lt;br /&gt;
&lt;br /&gt;
== Map Reduce on Graphics Processors ==&lt;br /&gt;
=== Challenges ===&lt;br /&gt;
&lt;br /&gt;
Compared with CPUs, the hardware architecture of GPUs differs significantly. For instance, current GPUs have over one hundred [http://encyclopedia.jrank.org/articles/pages/6904/SIMD-Single-Instruction-Multiple-Data-Processing.html SIMD (Single Instruction Multiple Data)] processors whereas current multi-core CPUs offer a much smaller number of cores. Moreover, most GPUs do not support atomic operations or locks. &lt;br /&gt;
&lt;br /&gt;
Due to the architectural differences, there are following three technical challenges in implementing the MapReduce framework on the GPU. &lt;br /&gt;
# The synchronization overhead in the run-time system of the framework must be low so that the system can scale to hundreds of processors.&lt;br /&gt;
# Due to the lack of dynamic thread scheduling on current GPUs, it is essential to allocate work evenly across threads on the GPU to exploit its massive thread parallelism. &lt;br /&gt;
# The core tasks of MapReduce programs, including string processing, file manipulation and concurrent reads and writes, are unconventional to GPUs and must be handled efficiently.&lt;br /&gt;
&lt;br /&gt;
'''''Mars''''', MapReduce framework on the GPU was designed and implemented with these challenges in mind.&amp;lt;ref&amp;gt;http://www.ece.rutgers.edu/~parashar/Classes/08-09/ece572/readings/mars-pact-08.pdf Mars: A MapReduce Framework on Graphic Processors&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Mars API ===&lt;br /&gt;
&lt;br /&gt;
Mars provides a small set of APIs that are similar to those of CPU-based MapReduce. Run-time system utilizes a large number of GPU threads for Map or Reduce tasks, and automatically assigns each thread a small number of key/value pairs to work on. As a result, the massive thread parallelism on the GPU is well utilized. To avoid any conflict between concurrent writes,  Mars has a lock-free scheme with low runtime overhead on the massive thread parallelism of the GPU. This scheme guarantees the correctness of parallel execution with little synchronization overhead. &lt;br /&gt;
&lt;br /&gt;
Mars has two kinds of APIs, the ''user-implemented APIs'', which the users implement, and the ''system-provided APIs'', which the users can use as library calls. &lt;br /&gt;
&lt;br /&gt;
* Mars has the following user-implemented APIs. These APIs are implemented with C/C++. ''void*'' type has been used so that the developer can manipulate strings and other complex data types conveniently.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//MAP_COUNT counts result size of the map function.&lt;br /&gt;
voidMAP_COUNT(void *key, void *val, int keySize, int valSize);&lt;br /&gt;
//The map function.&lt;br /&gt;
voidMAP(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
//REDUCE_COUNT counts result size of the reduce function.&lt;br /&gt;
void REDUCE_COUNT(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
//The reduce function.&lt;br /&gt;
void REDUCE(void* key, void* vals, int keySize, int valCount);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Mars has the following four system-provided APIs. The emit functions are used in user-implemented map and reduce functions to output the intermediate/final results.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Emit the key size and the value size inMAP_COUNT.&lt;br /&gt;
void EMIT_INTERMEDIATE_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit an intermediate result in MAP.&lt;br /&gt;
void EMIT_INTERMEDIATE(void* key, void* val, int keySize, int valSize);&lt;br /&gt;
//Emit the key size and the value size in REDUCE_COUNT.&lt;br /&gt;
void EMIT_COUNT(int keySize, int valSize);&lt;br /&gt;
//Emit a final result in REDUCE.&lt;br /&gt;
void EMIT(void *key, void* val, int keySize, int valSize);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Overall, the APIs in Mars are similar to those in the existing MapReduce frameworks such as Hadoop and Phoenix. The major difference is that Mars needs two APIs to implement the functionality of each CPU-based API. One is to count the size of results, and the other one is to output the results. This is because the GPU does not support atomic operations, and the Mars runtime uses a two-step design for the result output.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Details ===&lt;br /&gt;
&lt;br /&gt;
* Since the GPU does not support dynamic memory allocation on the device memory during the execution of the GPU code, arrays are used as the main data structure. &lt;br /&gt;
* The input data, the intermediate result and the final result are stored in three kinds of arrays, i.e., the key array, the value array and the directory index. The directory index consists of an entry of &amp;lt;key offset, key size, value offset, value size&amp;gt; for each key/value pair. &lt;br /&gt;
* Given a directory index entry, the key or the value at the corresponding offset in the key array or the value array is fetched. &lt;br /&gt;
* With the array structure, for the input data as well as for the result output the space on the device memory is allocated before executing the GPU program. However, the sizes of the output from the map and the reduce stages are unknown. The output scheme for the map stage is similar to that for the reduce stage.&lt;br /&gt;
&lt;br /&gt;
First, each map task outputs three counts, i.e., the number of intermediate results, the total size of keys (in bytes) and the total size of values (in bytes) generated by the map task. Based on key sizes (or value sizes) of all map tasks, the run-time system computes a prefix sum on these sizes and produces an array of write locations. A write location is the start location in the output array for the corresponding map task to write. Based on the number of intermediate results, the run-time system computes a prefix sum and produces an array of start locations in the output directory index for the corresponding map task. Through these prefix sums, the sizes of the arrays for the intermediate result is also known. Thus, the run-time allocates arrays in the device memory with the exact size for storing the intermediate results.&lt;br /&gt;
&lt;br /&gt;
Second, each map task outputs the intermediate key/value pairs to the output array and updates the directory index. Since each map has its deterministic and non-overlapping positions to write to, the write conflicts are avoided. This two-step scheme does not require the hardware support of atomic functions. It is suitable for the massive thread parallelism on the GPU. However, it doubles the map computation in the worst case. The overhead of this scheme is application dependent, and is usually much smaller than that in the worst case.&lt;br /&gt;
&lt;br /&gt;
=== Optimization Techniques ===&lt;br /&gt;
==== Memory Optimizations ====&lt;br /&gt;
Two memory optimizations are used to reduce the number of memory requests in order to improve the memory bandwidth utilization. &lt;br /&gt;
* '''Coalesced accesses'''&lt;br /&gt;
The GPU feature of coalesced accesses is utilized to improve the memory performance. The memory accesses of each thread to the data arrays are designed according to the coalesced access pattern when applicable. Suppose there are T threads in total and the number of key/value pairs is N in the map stage. Thread i processes the (i + T • k )th (k=0,..,N/T) key/value pair. Due to the SIMD property of the GPU, the memory addresses from the threads within a thread group are consecutive and these accesses are coalesced into one. The figure below illustrates the map stage with and without the coalesced access optimization.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Mars.jpg]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Accesses using built-in vector types'''&lt;br /&gt;
Accessing the values in the device memory can be costly, because the data values are often&lt;br /&gt;
of different sizes and the accesses are hardly coalesced. Fortunately, GPUs such as G80 support built-in vector types such as char4 and int4. Reading built-in vectors fetches the entire vector&lt;br /&gt;
in a single memory request. Compared with reading char or int, the number of memory requests is greatly reduced and the memory performance is improved.&lt;br /&gt;
&lt;br /&gt;
==== Thread parallelism ====&lt;br /&gt;
The thread configuration, i.e., the number of thread groups and the number of threads per thread group, is related to multiple factors including, (1) the hardware configuration such as the number of multiprocessors and the on-chip computation resources such as the number of registers on each multiprocessor, (2) the computation characteristics of the map and the reduce tasks, e.g., they are memory- or computation-intensive. Since the map and the reduce functions are implemented by the developer, and their costs are unknown to the runtime system, it is difficult to find the optimal setting for the thread configuration at&lt;br /&gt;
run time.&lt;br /&gt;
&lt;br /&gt;
==== Handling variable-sized types ==== &lt;br /&gt;
The variable-sized types are supported with the directory index. If two key/value pairs need to be swapped, their corresponding entries in the directory index are swapped without modifying the key and the value arrays. This choice is to save the swapping cost since the directory entries are typically much smaller than the key/value pairs. Even though swapping changes the order of entries in the directory index, the array layout is preserved and therefore accesses to the directory index can still be coalesced after swaps. Since strings are a typical variable-sized type, and string processing is common in web data analysis tasks, a GPU-based string manipulation library was developed for Mars. The operations in the library include strcmp, strcat, memset and so on. The APIs of these operations are consistent with those in C/C++ library on the CPU. The difference is that simple algorithms for these GPU-based string operations were used, since they usually handle small strings within a map or a reduce task. In addition, char4 is used to implement strings to optimize the memory performance.&lt;br /&gt;
&lt;br /&gt;
==== Hashing ====&lt;br /&gt;
Hashing is used in the sort algorithm to store the results with the same key value consecutively. In that case, it is not needed that the results with the key values are in their strict ascending/ decreasing order. The hashing technique that hashes a key into a 32-bit integer is used, and the records are sorted according to their hash values. When two records are compared, their hash values are compared first. Only when their hash values are the same, their keys are fetched and compared. Given a good hash function, the probability of comparing the keys is low.&lt;br /&gt;
&lt;br /&gt;
==== File manipulation ====&lt;br /&gt;
Currently, the GPU cannot directly access the data in the hard disk. Thus, the file manipulation with the assistance of the CPU is performed in three phases. First, the file I/O on the CPU is performed and the file data is loaded into a buffer in the main memory. To reduce the I/O stall, multiple threads are used to perform the I/O task. Second, the preprocessing on the buffered data is performed and the input key/value pairs are obtained. Finally, the input key/value pairs are copied to the GPU device memory.&lt;br /&gt;
&lt;br /&gt;
=== Pros and Cons ===&lt;br /&gt;
* '''Advantages'''&lt;br /&gt;
&lt;br /&gt;
# Provides a performance speedup of accessing data by using built-in vector types. These vector types  reduces the number of memory requests and improves the bandwidth utilization.&lt;br /&gt;
# Applications written on Mars may or may not have the reduce stage and thus improves speedup.&lt;br /&gt;
&lt;br /&gt;
* '''Disadvantages'''&lt;br /&gt;
&lt;br /&gt;
# GPU based applications are much more complex&lt;br /&gt;
# Mars currently handles data that can fit into the device memory but has not yet been checked to support massive data sets&lt;br /&gt;
&lt;br /&gt;
= More Examples =&lt;br /&gt;
Below are a few simple examples of programs that can be easily expressed as MapReduce computations.&lt;br /&gt;
*Distributed [http://unixhelp.ed.ac.uk/CGI/man-cgi?grep Grep]: The map function emits a line if it matches a given pattern. The reduce function is an identity function that just copies the supplied intermediate data to the output. &amp;lt;br&amp;gt;&lt;br /&gt;
*Count of URL Access Frequency: The map function processes logs of web page requests and outputs &amp;lt;URL, 1&amp;gt;. The reduce function adds together all values for the same URL and emits a &amp;lt;URL, total count&amp;gt; pair. &amp;lt;br&amp;gt;&lt;br /&gt;
*[http://books.google.com/books?id=gJrmszNHQV4C&amp;amp;pg=PA376&amp;amp;lpg=PA376&amp;amp;dq=what+is+reverse+web+link+graph&amp;amp;source=bl&amp;amp;ots=rLQ2yuV6oc&amp;amp;sig=wimcG_7MR7d9g-ePGXkEK1ANmws&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ei=BtxBT5HkN42DtgefhbXRBQ&amp;amp;ved=0CEwQ6AEwBg#v=onepage&amp;amp;q=what%20is%20reverse%20web%20link%20graph&amp;amp;f=false Reverse Web-Link Graph]: The map function outputs &amp;lt;target, source&amp;gt; pairs for each link to a target URL found in a page named &amp;quot;source&amp;quot;. The reduce function concatenates the list of all source URLs associated with a given target URL and emits the pair: &amp;lt;target, list(source)&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
*Term-Vector per Host: A term vector summarizes the most important words that occur in a document or a set of documents as a list of &amp;lt;word, frequency&amp;gt; pairs. The map function emits a &amp;lt;hostname, term vector&amp;gt; pair for each input document (where the hostname is extracted from the URL of the document). The reduce function is passed all per-document term vectors for a given host. It adds these term vectors together, throwing away infrequent terms, and then emits a final &amp;lt;hostname, term vector&amp;gt; pair.&amp;lt;br&amp;gt;&lt;br /&gt;
*[http://nlp.stanford.edu/IR-book/html/htmledition/a-first-take-at-building-an-inverted-index-1.html Inverted Index]: The map function parses each document, and emits a sequence of &amp;lt;word, document ID&amp;gt; pairs. The reduce function accepts all pairs for a given word, sorts the corresponding document IDs and emits a &amp;lt;word, list(document ID)&amp;gt; pair. The set of all output pairs forms a simple inverted index. It is easy to augment this computation to keep track of word positions.&lt;br /&gt;
&lt;br /&gt;
= Summary =&lt;br /&gt;
Google’s MapReduce runtime implementation targets large clusters of Linux PCs connected through Ethernet switches. Tasks are forked using remote procedure calls. Buffering and communication occurs by reading and writing files on a distributed file system. The locality optimizations focus mostly on avoiding remote file accesses. While such a system is effective with distributed computing, it leads to very high overheads if used with shared-memory systems that facilitate communication through memory and are typically of much smaller scale.&lt;br /&gt;
&lt;br /&gt;
Phoenix, implementation of MapReduce uses shared memory and minimizes the overheads of task spawning and data communication. With Phoenix,the programmer can provide a simple, functional expression of the algorithm and leaves parallelization and scheduling to the runtime system.Phoenix leads to scalable performance for both multi-core chips and conventional symmetric multiprocessors. Phoenix automatically handles key scheduling decisions during parallel execution. Despite runtime overheads, results have shown that performance of Phoenix to that of parallel code written in P-threads API are almost similar. Nevertheless,there are also applications that do not fit naturally in the MapReduce model for which P-threads code performs significantly better.&lt;br /&gt;
&lt;br /&gt;
Graphics processors have emerged as a commodity platform for parallel computing. However, the developer requires the knowledge of the GPU architecture and much effort in developing GPU applications. Such difficulty is even more for complex and performance centric tasks such as web data analysis. Since MapReduce has been successful in easing the development of web data analysis tasks, one can use a GPU-based MapReduce for these applications. With the GPU-based framework, the developer writes their code using the simple and familiar MapReduce interfaces. The runtime on the GPU is completely hidden from the developer by the framework.&lt;br /&gt;
&lt;br /&gt;
The framework is followed by criticisms as well. Google was awarded the patent for MapReduce, but it can be argued that this technology is similar to many other already existing ones. There are programming models that are similar to MapReduce like Algorithm Skeletons (Parallelism Patterns), Sector/Sphere, Datameer Analytics Solution. Algorithm Skeletons are a high-level parallel programming model for parallel and distributed computing.This frameowrk libraries are used for a number of applications. Sector/Sphere is a distributed file system targeting data storage over a large number of commodity computers. Sphere is the programming framework that supports massive in-storage parallel data processing for data stored in Sector. Additionally, Sector/Sphere is unique in its ability to operate in a wide area network (WAN) setting. Datameer Analytics Solution (DAS) is a business integration platform for Hadoop and includes data source integration, an analytics engine with a spreadsheet interface designed for business users with over 180 analytic functions and visualization including reports, charts and dashboards.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Interesting Read =&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Algorithmic_skeleton#Frameworks_and_libraries Algorithm Skeleton]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Sector/Sphere Sector/Sphere]&lt;br /&gt;
# [http://en.wikipedia.org/wiki/Datameer Datameer Analytic Solution]&lt;/div&gt;</summary>
		<author><name>Amahaba</name></author>
	</entry>
</feed>