https://github.com/tkf/parallelincrements.jl
https://github.com/tkf/parallelincrements.jl
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tkf/parallelincrements.jl
- Owner: tkf
- License: mit
- Created: 2020-06-15T01:55:49.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-15T01:55:59.000Z (over 5 years ago)
- Last Synced: 2024-10-19T18:24:49.550Z (about 1 year ago)
- Language: Julia
- Size: 4.88 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ParallelIncrements
ParallelIncrements.jl contains some code for benchmarking and
demonstrating the overhead of atomic operation on arrays.
Usage:
```julia
using ParallelIncrements
suite = ParallelIncrements.benchsuite() # BenchmarkTools.BenchmarkGroup
result = run(suite; verbose = true)
```
prints something like
```
2-element BenchmarkTools.BenchmarkGroup:
tags: []
"n=1000" => 1-element BenchmarkTools.BenchmarkGroup:
tags: []
"m=1000000" => 2-element BenchmarkTools.BenchmarkGroup:
tags: []
"nonatomic" => Trial(570.088 μs)
"atomic" => Trial(5.701 ms)
"single" => 2-element BenchmarkTools.BenchmarkGroup:
tags: []
"nonatomic" => Trial(35.000 ns)
"atomic" => Trial(4.888 μs)
```
`atomic` uses atomic instructions; `nonatomic` uses standard
instructions.
`n=1000`/`m=1000000` benchmark increments random `m` indices in a
vector of length `n`. Atomic operation is 10x slower.
`single` benchmark increments a single location in an array 1000
times. The difference is much more drastic (~140x) presumably because
the compiler elides the loads and stores for the nonatomic case.