File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -80,8 +80,20 @@ Base.length(range::NDRange) = length(blocks(range))
80
80
CartesianIndex (nI)
81
81
end
82
82
83
- Base. @propagate_inbounds function expand (ndrange:: NDRange , groupidx:: Integer , idx:: Integer )
84
- expand (ndrange, blocks (ndrange)[groupidx], workitems (ndrange)[idx])
83
+ Base. @propagate_inbounds function expand (ndrange:: NDRange{N} , groupidx:: Integer , idx:: Integer ) where {N}
84
+ # This causes two sdiv operations, one for each Linear to CartesianIndex
85
+ # expand(ndrange, blocks(ndrange)[groupidx], workitems(ndrange)[idx])
86
+
87
+ # The formulation below saves one sdiv
88
+ B = blocks (ndrange)
89
+ W = workitems (ndrange)
90
+ Ind = ntuple (Val (N)) do I
91
+ Base. @_inline_meta
92
+ b = B. indices[I]
93
+ w = W. indices[I]
94
+ length (b) * length (w)
95
+ end
96
+ CartesianIndices (Ind)[(groupidx- 1 )* prod (size (B)) + idx]
85
97
end
86
98
87
99
Base. @propagate_inbounds function expand (ndrange:: NDRange{N} , groupidx:: CartesianIndex{N} , idx:: Integer ) where {N}
You can’t perform that action at this time.
0 commit comments