User`s guide
vii
Reduction Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
Basic Rules for Reduction Variables . . . . . . . . . . . . . . . . . . 2-33
Further Considerations with Reduction Variables . . . . . . . . 2-34
Example: Using a Custom Reduction Function . . . . . . . . . . 2-37
Temporary Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39
Uninitialized Temporaries . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39
Temporary Variables Intended as Reduction Variables . . . . 2-40
Improving parfor Performance . . . . . . . . . . . . . . . . . . . . . . . 2-42
Where to Create Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42
Slicing Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-42
Optimizing on Local vs. Cluster Workers . . . . . . . . . . . . . . 2-42
Parallel Pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44
What Is a Parallel Pool? . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44
Automatically Start and Stop a Parallel Pool . . . . . . . . . . . 2-45
Alternative Ways to Start and Stop Pools . . . . . . . . . . . . . . 2-45
Pool Size and Cluster Selection . . . . . . . . . . . . . . . . . . . . . . 2-46
Convert Nested for-Loops to parfor . . . . . . . . . . . . . . . . . . . 2-48
Single Program Multiple Data (spmd)
3
Execute Simultaneously on Multiple Data Sets . . . . . . . . . . . 3-2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
When to Use spmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Define an spmd Statement . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Display Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Access Worker Variables with Composites . . . . . . . . . . . . . . . 3-6
Introduction to Composites . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Create Composites in spmd Statements . . . . . . . . . . . . . . . . 3-6
Variable Persistence and Sequences of spmd . . . . . . . . . . . . . 3-8
Create Composites Outside spmd Statements . . . . . . . . . . . . 3-9
Distribute Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Distributed Versus Codistributed Arrays . . . . . . . . . . . . . . 3-10
Create Distributed Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10