You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+64-3Lines changed: 64 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,15 @@ This library provides "vectorized" (with/without multithreading) versions of the
18
18
The naming convention is as follows: a vectorized (without threading) version is prefixed by `v`, and a vectorized with threading version is prefixed by `vt`.
19
19
There is a single exception to this rule: vectorized (without threading) versions of the functions listed in 1. are prefixed by `vv` in order to avoid name collisions with LoopVectorization and VectorizedStatistics.
20
20
21
+
This library also provides other, less common, reductions (all of which follow the naming convention above):
22
+
1.`mapreducethen` : Apply function `f` to each element of `A`, reduce the result over the dimensions `dims` using the binary function `op`, then apply `g` to the result
When writing numerical code, one may wish to perform a reduction, perhaps across multiple dimensions, as the most natural means of expressing the relevant mathematical operation.
@@ -238,13 +247,65 @@ BenchmarkTools.Trial: 10000 samples with 173 evaluations.
238
247
</details>
239
248
240
249
250
+
### `mapreducethen` examples
251
+
<details>
252
+
<summaryClick me! ></summary>
253
+
<p>
254
+
255
+
Examples of seemingly strange but useful concept: `mapreduce(f, op, ...)`, then apply `g` to each element of the result. However, the post-transform `g` can be fused such that the output array is populated in a single pass, hence, `mapreducethen(f, op, g, ...)`. It happens that many familiar quantities follow this pattern, as shown below.
The original motivation for this work was a vectorized & multithreaded multi-dimensional findmin, taking a variable number of array arguments -- it's a long story, but the similarity between findmin and mapreduce motivated a broad approach. My initial attempt (visible in the /attic) did not deliver all the performance possible -- this was only apparent through comparison to C. Elrod's approach to multidimensional forms in VectorizedStatistics. Having fully appreciated the beauty of branching through @generated functions, I decided to take a tour of some low-hanging fruit -- this package is the result.
243
304
244
305
## Future work
245
-
1. post-reduction operators
246
-
2. reductions over index subsets within a dimension.
247
-
3. actual documentation
306
+
1.✓ post-reduction operators
307
+
2.□ reductions over index subsets within a dimension.
308
+
3.□ actual documentation
248
309
249
310
## Elsewhere
250
311
*[LoopVectorization.jl](https://github.com/chriselrod/LoopVectorization.jl) back-end for this package.
0 commit comments