1 / 60

Master Program (Laurea Magistrale) in Computer Science and Networking

Master Program (Laurea Magistrale) in Computer Science and Networking High Performance Computing Systems and Enabling Platforms Marco Vanneschi. 4. Shared Memory Parallel Architectures 4.3. Interprocess Communication and Cache Coherence. Run-time support of concurrency mechanisms.

casey
Download Presentation

Master Program (Laurea Magistrale) in Computer Science and Networking

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Master Program (Laurea Magistrale) in Computer Science and Networking High Performance ComputingSystems and EnablingPlatforms Marco Vanneschi 4. SharedMemoryParallelArchitectures 4.3. InterprocessCommunication and Cache Coherence

  2. Run-timesupportofconcurrencymechanisms • Features of the multiprocessor run-time support: • Locking: indivisibility (atomicity) of concurrency mechanims. • Low-level scheduling: different versions of process wake-up procedure for anonymous vs dedicated processors architectures • Communication processor: overlapping of interprocess communication to calculation. send implementation. • Cache-coherence: automatic firmware support vs algorithm dependent approach. send implementation. • Interprocess communication cost model, referring to the algorithm-dependent cache coherence implementation. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  3. 1. LOCKING MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  4. Locking • Indivisible (atomic) operationsequences(often on shared data structures) are executedwithdisabledinterruptsandimplementedascriticalsectionssuchas: lock (X); < criticalsection >; unlock (X) whereXis a locksemaphoreassociatedto the criticalsection (if the criticalsectionacts on a single shared data structure D, the X isassociatedto D). • Lock, unlockoperations are analogousto P, V (Wait, Signal) primitives, however • theiratomicityisimplementedbymechanismsat the hardware-firmwarelevel, • theysynchronizeprocessors(notprocesses), thusimplybusywaitingin the lockoperation. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  5. Simplifiedlockingoperations The simplest (thoughinefficient) implementationoflockingoperationsis the following, whereXis a booleanlocksemaphore: lock (X):: indivisible_sequencewaituntil X; X = false unlock(X) :: X = true The locksequence (at the assembler or firmwarelevel) isof the kind: Lock: read X intoregister R; if(R = 0) then goto Lockelsewrite 1 into X Thisread-writesequencemustbeimplemented in anindivisible way, i.e. ifprocessorPiperformsthefirst (read)operationof the sequence, no otherPj(j ≠ i) can start the sequence (can read location X) untilPicompletes the sequence. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  6. Indivisiblesequencesofmemoryaccesses • The atomicimplementationoflockingmechanisms at the hardware-firmwarelevelconsists in the primitive implementationofindivisiblesequencesofmemoryread-writeoperations, e.g. (the sequences inside lockand unlock are examples) read (a) read (b) read (c) write (a, val) • Assume thata, b, c are locationsof the samememorymoduleM. If the sequenceisinitiatedbyprocessorPi, the moduleunit (or anarbiterofM, or an interface unit, or a switchingunitconnectedtoM) preventsanyotherPj(j ≠i) fromexecutingread-writeoperation on Muntil the sequenceiscompleted. • Note: itcouldbesufficientthatanyotherPjispreventedtoaccess the data structurecontaininga. However, becausewe are interested in short sequences, the “block ofmemorymodule” solutionissimpler and more efficient. • Note: ifa, b, c are not in the samemodule, itissufficientto block the moduleofa, providedthatthereis no possibilitytoaccessb, c independentlybeforeaccessinga. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  7. Indivisiblesequencesofmemoryaccesses • In the firmwareinterpreter, anindivisibility bit (indiv) isassociatedtoeverymemoryaccessrequest, todenote (indiv = 1) the beginningofanindivisiblesequence. Itismantained at indiv = 1 in all the successive requestsof the sequence, except the last request in whichindiv = 0. • Often, the assemblerlevelprovidesinstructionslikeTest and Set, Atomicexchange, AddtoMemory, etc. • More flexible and efficientmechanism: directlycontrol the indivisibility bit. Forexample, in D-RISC: • specialinstructions: SET_INDIV, RESET_INDIV • annotations (setindiv, resetindiv) in LOAD, STORE instructions. • Forvery short locksequences (1-2 memoryaccesses), lock/unlock can bereplaceddirectlybyset_indiv /reset_indiv . Lock/unlockare usedforlongersequences. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  8. Architecturalimplications Two extreme situations, according to which all the architectures with the known interconnection structures can be studied. M 1) M (or an interface/arbiterunit in frontof M) has a non-deterministicbehaviourwhen no indivisiblesequenceis in progress. If a requestfromPiwithindiv = 1 isselected, then M enters a deterministicbehaviour, duringwhich M “listens” only the Pirequests, i.e. M doesn’t test RDYsof the otherinterfaces. Whenindiv = 0, M resumes the non-deterministicbehaviour. P0 P1 P2 P3 2) M (or an interface/arbiterunit in frontof M) listens the only input link. A Requestcontains the nameof the requestingprocessor. If a requestfromPiwithindiv = 1 isselected, then M remember the nameofPi, and continuestolistenanyrequest. RequestsfromPi are served, requestsfrom the othersprocessors are bufferedintoaninternal FIFO queue. Whenindiv = 0, M serves the queuedrequests and/or new input requests. M P0 P1 P2 P3 MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  9. Exercize According to the two extreme situations above, solve the problem of management of memory accesses indivisible sequences, for the following architectures: • SMP whose interconnection network is composed of m trees, one for each shared memory module (root in the memory module) • SMP with k-ary n-fly network • NUMA with Fat Tree network • NUMA with k-ary n-cube network MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  10. Lockingwithperiodicretry • In orderto reduce the continuosaccessestosharedmemoryof the simplifiedalgorithm, the lock test isre-executedafter a giventimeinterval. The algorithmis “unfair” (potential infinite waiting). Writing: set indiv; S (x); reset indivmeans: sequence S, on shared data x, is executed with indiv = 1 for all the memory accesses to x except the last one. lock (semlock):: ok = false; while not ok doset indiv; if semlock thensemlock = false; reset indiv; ok = true  else reset indiv; wait for a given time-out   unlock (semlock):: semlock = true MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  11. Fair lockingwithqueueing • Locksemaphoreis a data structurecontaining the value (boolean) and a FIFO queueofprocessornames. • In case ofredsemaphore in lockoperation, processorwaitsanexplicit “unblockingcommunication” byanyprocessorexecuting the unlockoperation. • Thiscommunicationis a directcommunicationone, on the processor-to-processor network ifdistinctfrom the processor-to-memory network. Ifthey coincide (e.g. GeneralizedFatTree), distinctmessagetypes are usedfordifferentusages. • An I/O unit, calledCommunicationUnit (UC) isprovidedforthispurpose. • In the waitingnode, the unblockingcommunicationistransformedintoaninterruptfrom UC to the processor. In fact, the processorwaswaitingforan interrupt (seespecialinstruction in D-RISC). MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  12. Directinter-processorcommunications Interconnection Structure Wn-1 W0 … CPUn-1 CPU0 UCn-1 UC0 MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  13. Fair lockingwithqueueing Initialization:: semlock.val = true; semlock.queue = empty. lock (semlock):: set indiv; if semlock.val thensemlock.val = false; reset indiv else put (processor_name, semlock.queue) ; reset indiv; waitforanunblocking interrupt from UC unlock (semlock):: set indiv; if empty (semlock.queue) thensemlock.val = true; reset indiv elseprocessor_name = get (semlock.queue); reset indiv; sendto UC anublockingmessage tobe sent toprocessor_name MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  14. Locking and caching • Because of cache coherence reasons, the lock/unlock algorithms could also contain actions for the correcty management of memory hierarchy. • See the Cache Coherence section. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  15. Exercize Implement in detail (in D-RISC) the lock operation according to the fair algorithm. Evaluate its latency in case of green semaphore. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  16. Technologicalremark • In principle, locking operations are very efficient. • They can be executed in few clock cycles (except remote accesses) if proper assembler instructions exist, and are executed in user mode. • Again: inefficiencies are introduced when locking is a OS mechanism executed in kernel mode. • Alternative: lock-free algorithms for synchronizations (e.g., ad-hoc solutions for the various concurrency problems), which, on the other hand, can be expensive from the computational viewpoint. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  17. Run-timesupportofsend primitive • Let’s modify the uniprocessorversionofsendrun-timesupport, includinglocking. • ChannelDescriptoris a linearsequenceofwordscontaining a locksemaphore: • X: locksemaphore; • WAIT: boolean; • Message_length: integer; • Buffer: FIFO queueof (k + 1) positions (referenceto target variable, validity bit) • PCB_ref: referenceto PCB • The Channeldescriptoraddressis the logicaladdressof X. • Note: the algorithmis the sameforeverymultiprocessorarchitecture, exceptfor the low-levelscheduling procedure. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  18. Run-timesupportofsend primitive send (ch_id, msg_address) :: CH address =TAB_CH (ch_id); lock (X); if (CH_Buffer [Insertion_Pointer].validity_bit = 0) then wait = true; copy reference to Sender_PCB into CH.PCB_ref ; unlock (X); process transition into WAIT state: contextswitching; copy messagevalueinto the target variablereferredby CH_Buffer [Insertion_Pointer].reference_to_target_variable ; modifyCH_Buffer. Insertion_Pointer and CH_Buffer_Current_Size; if wait then wait = false; wake_uppartner process (CH.PCB_ref) ; if buffer_fullthen wait = true; copy reference to Sender_PCB into CH.PCB_ref ; unlock (X); process transition into WAIT state: contextswitching elseunlock (X) MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  19. Exercize Find an alternative implementation of send primitive, able to reduce the locking critical section duration. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  20. 2. LOW-LEVEL SCHEDULING MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  21. Processwake-up procedure • This procedure is different for anonymous processors and dedicated processors architectures. • This is another opportunity for direct interprocessor communications: Interconnection Structure Wn-1 W0 … CPUn-1 CPU0 UCn-1 UC0 MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  22. Preemptivewake-up in anonymousprocessorsarchitectures • An anonymous processors architecture • is a direct extension of a uniprocessor • aims to load balance processors. • These features require a distributed strategy for preemptive wake-up scheduling (processes with priority). • Assume that process B is WAITing and process A, running on Pi, wakes-up B. • If  Pjexecuting process C : priority (B) > priority (C) then B preempts C, i.e. B passes in Execution on Pj and C becomes Ready. • Otherwise, A put PCBBinto the Ready List. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  23. Preemptivewake-up in anonymousprocessorsarchitectures • A is in charge of consulting a Cental Table, where the correspondence (processor-process in execution-priority) is mantained. • A selects the minimum priority entry (Pj, C, priority) of Central Table. • If preemption can be applied, if C  A, then A performs preemtion on Pidirectly. • Otherwise, A sends to Pjan interprocessor message (preemption, reference to B, priority of B). • It is possible that, in the meantime, Pjhas performed a context-switch , or C has changed priority. The UC associated to Pjcan detect this situation and, usind DMA, can try to perform a preemtion onto a different processor, i.e., try to “bounce” the preemption message to another processor, without interrrupting Pj. • This potentially infinite procedure can be stopped after a (very) limited number of “bounces”. • Notice that, in order to avoid this problem (not so serious, nor leading to inconsistent state), a complex locking procedure should be implemented: • which data structures should have been locked, and when unlocked ? MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  24. Exercize Preemptivewake-up in SMP. Answer the previousquestion: … Noticethat, in ordertoavoidthisproblem (…), a complexlocking procedure shouldbeimplemented: • which data structuresshouldhavebeenlocked, and whenunlocked ? i.e., implement the preemptivewake-up procedure in such a way that the situation detectedby A doesn’t changeuntil the wake-uphasbeencompleted (withpreemption or not, on A’s node or not). MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  25. Shared I/O • In a UMA anonymous processors architecture, in principle I/O units are anonymous themselves, i.e. an I/O unit is not statically associated to a specific processor. • An interrupts can be sent to, and served by, any processor. • The most interruptable processor can be chosen, according to the same technique for preemptive wake-up. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  26. Processwake-up in dedicatedprocessorsarchitectures • In a dedicated processors architecture, every node has full responsibility of the low-level scheduling of its processes. • Assume process A, running on Pi, wishes to wake-up process B, running on Pj. • A replicated table contains the mapping correspondence (process, processor). • If i = j, then A wakes-up B using the Ready List of Pi. • Otherwise, A sends to Pjan interprocessor message (wake-up, reference to B). On Pj, the running process executes the wake-up procedure according to the local rules (with/without preemtion). MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  27. Exercize Describe in detail the implementation of process wake-up procedure for SMP and NUMA machines, including the UC behaviour and the interrupt handling actions. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  28. 3. COMMUNICATION PROCESSOR MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  29. Principle • Every processing node contains a second CPU (KP)dedicated to the implementation of the run-time support of interprocessor communication. • The main CPU (IP) delegates to KP the execution of (the most expensive part of) the send primitive. • If communication is asynchronous, andIP has work to do after a send, then communication is overlapped (at least in part). • KP executes just one process permanently (a “demon”), i.e. the process consisting in the send interpreter. • KP may be either a specialized co-processor, or identical to IP. • receive primitive is executed by IP. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  30. Examples while … do y = F(x, y); send (ch, y) Calculation is correctly overlapped to communication if the message value is not modified by calculation during the send execution. • while … do y2 = F(x, y1); send (ch, y2); y1 = F(x, y2); send (ch, y1)  • A partial loop-unfolding solves the problem easily (“double buffering”) • while … doreceive (ch1, x); y = F(x, y); send (ch2, y) • receive is executed by IP, thus it is overlapped to send (and, with zero-copy communication, receive latency is relatively low); • apply loop-unfolding if necessary. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  31. Processing nodestructure IP, KP share local memories inside the node; processing node is a small NUMA. Interconnection Structure MI MK IP KP uc uc KP has access to the whole shared memory of the system. Delegation of send execution from IP to KP: IP transmits to KP a reference (e.g. capability) to the send parameters (ch_id, message value), via direct interprocessor communication (uc – uc). The send execution by KP exploits KP resources, in particular KP cache. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  32. Exercizes • Describe the detailed scheme of a processing node with communication processor, for an SMP and for a NUMA architecture, using the D-RISC Pipelined CPU as off-the-shelf building block. • Assuming KP identical to IP, a multiprocessor with N processing nodes has a total of 2N CPUs. Thus the problem arises: why not exploiting 2N processing nodes without communication processors? Discuss this problem, individuating pros and cons of the communication processor solution. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  33. sendimplementationwith KP • sendsemantics: • copy the message and, if the asynchronydegreebecomessaturated (buffer_full), suspend the Senderprocess. • Ofcourse, thisconditionmustbyverified in presenceofKP too. • IfIP delegatestoKP the sendexecutionentirely, then some complications are introduced in the sendimplementationbecauseof the management of the WAIT state (versionsofthiskindexist). • more thanonecommunicationshouldbedelegatedtoKP: calculation …; send …; send …; send …; MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  34. sendimplementationwith KP • Simple and efficientsolution, thoughat the expenseof a (small) reductionofoverlapping: • IP verifies the saturationofchannelasynchronydegree(i.e. IPperforms the buffer_full test); • IPdelegatestoKP the sendcontinuation; • if (buffer_size = k) IPsuspends the Senderprocess (k = asynchronydegree, k + 1 = numberofqueueelements); • otherwiseIP delegatestoKP the sendcontinuation, and Sendergoes on. • KPdoesn’t perform the buffer_full test. • ChannelDescriptorislockedbyIP and unlockedbyKP. • Zero-copycommunication: IPcontrols the validity bit too. • Optimization: mantain a consistent copy ofBuffer_Sizeand validity bit in localmemoryofIP (avoid the remote channelaccess). MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  35. sendimplementationwith KP • Latency of the buffer_full and validity bit verification in IP has to be added to Tcalc(not Tsetup). • In some advanced architectures, KPs are built into to the interconnection structure, and are connected to the nodes via interface units (W). MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  36. 4. CACHE COHERENCE MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  37. Cache coherenceproblem • If the a shared data (block) isloadedinto more thanone cache, all the copiesmustbeidentical (consistent) eachother and identicalto the value in sharedMainMemory (or in furthersharedlevelsof the memoryhierarchy). • Abstractscheme, forourpurpose : sharedmemory M and (processor P, primary data cache C) nodes S (block) is loaded into Ci and Cj. No consistency problem if S is used in a read-only mode by Pi and Pj. If Pimodifies its S copy, then the copy in Cj is inconsistent (in general). S M Pi Pj Ci Cj S S . . . . . . . . . MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  38. Cache coherenceproblem Pi be the first processor that modifies S in its cache Ci. S • Write-Backcache: S copy in M (main copy) is inconsistent • Other processors find a inconsistent value of S in M, when they transfer S in their cache • Pj can not rely on the copy of S when it need to read it again • The only way to acquire a consistent value of S is with the help of Pi S S M • Write-Through cache: S copy in M is consistent • When ? Updating actions of S in Ci and in M are not simultaneous (if they were simultaneous: what about the Write Through performance ?) • There is a time interval during which S in M is inconsistent. • Other processors (and Pj itself) could find a consistent value of S in M, when they need to transfer S in their cache, provided that they are informed in time by Pi. • Again: in some way, they need the help of Pi. Pi Pj Ci Cj . . . . . . . . . MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  39. Automatic cache coherence • Cache coherencesolution at the firmwarelevel: itisguaranteedthat a processoralways work on a consistent copy, in a seemless way. • Twomaintechniques: • Invalidation: onlyonecached copy isvalid, i.e. the last modified, all the othercopies are/becomeinvalid • Update: all the cachedcopies are mantainedconsistent (broadcastedvalue) • In bothcases, an accurate (often, heavy) synchronizationmechanismhastobeadopted, e.g. • Invalidation: how can a Pjunderstandthatits copy hasbeeninvalidated or notyetinvalidated? • Update: how can a Pjunderstandthatits copy hasbeenupdated or notyetupdated? MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  40. Synchronization in automatic cache coherence • Analogy: Pipelined CPU: GeneralRegisterscopies in IU and EU • Update-likesolution: EU sends the updatedvalueto IU • Synchronizationthrough a semaphoricsolution in IU • Eachreadingoperationof a register in IU can beexecutedif and onlyif the associatedsemaphoreis green, otherwise IU mustwait. • Efficientsolution in Pipelined CPU: • synchronizationper sehas zero cost, alsobecausethereisonlyonesecondary copy, • but, whatabout the costof the synchronizationmechanism in a cache coherentmultiprocessor? • Invalidation-likesolution in the IU-EU analogy: notmeaningful, since IU doesn’t modifyregisters. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  41. Invalidation • When a processor Pimodifies a block S in Ci, all the othercopiesof S (ifany) are invalidated • An invalidated copy isde-allocated • Invalidationiscommunicatedby Pi, with a broadcast messagetoallprocessors, or a multicastmessagetothoseprocessorshaving S in their cache • Write-Back or Write-Through: the valid, acquired copy can bereadfrom M • Potential “ping – pong” effect. • Synchronization: • foreach cache access, everyPjwaitsfor a possibleinvalidationcommunication (S) • Time-dependentsolution ? (e.g., synchronizedlogicalclocks) • Otherwise: complexity, and performance degradation, increasesrapidly • Centralizationpointat the firmwarearchitecturelevel: • Snoopy bus in many commercial SMP multiprocessorswithlow parallelism(4 processors) and bus interconnection structure. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  42. Snoopingarchitectures (SMP) • e.g. MESI protocol (see: [Drepper], section 3.3.4; other protocols and formal treatment in [Pong-Dubois]) M Snoopy bus: to communicate invalidation events Also: a centralization point for synchronization: bus arbiter Before accessing its cache, a processor has to listen the bus Analogous consideration for Update technique, in which the bus supports a synchronized multicast too. Pi Pj Ci Cj . . . . . . . . . MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  43. Snooping: optimizations E.g. MESIF protocol • For each block descriptor: bit_mask[N], where bit i-th corresponds to processor Pi • in shared memory • if, for block p, • bit_mask[j] = 0: processor Pjcan not have block p in cache Cj; • bit_mask[j] = 1: it is possible (but not sure) that processor Pjhas block p in cache Cj; • For each p, automatic coherence is applied to processors having bit_mask = 1. • This technique limits the number of invalidation messages. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  44. Directory-basedarchitectures • Forhigherparallelismsystems, SMP and NUMA: avoidingcentralizationpoints, likebuses • High-parallelism interconnection structures can beused • Synchronizationthroughsharedvariables (directories) in localmemories, containingall the information aboutcached and sharedobjects: • firmwaresupporttomantainconsistentthesevariablestoo: at a costmuchlowerthan the costof cache coherenceitselfforany information block (specializedfirmwarefordirectories). • The directory-basedsolution can beimplementedbyprogramtoo: see the algorithm-dependentcaching, i.e • exploit the knowledgeof the computationsemanticstoimplement cache coherencewithoutautomaticsupport • explicitutilizationoflockingsynchronizations. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  45. “False sharing” Distinctprocessorsmodifydifferentlocationsof the same cache block: No real sharing of information, thus no real problem of cache coherence. However, this situation is considered as true sharing if automatic coherence is applied (cache block is the elementary unit of consistency), thus the invalidation / update traffic is executed. S M modifies location 3 only of shared block S …….. …….. …….. …….. modifies location 2 only of shared block S …….. …….. …….. …….. Pi Pj Ci Cj . . . . . . . . . • “Padding” techniques (data alignment to block size) in order to put words modified by distinct processors in distinct blocks. • effective when recognizable (knowledge of program semantics) MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  46. Automaticsolutions: alternatives • Automaticsolutions - Pros: no visibility at the programlevel • Cons: inefficiency and high overhead, especially in high parallelismmultiprocessors, or low parallelismarchitectures (evenwithmeaningfuloverheadtoo) • The key pointfor alternative solutionsis: • Processorsadoptsynchronizationmechanisms at the hardware-firmwarelevel: locking, indivisible bit, architecturalsupports in interconnection networks • Can thesemechanisms help to solve the cache coherenceproblemwithoutadditionalautomaticmechanisms? • In whichcasesthese alternative solutions are applicable, providedthat the synchronizationmechanisms (locking) are efficient(user mode) ? MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  47. Cache coherence in presenceoflocking • Consider a system withautomatic cache coherence • Consider a process, running on Pi(cache Ci), and a process, running on Pj(cache Cj), sharing a structureSwithlocksemaphoreX. • Sisaccessed in lock state (mutualexclusionwithbusywaiting). X belongs to the first block of S, or is allocated in an separate block. X S Arbitration – interconnection with indivisibility bit management M Locking is supported, at the HW-FW level, by the indivisibility bit mechanism. This mechanism represent a logically centralized, very efficient synchronization point. This mechanism prevents that both processors are able to load the lock semaphore X in their respectives caches simultaneously. Pi Pj Ci Cj MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  48. Cache coherence and locking • Assume the worst case forourpurposes: Pi and PjtrytoaccessX simultaneously. • BothrequestforXreading are associatedindiv = 1. • Assume Piisableto copy X in Ci. Pj’s requestispending (queued) in the properunitfor the indivisibility bit management. • Piexecuteslock (X),modifyingX; at the end, executesreset_indiv. PjisnowabletoaccesssharedmemoryforcopyingX in Cj. • The X copy in Ciisinvalidated. Thishas no particulareffect: PihasalreadyutilizedX (hasexecutedlock (X)). • Pjexecuteslock (X) on itsX copy: Xisred, thusPjentersbusywaiting. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  49. Cache coherence and locking (cont.) • When Piexecutesunlock (X), itloadsX in Ci and invalidatesX copy in Cj. Thishas no particukareffect on Pj, whichwasnotusingX (busywaiting), providedthatlock (X) isimplementedefficiently (bettersolution: fair lockwithqueue). • The unlock (X) providestounblockPj, whichloadsX in Cjand invalidesX copy in Ci. Thishas no particulareffect on Pi, whichdoesn’t needXany more. • Conclusion: cache coherenceper se isnotcomputationallyinefficient, e.g. invalidationdoesn’t introduce “ping-pong” effects, owingto the lockingsynchronization and indivisibility bit mechanism. • Consequence:trytoavoid the inefficienciesofautomaticsolutions (mechanismoverhead, low parallelism), relyingentirelyto the lockingsynchronizationmechanisms. MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

  50. Algorithm-dependent cache coherence • Cache coherenceisimplementedbyprogram, relying on the lockingsynchronizationmechanisms and knowing the computationsemantics. • Thisrequiresto individuate a properalgorithm. • Explicit management ofmemoryhierarchyisrequired. Thisisrenderedefficientbysuitableassemblersupports, throughLOAD/STORE instructionannotations. • In D-RISC: • STORE …., block_rewrite: explicitre-writingof a block, independentlyofWrite-Back or Write-Through cache • STORE …, don’t_modify : evenforWrite-Through cache, a writingoperationisexecutedin cache only. • STORE …, single_word : evenforWrite-Back cache, modify a single word in sharedmemorydirectly, insteadofanentire block • LOAD/STORE …, deallocate : explicit cache deallocationof a block. • LOAD/STORE …, don’t_deallocate: sameannotationexploitedforreuse MCSN - M. Vanneschi: High Performance Computing Systems and Enabling Platforms

More Related