Praktikum Wissenschaftliches Rechnen …...Praktikum Wissenschaftliches Rechnen...

27
Praktikum Praktikum Wissenschaftliches Wissenschaftliches Rechnen Rechnen (Performance (Performance - - optimized Programming) optimized Programming) Dynamic Load Balancing Dr. Ralf-Peter Mundani Center for Simulation Technology in Engineering Technische Universität München

Transcript of Praktikum Wissenschaftliches Rechnen …...Praktikum Wissenschaftliches Rechnen...

PraktikumPraktikum WissenschaftlichesWissenschaftliches RechnenRechnen(Performance(Performance--optimized Programming)optimized Programming)

Dynamic Load Balancing

Dr. Ralf-Peter MundaniCenter for Simulation Technology in Engineering

Technische Universität München

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 2

Dynamic Load BalancingDynamic Load BalancingOverviewOverview

definitionsexamples of load balancing strategiesswarm intelligence

Computers make it easier to do a lot of things,but most of the things they make it easier to do

don’t need to be done.—Andy Rooney

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 3

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

load distribution and load balancing are essential issues to exploit the full potential of parallel programssome foundations

motivationstatic load balancingdynamic load balancingcentralised dynamic load balancingdecentralised dynamic load balancingload modelsstrategy selection

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 4

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

motivationcentral issue: fairly distribution of computations across all processors / nodes in order to optimise

run time (user’s point of view)system load (computing centre’s point of view)

so far, division of a problem into a fixed number of processes to be executed in parallelproblem

amount of work is often not known prior to executionload situation changes permanently (adaptive mesh refinement within numerical simulations, I/O, searches, …)different processor speeds (heterogeneous systems, e. g.)different latencies for communication (grid computing, e. g.)

objective: load distribution or load balancing strategies

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 5

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

static load balancingto be applied before the execution of any process (in contrast to dynamic load balancing to be applied during the execution)usually referred to as mapping problem or scheduling problempotential static load-balancing techniques

round robin: assigning tasks (more general formulation than work to cover both data and function parallelism) in sequential order to processes coming back to the first when all processes have been given a taskrandomised: selecting processes at random to assign tasksrecursive bisection: recursive division of problems into smaller subproblems of equal computational effort with less communication costsgenetic algorithm: finding an optimal distribution of tasks according to a given objective function

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 6

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

static load balancing (cont’d)mapping should reflect communication pattern of processes in case of static network topologies when assigning tasks, i. e. short communication paths between processors / nodes to be preferred ( NP-complete problem)missing knowledge about execution times of various parts of a program might lead to very inaccurate mappingscommunication delays that vary under different circumstances aredifficult to incorporate (via variable communication delays) with static load balancingalgorithms might have an indeterminate number of steps to reach their solutions (traversing a graph in search algorithms, e. g.)hence, different approaches needed to overcome the mentioned problems

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 7

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

dynamic load balancingdivision of tasks dependent upon the execution of parts of the program as they are being executed entails additional overhead (to be kept as small as possible, else bureaucracy wins)assignment of tasks to processes can be classified as

centralisedtasks are handed out from a centralised locationwithin a master-slave structure one dedicated master process directly controls each of a set of slave processes

decentralisedtasks are passed between arbitrary processesworker processes operate upon the problem and interact among themselves a worker process may receive tasks from other or may send tasks to other worker processes

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 8

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

centralised dynamic load balancingexample: work pool

master process holds a collection of tasks to be performed by the slave processestasks are sent ( ) to slave processeswhen a task is completed, a slave process requests ( ) another task from the master processall slaves are the same (replicated worker), but specialised slaves capable of performing certain tasks are also possible

queue with tasksqueue with tasksmaster

slave

slave

work pool

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 9

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

centralised dynamic load balancing (cont’d)work pool techniques can also be readily applied when

tasks are quite different and of different size (in general, it is best to hand out larger tasks first to prevent idle waiting)amount of tasks may change during execution, i. e. execution of one task might generate new tasks (to be submitted to the master)

computation terminates if both of the following are satisfied1) task queue is empty2) every process made a request for another task without any

new tasks being generated (even if (1) is true a still runningprocess may provide new tasks for the task queue)

a slave may detect the program termination condition by some local termination condition (searches, e. g.), hence it has to send a termination message to the master for closing down all others

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 10

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

decentralised dynamic load balancingexample: distributed work pool

drawback of centralised model: master might become bottleneck in case of too many slaveshence, work pool is distributed among several masterseach master controls one group of slavesseveral layers of decomposition possible building up a tree hierarchy with tasks being passed downwards and requests / messages being passes upwards

M0

M1 MN…

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 11

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

decentralised dynamic load balancing (cont’d)example: fully distributed work pool

once tasks are (initially) distributed among processes (that moreover are able to generate new tasks), all processes can execute tasks from each othertasks could be transferred by a

