Transcript
Page 1: SOFA : Design for Parallel Computations

SOFA :Design for Parallel Computations

Jérémie Allard

Page 2: SOFA : Design for Parallel Computations

SOFA

• Goal: interactive deformable objects simulation platform

• Integrate as many simulation algorithms as possible– Rigid bodies, mass-springs, finite-element models,

fluids, articulated bodies, …– Implicit/explicit/static solvers, penality/constraint

collision response, stiff interactions, …

Page 3: SOFA : Design for Parallel Computations

SOFA: Basic Principles

• Each object has several aspects– Behavior Model– Collision Model– Visual Model

• Mappings are used to link them– BM VM/CM : propagate positions and velocities– CM BM : send back forces

BehaviorModel

VisualModel

CollisionModel

X,VX,V

F

Page 4: SOFA : Design for Parallel Computations

Behavior Model

• 2 possible designs– “black-box” single element

• No knowledge of the internal algorithm of each object• Exchange interaction forces at each time-step• Similar to FlowVR Interact

– “white-box” aggregation• MechanicalModel : Degree-of-freedoms (DOF)• Attached elements : Mass, ForceField, Constraint, Solver, …• Internal MechanicalMappings to map new representations to the

original DOFs– Attach a set of points on a rigid body as if it was a mass-spring object– Embed a surface inside a deformable FFD grid– Implement interactions between 2 types of objects by mapping them to

a common representation whenever possible

Page 5: SOFA : Design for Parallel Computations

Scene structure

• Scene-graph design• All data are in leaf elements (Objects)

– Internal elements (Nodes) contains only pointers to attached objects and child nodes

• Computations are implementedas traversals of the tree– Separate computations

from scheduling(order of traversal)

Page 6: SOFA : Design for Parallel Computations

Collisions and Interactions

• Generic collision pipeline– Compute set of contacts between collision models– Change the scene structure dynamically

• Add new forcefields or constraints between objects• Change integration groups (implicit stiff interaction forces,

global constraints solvers)

• Interactions create loops in the graph– InteractionForceFields point to the 2

MechanicalModels involved– Attached to the first common ancestor node

• Except if one of the model is immobile (such as static obstacles), in which case it is attached to the other model

MechanicalModel

MechanicalModel

InteractionForceField

Page 7: SOFA : Design for Parallel Computations

Example

• 4 objects falling on the floor– 1 Rigid– 1 Mass-spring– 1 FFD spring grid– 1 FEM

• Each have an mappedcollision surface

Legend

Page 8: SOFA : Design for Parallel Computations

Example (2)

• Contacts with the floor– New nodes containing

contact points– New InteractionForceFields

Page 9: SOFA : Design for Parallel Computations

Example (3)

• Contacts between objects– Hierarchy changed to group

connected objects under onesolver

Page 10: SOFA : Design for Parallel Computations

Computations

• Each computation is implemented as an Action executed from a given graph node– called recursively for each node

• processNodeTopDown called before recursion to child nodes

• processNodeBottomUp after

– At each node, it can:• Ask to be called recursively on each child

• Stop the recursion

• Execute other actions from that node

Page 11: SOFA : Design for Parallel Computations

Computations (2)

• Data dependencies rules:– processNodeTopDown: read access to all parent nodes,

read/write access to current and all child nodes– processNodeBottomUp: read access to all parent nodes,

read/write access to current and all child nodes and parent node

Page 12: SOFA : Design for Parallel Computations

Computing Animation

• Animate Action Algorithm:– Call updatePosition() for each BehaviorModel

– If there is a Solver :• Call solver->solve(dt) (which will execute mechanical actions)• Stop the recursion

– Else• Continue the recursion

• Mechanical Actions:– PropagatePositionAndVelocity: set new position and velocity and apply

mappings to propagate them downward

– ComputeForce: call all ForceFields to compute the current force and apply mappings to accumulate it upward

– AccFromF: use Mass to compute accelerations from force

– V = A + B . f : linear vector operation (i.e. x += v.dt)

