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
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 listen in 1. are prefixed by `vv` in order to avoid name collisions with LoopVectorization and VectorizedStatistics.
@@ -33,10 +33,10 @@ To define a multi-dimensional mapreduce, one specifies a index set of dimensions
33
33
34
34
### When to consider replacing any/all with vectorized versions
35
35
Assumptions: x is inherently unordered, such that the probablilty of a "success" is independent of the index (i.e. independent of a random permutation of the effective vector over which the reduction occurs).
36
-
This is a very reasonable assumption for certain types of data, e.g. Monte Carlo simulations. However, for cases in which there is some inherent order (e.g. a solution to an ODE, or even very simply, `map(exp, 0.0:0.1:10.0)`), then the analysis below does not hold. If inherent order exists, then the probability of success depends on said ordering -- the caller must then exercise judgment based on where the first success might land (if at all); as this is inevitably problem-specific, I am unable to offer general advice.
36
+
This is a very reasonable assumption for certain types of data, e.g. Monte Carlo simulations. However, for cases in which there is some inherent order (e.g. a solution to an ODE, or even very simply, `cos.(-2π:0.1:2π)`), then the analysis below does not hold. If inherent order exists, then the probability of success depends on said ordering -- the caller must then exercise judgment based on where the first success might land (if at all); as this is inevitably problem-specific, I am unable to offer general advice.
37
37
38
38
For inherently unordered data:
39
-
Define `p` as the probability of success, i.e. the probability of `true` w.r.t. `any` and the probability of `false` w.r.t. `all`.
39
+
Define `p` as the probability of "success", i.e. the probability of `true` w.r.t. `any` and the probability of `false` w.r.t. `all`.
40
40
The cumulative probability of evaluating all elements, `Pr(x ≤ 0)` is
41
41
```julia
42
42
binomial(n, 0) * p^0* (1- p)^(n -0) # (1 - p)^n
@@ -71,9 +71,70 @@ julia> p.(.01, 10 .^ (1:4))
71
71
```
72
72
However, due to the current implementation details of Base `any`/`all`, early breakout occurs only when the reduction is being carried out across the entire array (i.e. does not occur when reducing over a subset of dimensions). Thus, the current advice is to use `vany`/`vall` unless one is reducing over the entire array, and even then, one should consider the `p` and `n` for one's problem.
73
73
74
+
## Examples
75
+
### Simple examples
76
+
77
+
<details>
78
+
<summaryClick me! ></summary>
79
+
```julia
80
+
julia>@btimemapreduce(abs2, +, A1, dims=(1,2,4))
81
+
BenchmarkTools.Trial:10000 samples with 159 evaluations.
The motivation for this package arose from my own experiences, but my initial attempt (visible in the /attic) did not deliver all the performance possible -- this was ony 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 osme low-hanging fruit -- this package is the result.
132
+
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.
76
133
77
134
## Future work
78
135
1. post-reduction operators
79
-
2. reductions over index subsets within a dimension.
136
+
2. reductions over index subsets within a dimension.
137
+
138
+
## Elsewhere
139
+
*[LoopVectorization.jl](https://github.com/chriselrod/LoopVectorization.jl) back-end for this package.
140
+
*[Tullio.jl](https://github.com/mcabbott/Tullio.jl) express any of the reductions using index notation
0 commit comments