receiver-initiated method: a process that has only few or no tasks to perform requests tasks from other processesit selects (works well at high system loads)sender-initiated method: a process with heavy load sends tasks to other processes it selects and that are willing to accept them (works well at light overall system loads)

in general, avoid passing on the same task that is receivedwhich one to prefer, what kind of flaws do they have?

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 12

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

load modelsdecisions of any strategy about passing / requesting tasks are based on the local loadproblem: measurement of the loadreliable load models are based upon load indices

simple and composite load indices (one or more quantities)might refer to different functional units (CPU, bus, memory, …)snapshot or integrated or averaged quantitiesstochastic quantities to reflect external influences

properties of a good load indexprecisely reflects the target quantity at presentallows for accurate predictions concerning the futuresmoothing behaviour to compensate peaksbased upon some simple formula, easy to compute

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 13

Dynamic Load BalancingDynamic Load BalancingDefinitionsDefinitions

strategy selectionnot all strategies are appropriate for any problemcrucial task: how to find the best strategy for a given problemmain aspects to be considered

objective: optimisation of load or run timelevel of integration: OS, runtime system (MPI, e. g.), applicationunits to distribute: process / thread, parts of program, data, …

further aspectsstatic / dynamic strategies, central / decentral strategiessource of initiative: idle slave, overloaded slave, master, …costs of the chosen strategy (computation should dominate load distribution and not vice versa)placement of new processes or real process migration…

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 14

Dynamic Load BalancingDynamic Load BalancingExamples of Load Balancing StrategiesExamples of Load Balancing Strategies

quite a huge amount of different strategies do exist that all vary according to the underlying way of distributing tasksselected examples

biddingbalanced allocationbroker systemrandom matchingprecalculation of the load

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 15

Dynamic Load BalancingDynamic Load BalancingExamples of Load Balancing StrategiesExamples of Load Balancing Strategies

bidding (economic model)analogy to mechanisms of price fixing in marketsidea

process (with high workload) advertises tasks to its neighboursneighbours submit their free resources as bidprocess with highest bid (i. e. largest free resources) wins

remarksmaybe several rounds of bidding necessary successively extending the range of biddersin case of sudden workload peaks, a process might reject the purchased tasksprocesses with free resources are still allowed to ask for tasks

drawback: quite complex analysis of this model

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 16

Dynamic Load BalancingDynamic Load BalancingExamples of Load Balancing StrategiesExamples of Load Balancing Strategies

balanced allocation (balls into bins)basic idea: placing N balls into N bins at random choice (extensively studied problem from probability and statistics)variant of the above

each ball comes with D possible destinations (to be placed), chosen independently and uniformly at randomthen the ball is placed in the least full bin among the D possible destinations

applied to load balancing: a process selects D processes at random and passes some of its workload to the least loaded onefor temporary tasks (i. e. tasks that are finished at unpredictable times) this strategy has a competitive ratio of Ο( ) compared to the optimal off-line strategy (that has global knowledge)

N

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 17

Dynamic Load BalancingDynamic Load BalancingExamples of Load Balancing StrategiesExamples of Load Balancing Strategies

broker systemorigin of the idea: brokers at the stock exchangedesigned and especially well-suited for hierarchical topologiesidea

each processor has one broker with local knowledge (about workload in subtree, e. g.)tasks arrive at the local broker (via an application server) andare dependent from the available budget processed locally or passed to the parent nodeon some level (at least at the root node), some price-based decision and allocation is doneprices have to be paid for using remote resources as well as for the broking itself local computations are cheaper

flexible strategy for hierarchical and heterogeneous topologies

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 18

Dynamic Load BalancingDynamic Load BalancingExamples of Load Balancing StrategiesExamples of Load Balancing Strategies

random matchingorigin of the idea: graph theoryprinciple

construct a matching in the topology graph G = (V, E) of the network (set of vertices V are the processors, set of edges E are the direct connections between processors)matching: injective function f: x → y for all x, y ∈ Vperfect load balancing along all edges of the matching

this is an iterative strategy, hence several steps are necessarymatching must be found in parallel

start with an empty set of edges in each vertexlocal selection (by chance) of one incident edge in each vertexcoordination with neighbouring vertices, solution of conflicts

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 19

Dynamic Load BalancingDynamic Load BalancingExamples of Load Balancing StrategiesExamples of Load Balancing Strategies

precalculation of the loadall strategies so far are based on local information onlyhence, load balancing is often quite expensive since (from a global point of view) balancing steps not always lead to a better load distribution among the processorsidea

global determination of the workload at program start or at certain points in timeglobal determination of an appropriate load distributionworkload transfer with less communication

developed and used for hierarchical network topologies workload recording and load balancing between child and parent nodes

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 20

Dynamic Load BalancingDynamic Load BalancingSwarm IntelligenceSwarm Intelligence

meanwhile, there exists a quite widespread usage of swarm intelligence throughout different fields within computer science(TSP, shortest path problems, traffic simulations, …)an unconventional load balancing strategy with origins in ant colonies in nature

