-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNewDepthGpuThread.asm
More file actions
239 lines (192 loc) · 5.95 KB
/
Copy pathNewDepthGpuThread.asm
File metadata and controls
239 lines (192 loc) · 5.95 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# My FIRST GPU assembly program
.include "vc4.qinc"
#
# The main code starts after the Definitions and Macros sections
#
############################################################
# Definitions
############################################################
.set in_addr, ra0
.set out_addr, rb0
.set remx, rb1
.set in_addr2, ra1
.set gpuindex, ra2
.set elem_offs, rb2
.set gpuindex8, ra3
.set add_input_stride, rb3
.set gpujumpindex, ra4
.set num_gpus, rb4
.set add_input_x, ra5
.set add_input_y, rb5
.set cury, ra6
.set add_input_height, rb6
.set add_output_stride, ra7
.set add_output_x, rb7
.set add_output_height, ra8
.set add_output_y, rb8
.set curx, ra9
.set remy, rb9
.set setup_indexed_final, ra10
############################################################
# Macros
############################################################
############################################################
# Main Code
############################################################
mov in_addr, unif # input base address
mov out_addr, unif # output base address
mov num_gpus, unif # number of additional gpus
mov gpuindex, unif # gpu index, but it's zero for the main loop
mov add_input_x, unif # input x start
mov add_input_y, unif # input y start
mov add_input_stride, unif # input x stride = m_w
mov add_input_height, unif # input height = m_h
mov add_output_stride, unif # output m_w
mov add_output_height, unif # output m_h
mov add_output_x, unif # output m_borderw
mov add_output_y, unif # being written (coordinate). Same as border
mov in_addr2, unif # input 2 base address
# jump calculation for slave semaphore wait
mov r1, 48 # r1 = 48
mov r0, gpuindex
sub r0, r0, 1 # r0 = index - 1
mul24 gpujumpindex, r0, r1 # gpuindexjump = 48*(index-1)
nop
shl elem_offs, elem_num, 2 # elem_offsa = {0,1,2,3,4,5,6,7} * 8
#######################################
# Setup outer loop y
#######################################
mov cury, 0
mov r1, 64
sub r0, add_output_height, add_output_y
sub r0, r0, add_output_y
sub remy, r0, r1
:anotherloopy
#######################################
# Setup inner loop x
#######################################
mov curx, 0
sub r0, add_output_stride, add_output_x
sub r0, r0, add_output_x
mov r1, 64
sub remx, r0, r1
:anotherloopx
###############################################################################
# Set up the loop required for going through the entire bitmap. This loop
# These are byte aligned.
#
# this calculates where to store the result for the various threads
#
# It stores the result in rb0 (aliased to setup_indexed). It
# uses an index number from 1 to 7, multiplies it by 8 and then
# combines it with the vpm setup to tell the reader where to
# actually store the value in vpm memory
#
mov r0, vpm_setup(8,1,h32(0,0))
shl r3, gpuindex, 3
mov gpuindex8, r3
or setup_indexed_final, r0, r3
mov r2, add_input_x # if we want to start at the border so there's an overlap, use 4 instead of 0
add r1, add_input_y, cury # add the current y
#sub r1, r1, 1
add r1, r1, gpuindex8 # if this is a thread, uncomment, add the index to the input read
mul24 r0, add_input_stride, r1 # r0 = src.m_w * (src.m_borderh + cury);
add r0, r0, curx # r0 += curx;
add r2, r2, r0 # r1 = r2 + r0
add r2, r2, elem_offs
add r3, r2, in_addr # tempbuf_addr initiaized to in_addr
# load the source
.rep i, 4
mov t1s, r3
add r3, r3, add_input_stride
mov t0s, r3
add r3, r3, add_input_stride
.endr
ldtmu1
ldtmu0; mov rb10, r4
ldtmu1; mov rb11, r4
ldtmu0; mov rb12, r4
ldtmu1; mov rb13, r4
ldtmu0; mov rb14, r4
ldtmu1; mov rb15, r4
ldtmu0; mov rb16, r4
mov rb17, r4
brr -, :sample_acq0, gpujumpindex # jump to sample_acq0[index-1]
nop
nop
nop
:sample_acq0
.rep i, 6
mov -, srel(i+1)
mov -, sacq(i+8)
brr -,:sacq_done0
nop
nop
nop
.endr
mov -, srel(7)
mov -, sacq(14)
:sacq_done0
# finally write all of the results!
add r3, r2, in_addr2 # tempbuf_addr initiaized to in_addr
# load the subtrahend
.rep i, 4
mov t1s, r3
add r3, r3, add_input_stride
mov t0s, r3
add r3, r3, add_input_stride
.endr
mov vw_setup, setup_indexed_final
ldtmu1
ldtmu0; v8subs vpm, rb10, r4
ldtmu1; v8subs vpm, rb11, r4
ldtmu0; v8subs vpm, rb12, r4
ldtmu1; v8subs vpm, rb13, r4
ldtmu0; v8subs vpm, rb14, r4
ldtmu1; v8subs vpm, rb15, r4
ldtmu0; v8subs vpm, rb16, r4
v8subs vpm, rb17, r4
# tell the master we're done
brr -, :sample_acq2, gpujumpindex # jump to sample_acq0[index-1]
nop
nop
nop
:sample_acq2
.rep i, 6
mov -, srel(i+1)
mov -, sacq(i+8)
brr -,:sacq_done2
nop
nop
nop
.endr
mov -, srel(7)
mov -, sacq(14)
:sacq_done2
#######################################
# Increment inner loop x
#######################################
mov r1, 64 # for overlaps, use 56 instead of 64
or.setf r0, remx, remx # r0 = remx; // (set the flag too!)
add curx, curx, r1 # curx += r1;
brr.anynz -, :anotherloopx #
sub.setf r0, r0, r1 # r0 -= r1;
add.ifn curx, curx, r0; mov remx, r0 # if (r0<1) curx+=r0; remx=r0;
mov.ifn remx, 0 # if (r0<1) remx=0;
# if (r0!=0) goto :anotherloopx;
#######################################
# Increment inner loop y
#######################################
mov r1, 64
or.setf r0, remy, remy # r0 = remy; // (set the flag too!)
add cury, cury, r1 # cury += r1;
brr.anynz -, :anotherloopy #
sub.setf r0, r0, r1 # r0 -= r1;
add.ifn cury, cury, r0; mov remy, r0 # if (r0<1) curx+=r0; remy=r0;
mov.ifn remy, 0 # if (r0<1) remy=0;
# if (r0!=0) goto :anotherloopy
# exit the thread
:end
thrend
nop
nop