@@ -75,57 +75,57 @@ It supports array-references with up to 8 indexes, where the data for each conse
75
75
of `index_types` (storing the enum `IndexType`), `indices` (the `id` for each index symbol), and `offsets` (currently unused).
76
76
"""
77
77
struct ArrayRefStruct{array,ptr}
78
- index_types:: UInt64
79
- indices:: UInt64
80
- offsets:: UInt64
81
- strides:: UInt64
78
+ index_types:: UInt128
79
+ indices:: UInt128
80
+ offsets:: UInt128
81
+ strides:: UInt128
82
82
end
83
83
array_and_ptr (@nospecialize (ar:: ArrayRefStruct{a,p} )) where {a,p} = (a:: Symbol ,p:: Symbol )
84
84
# array(@nospecialize(ar::ArrayRefStruct{a,p})) where {a,p} = a::Symbol
85
85
# ptr(@nospecialize(ar::ArrayRefStruct{a,p})) where {a,p} = p::Symbol
86
86
87
87
function findindoradd! (v:: Vector{T} , s:: T ) where {T}
88
- ind = findfirst (== (s), v)
89
- ind === nothing || return ind
90
- push! (v, s)
91
- length (v)
88
+ ind = findfirst (== (s), v)
89
+ ind === nothing || return ind
90
+ push! (v, s)
91
+ length (v)
92
92
end
93
93
function ArrayRefStruct (ls:: LoopSet , mref:: ArrayReferenceMeta , arraysymbolinds:: Vector{Symbol} , ids:: Vector{Int} )
94
- index_types = zero (UInt64)
95
- indices = zero (UInt64)
96
- offsets = zero (UInt64)
97
- strides = zero (UInt64)
98
- @unpack loopedindex, ref = mref
99
- indv = ref. indices
100
- offv = ref. offsets
101
- strv = ref. strides
102
- # we can discard that the array was considered discontiguous, as it should be recovered from type information
103
- start = 1 + (first (indv) === DISCONTIGUOUS)
104
- for (n,ind) ∈ enumerate (@view (indv[start: end ]))
105
- index_types <<= 8
106
- indices <<= 8
107
- offsets <<= 8
108
- offsets |= (offv[n] % UInt8)
109
- strides <<= 8
110
- strides |= (strv[n] % UInt8)
111
- if loopedindex[n]
112
- index_types |= LoopIndex
113
- if strv[n] ≠ 0
114
- indices |= getloopid (ls, ind)
115
- end
116
- else
117
- parent = get (ls. opdict, ind, nothing )
118
- @assert ! (parent === nothing ) " Index $ind not found in array."
119
- # if parent === nothing
120
- # index_types |= SymbolicIndex
121
- # indices |= findindoradd!(arraysymbolinds, ind)
122
- # else
123
- index_types |= ComputedIndex
124
- indices |= ids[identifier (parent)]
125
- # end
126
- end
94
+ index_types = zero (UInt128)
95
+ indices = zero (UInt128)
96
+ offsets = zero (UInt128)
97
+ strides = zero (UInt128)
98
+ @unpack loopedindex, ref = mref
99
+ indv = ref. indices
100
+ offv = ref. offsets
101
+ strv = ref. strides
102
+ # we can discard that the array was considered discontiguous, as it should be recovered from type information
103
+ start = 1 + (first (indv) === DISCONTIGUOUS)
104
+ for (n,ind) ∈ enumerate (@view (indv[start: end ]))
105
+ index_types <<= 8
106
+ indices <<= 8
107
+ offsets <<= 8
108
+ offsets |= (offv[n] % UInt8)
109
+ strides <<= 8
110
+ strides |= (strv[n] % UInt8)
111
+ if loopedindex[n]
112
+ index_types |= LoopIndex
113
+ if strv[n] ≠ 0
114
+ indices |= getloopid (ls, ind)
115
+ end
116
+ else
117
+ parent = get (ls. opdict, ind, nothing )
118
+ @assert ! (parent === nothing ) " Index $ind not found in array."
119
+ # if parent === nothing
120
+ # index_types |= SymbolicIndex
121
+ # indices |= findindoradd!(arraysymbolinds, ind)
122
+ # else
123
+ index_types |= ComputedIndex
124
+ indices |= ids[identifier (parent)]
125
+ # end
127
126
end
128
- ArrayRefStruct {mref.ref.array,mref.ptr} ( index_types, indices, offsets, strides )
127
+ end
128
+ ArrayRefStruct {mref.ref.array,mref.ptr} ( index_types, indices, offsets, strides )
129
129
end
130
130
131
131
"""
@@ -135,62 +135,56 @@ A condensed representation of an [`Operation`](@ref).
135
135
"""
136
136
struct OperationStruct <: AbstractLoopOperation
137
137
# instruction::Instruction
138
- loopdeps:: UInt64
139
- reduceddeps:: UInt64
140
- childdeps:: UInt64
141
- parents:: UInt64
142
- node_type:: OperationType
143
- array:: UInt8
144
- symid:: UInt8
138
+ loopdeps:: UInt128
139
+ reduceddeps:: UInt128
140
+ childdeps:: UInt128
141
+ parents:: UInt128
142
+ node_type:: OperationType
143
+ array:: UInt8
144
+ symid:: UInt8
145
145
end
146
146
optype (os) = os. node_type
147
147
148
148
function findmatchingarray (ls:: LoopSet , mref:: ArrayReferenceMeta )
149
- id = 0x01
150
- for r ∈ ls. refs_aliasing_syms
151
- r == mref && return id
152
- id += 0x01
153
- end
154
- 0x00
149
+ id = 0x01
150
+ for r ∈ ls. refs_aliasing_syms
151
+ r == mref && return id
152
+ id += 0x01
153
+ end
154
+ 0x00
155
155
end
156
- # filled_4byte_chunks(u::UInt64) = 16 - (leading_zeros(u) >>> 2)
157
- filled_8byte_chunks (u:: UInt64 ) = 8 - (leading_zeros (u) >>> 3 )
158
-
159
- # num_loop_deps(os::OperationStruct) = filled_4byte_chunks(os.loopdeps)
160
- # num_reduced_deps(os::OperationStruct) = filled_4byte_chunks(os.reduceddeps)
161
- # num_child_deps(os::OperationStruct) = filled_4byte_chunks(os.childdeps)
162
- # num_parents(os::OperationStruct) = filled_4byte_chunks(os.parents)
156
+ filled_8byte_chunks (u:: T ) where {T<: Unsigned } = sizeof (T) - (leading_zeros (u) >>> 3 )
163
157
164
158
function shifted_loopset (ls:: LoopSet , loopsyms:: Vector{Symbol} )
165
- ld = zero (UInt64 ) # leading_zeros(ld) >> 2 yields the number of loopdeps
166
- for d ∈ loopsyms
167
- ld <<= 4
168
- ld |= getloopid (ls, d):: Int
169
- end
170
- ld
159
+ ld = zero (UInt128 ) # leading_zeros(ld) >> 2 yields the number of loopdeps
160
+ for d ∈ loopsyms
161
+ ld <<= 4
162
+ ld |= getloopid (ls, d):: Int
163
+ end
164
+ ld
171
165
end
172
166
loopdeps_uint (ls:: LoopSet , op:: Operation ) = shifted_loopset (ls, loopdependencies (op))
173
167
reduceddeps_uint (ls:: LoopSet , op:: Operation ) = shifted_loopset (ls, reduceddependencies (op))
174
168
childdeps_uint (ls:: LoopSet , op:: Operation ) = shifted_loopset (ls, reducedchildren (op))
175
169
function parents_uint (ls:: LoopSet , op:: Operation )
176
- p = zero (UInt64 )
177
- for parent ∈ parents (op)
178
- p <<= 8
179
- p |= identifier (parent)
180
- end
181
- p
170
+ p = zero (UInt128 )
171
+ for parent ∈ parents (op)
172
+ p <<= 8
173
+ p |= identifier (parent)
174
+ end
175
+ p
182
176
end
183
177
function recursively_set_parents_true! (x:: Vector{Bool} , op:: Operation )
184
- x[identifier (op)] && return nothing # don't redescend
185
- x[identifier (op)] = true
186
- for opp ∈ parents (op)
187
- recursively_set_parents_true! (x, opp)
188
- end
189
- return nothing
178
+ x[identifier (op)] && return nothing # don't redescend
179
+ x[identifier (op)] = true
180
+ for opp ∈ parents (op)
181
+ recursively_set_parents_true! (x, opp)
182
+ end
183
+ return nothing
190
184
end
191
185
function getroots (ls:: LoopSet ):: Vector{Bool}
192
- rooted = Vector {Bool} (undef, length (operations (ls)))
193
- getroots! (rooted, ls)
186
+ rooted = Vector {Bool} (undef, length (operations (ls)))
187
+ getroots! (rooted, ls)
194
188
end
195
189
function getroots! (rooted:: Vector{Bool} , ls:: LoopSet )
196
190
fill! (rooted, false )
0 commit comments