Optimizing Parallel Processes

Parallel Algorithms

David Mayerich

Scalable Tissue Imaging and Modeling (STIM) Laboratory

Department of Electrical and Computer Engineering

Cullen College of Engineering

University of Houston

David Mayerich

STIM Laboratory, University of Houston

Static Assignment

  • Allocate work before assigning it

  • Specify rules at compile-time

  • Assignment remains constant

  • Useful when:

    • Work is predictable

    • or statistically predicatable

David Mayerich

STIM Laboratory, University of Houston

t0

t1

t2

t3

\sum

t0

t1

t2

t3

t4

t8

t5

t9

t6

t10

t7

t11

t12

t13

t14

t15

Semi-Static Assignment

  • Determine the short-term cost of work

  • Assign workers based on that cost

  • Barnes-Hutt Algorithm

David Mayerich

STIM Laboratory, University of Houston

Dynamic Assignment

  • Prime test using trial division:

David Mayerich

STIM Laboratory, University of Houston

for(size_t i = 0; i < N; i++) {
  p[i] = test_prime(x[i]);
}

// test prime using trial division
bool test_prime(int y) {
  int m = sqrt(y);
  for(size_t j = 2; j < m; j++) {
    if(y % j == 0) return false;
  }
  return true;
}

30

31

\cdots

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

\cdots

9

11

13

10

12

test_prime 
duration

15

17

19

29

14

18

20

16

\cdots

queue

t0

t1

t2

t3

Assess Assignment Strategies

  • Profile the entire program

  • Calculate the overhead:

     

    • \(T_o\) is the overhead (time spent on non-useful work)

    • \(p\) is the number of processors

    • \(T_p\) is the parallel runtime

    • \(T_s\) is the serial runtime

  • Successful strategies

David Mayerich

STIM Laboratory, University of Houston

T_o = p T_p - T_s
p_0
p_1
p_2
p_3
p_4
p_5
s_1
s_0

sync()

sync()

sync()

p_0
p_1
p_2
s_0
p_3
p_4
p_5
s_1

serial

parallel

\(T_p\)

\(T_s\)