summaryrefslogtreecommitdiff
path: root/notes
blob: 23b8396cab9e40ad2579caf692cc015663aefdb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
NOTES TO SELF

atomic struct mthread_status {
  unsigned int area_covered 
  bool undevidable
  bool searching
  bool division_syn
  bool division_ack
  bool division_syn_ack
}


Thread finishes its job.
1: set "searching" local atomic struct to true
2: for each thread:

  if done=true; exit

  if searing, division_syn, division_ack, undevidable: go to next
    if all seem to be searching, set global done=true

  if not: continue below

3: record area_covered in own array, if more threads proceed to next, else continue below

4: pick thread with largest area_covered:
5: if division_syn or division_ack or searching or undevidable, go to next

5: set division_syn to true, wait for division_ack
6: divide(): copy over half of x/y, copy divisions, check and set undevidable, start to do work

thread is working.
1: 
for y:
  update area_covered
  check division_syn
  if true: 2 inline here
  for x:
    do some math stuff here
searching = true, "if thread finishes its job" inline here.


2: 
set division_ack
wait for division_syn_ack
check and set undevidable
// there should be no conflict with updating variable y is dependent on,
// as it's always more then current, and test will be accurate next loop.


thread is starting.
1: 
for y:
  update area_covered
  check division_syn
  if true: 2 inline here
  for x:
    do some math stuff here
searching = true, "if thread finishes its job" inline here.


PREFORMANCE:
without tasks helping eachother (commit c30fc7596810f7033dfd9a7452c808153bd2e14a):

const uint32_t WIDTH = 1920;
const uint32_t HEIGHT = 1080;
const int JOBS = 6; //test uneven stuff
const std::complex<double> b_min (-0.7463-0.005, 0.1102-0.005);
const std::complex<double> b_max (-0.7463+0.005, 0.1102+0.005);
#define MAX_ITER 1000 
#define INF_CUTOFF 256
#define COLOR_RAMP 100

/usr/bin/time -f '%p' -p ./mandelbrot

real 36.41
user 105.00
sys 0.02

real 36.38
user 104.98
sys 0.02

real 36.32
user 105.00
sys 0.05

With tasks helping eachother: (commit 3663966b88681f44ec8939e39e33ef922227b7a7):

real 19.21
user 111.70
sys 0.03

real 19.29
user 111.61
sys 0.02

real 19.30
user 111.84
sys 0.02


//CONTENDOR_HI REPLACEMENT - 50000 iterations
//const complex<double> DEFAULT_B_MIN (-0.74364386269 - 0.00000003000, 0.13182590271 - 0.00000003000);
//const complex<double> DEFAULT_B_MAX (-0.74364386269 + 0.00000003000, 0.13182590271 + 0.00000003000);

//CONTENDOR_ZOOM- 50000 iterations
//const complex<double> DEFAULT_B_MIN (-0.74364386269 - 0.00000001000, 0.13182590271 - 0.00000001000);
//const complex<double> DEFAULT_B_MAX (-0.74364386269 + 0.00000001000, 0.13182590271 + 0.00000001000);