Page 13: SOFA : Design for Parallel Computations

Computing Animation: Step 1

Animate

UpdatePosition

Page 14: SOFA : Design for Parallel Computations

Computing Animation: Step 2

Animate

solve

Animate

Animate

solve solve

Animate

Animate

Animate

Animate

Page 15: SOFA : Design for Parallel Computations

Computing Animation: Step 3

ComputeForce

computeForce

ComputeForce

ComputeForce

computeForce

computeForce

computeForce

computeForce

Page 16: SOFA : Design for Parallel Computations

Computing Animation: Step 4

ComputeForce

ComputeForceCompute

Force

computeForce

computeForce

computeForce

computeForce

computeForce

ComputeForce

Page 17: SOFA : Design for Parallel Computations

Computing Animation: Step 5

ComputeForce

ComputeForce

ComputeForce

computeForce

computeForce

Page 18: SOFA : Design for Parallel Computations

Computing Animation: Step 6

ComputeForce

ComputeForce

ComputeForce

ComputeForceCompute

ForceCompute

Force

Page 19: SOFA : Design for Parallel Computations

Computing Animation: Step 7

accumulateForce

accumulateForce

accumulateForce

accumulateForce

accumulateForce

accumulateForce

Page 20: SOFA : Design for Parallel Computations

Computing Animation: Step 8

accumulateForce

accumulateForce

accumulateForce

Page 21: SOFA : Design for Parallel Computations

Computing Animation: Step 9

accumulateForce

accumulateForce

Page 22: SOFA : Design for Parallel Computations

Computing Animation: Step 10

AccFromF

accFromF

AccFromF AccFromF

accFromF

AccFromF

AccFromF

AccFromF

accFromF

Page 23: SOFA : Design for Parallel Computations

Computing Animation: Step 11

VOp

VOp VOp

V += A.dtX += V.dt

VOp

VOp

V += A.dtX += V.dt

V += A.dtX += V.dt

V += A.dtX += V.dt

Page 24: SOFA : Design for Parallel Computations

Computing Animation: Step 12

PropagatePos&Vel

setXsetV

setXsetV

PropagatePos&Vel

PropagatePos&Vel

Page 25: SOFA : Design for Parallel Computations

Computing Animation: Step 13

propagateXpropagateV

setXsetV

PropagatePos&Vel

PropagatePos&Vel

setXsetV

PropagatePos&Vel

propagateXpropagateV

PropagatePos&Vel

Page 26: SOFA : Design for Parallel Computations

Computing Animation: Step 14

propagateXpropagateV

PropagatePos&Vel

propagateXpropagateV

propagateXpropagateV

PropagatePos&Vel

PropagatePos&Vel

Page 27: SOFA : Design for Parallel Computations

Computing Animation: Step 15

PropagatePos&Vel

propagateXpropagateV

propagateXpropagateV

propagateXpropagateV

propagateXpropagateV

propagateXpropagateV

propagateXpropagateV

PropagatePos&Vel

PropagatePos&Vel

PropagatePos&VelPropagate

Pos&VelPropagatePos&Vel

Page 28: SOFA : Design for Parallel Computations

Task dependency graph

• Determined by the scene tree• More advanced solvers requires more actions

varying number for iterative solvers (CG)

Page 29: SOFA : Design for Parallel Computations

Parallel Scheduler

• Coarse grained:– Schedule Animate actions (green tasks)

# thread ≤ # integration groups ≤ # objects

• Fine grained:– Schedule all tasks

Cost of parallelization increase with the size of the tree

• Adaptive:– Work stealing

Costly only when necessary (when one idle thread steals a task)

Page 30: SOFA : Design for Parallel Computations

Work Stealing Scheduler

• Requirements– Handle > 1000 tasks per iteration (with > 30 it/sec)– Support Linux and Windows

Linux-only is fine for initial tests

• Several possibilities– KAAPI ?– Cilk ?– Custom code ? (Luciano’s octree work)


Recommended