basicscomplex adaptive systemsanthill systemload balancing

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 21

Dynamic Load BalancingDynamic Load BalancingSwarm IntelligenceSwarm Intelligence

basicsorigin of the idea: ant colonies in natureants and termites (as well as some bees and wasps) belong to the class of so called social insectsmain characteristic of the above: building coloniesants communicate indirectly via scent, also knownas stigmergy (modification of local environment)therefore, ants use pheromones

to be left along their paths for others to followto label bulk material inside the nest

if an ant finds a path to some food it will mark it,hence other can follow until they find a better pathnevertheless, ants may by chance decide not tofollow chance of exploring alternatives

model of ant nest

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 22

Dynamic Load BalancingDynamic Load BalancingSwarm IntelligenceSwarm Intelligence

basics (cont’d)even a central decision maker is missing, ant colonies have a high grade of structure and organisation self-organisationself-organisation is based on the following properties

positive / negative feedback: one ant follows a path or it does not follow a path (due to dissolution of pheromones, e. g.)amplification of deviation: if one doesn’t follow and finds some closer food, successively all others will follow the new pathmutual communication: key for spreading information among ants and exploiting advantages induced by negative feedback

hence, ant colonies are often referred to as collective or swarmintelligence

they can adopt to their environment and related problemsthey can adopt their environment according to their demands

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 23

Dynamic Load BalancingDynamic Load BalancingSwarm IntelligenceSwarm Intelligence

complex adaptive systemsP2P systems have a decentralised control and exhibit extreme dynamism in structure and workloadproblem: classical approaches cannot deal with this dynamismhence, a paradigm shift to self-organisation, adaptation, and resilience as fundamental properties is necessarycomplex adaptive systems (CAS) used to explain the behaviour of certain biological and social systems might come up for this shift

they consist of a large number of relatively simple autonomous computing units, i. e. agentsthey exhibit so called emergent behaviour, i. e. interaction among agents can give rise to richer and more complex patterns than those generated by single agents (in isolation)

example of a CAS instance drawn from nature: ant colonies

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 24

Dynamic Load BalancingDynamic Load BalancingSwarm IntelligenceSwarm Intelligence

complex adaptive systems (cont’d)three simple rules for artificial ant colonies (RESNICK, 1994)

1) ant wanders around randomly, until it encounters an object2) if it was carrying an object, it drops the object and continues

to wander randomly3) if it was not carrying an object, it picks the object up and

continues to wanderindependent of the initial distribution of objects, a colony of those ants is able to group objects into large clustersalthough there are no rules specific to initial conditions, unforeseen scenarios, variations in the environment, or presence of failures global behaviour of large enough colonies is adaptive and resilienthence, CAS can achieve these properties without explicitly embedding them into the individual agents

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 25

Dynamic Load BalancingDynamic Load BalancingSwarm IntelligenceSwarm Intelligence

anthill systemproposed by MONTRESOR, MELING, and BABAOĞLU (2002)composed of a self-organising overlay network of interconnected nests, where each nest is capable of hosting resources and performing computationsevery node in the system is allowed to generate new tasks and tosubmit them to the network (tasks may remain in the originator or being transferred to other nests load balancing)ants (autonomous agents) are generated by nests and travel across the nest network to detect unused computational power

nest 1nest 3

nest 2

nest 4

nest 5

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 26

Dynamic Load BalancingDynamic Load BalancingSwarm IntelligenceSwarm Intelligence

load balancingvariation of RESNICK’s artificial ant algorithm

1) when an ant is not carrying any object, it wanders aboutrandomly until it encounters an object and picks it up

2) when an ant is carrying an object, the ant drops it only afterhaving wandered about randomly “for a while” withoutencountering other objects

colonies of such ants try to disperse objects (i. e. the actual tasks) uniformly over their environment rather than clustering themants may assume two different states

searchMAX: ant wanders about until it finds an “overloaded”nest; ant records nest’s identifier and switches to searchMINsearchMIN: ant wanders about looking for an “underloaded”nest; ant requests local task manager for task transfer from over- to underloaded nest and switches back to searchMAX

Dr. Ralf- Peter Mundani – Praktikum Wissenschaftliches Rechnen – Winter Term 2007/08 27

Dynamic Load BalancingDynamic Load BalancingSwarm IntelligenceSwarm Intelligence

load balancing (cont’d)ants do not transport tasks to avoid carrying potentially large amount of data from one node to another while wandering aboutconcept of overloaded and underloaded nests are relative to the average load of the nests recently visited by an ant enables ants to make decisions about task transfers between nests with unbalanced loads without the necessity of a global knowledgeeach nest stores collected information about an ant’s last visited nests to be used by subsequent ants to drive their searchMAX or searchMIN phase at each step, the ant randomly selects the next node to visit among those that are believed to be more overloaded or underloaded, resp.results: 100 idle nests and initially 10,000 tasks in one single node

only 15—20 iterations to transfer tasks to all other nodesafter 50 iterations, the workload is perfectly balanced