https://github.com/pouyakary/uniparallel
A set of tools for Go to teach Parallel Programming
https://github.com/pouyakary/uniparallel
barrier channels forall multi-pascal multi-threading parallel-programming spinlock university university-project
Last synced: about 1 month ago
JSON representation
A set of tools for Go to teach Parallel Programming
- Host: GitHub
- URL: https://github.com/pouyakary/uniparallel
- Owner: pouyakary
- Created: 2018-05-14T12:08:36.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-21T16:21:42.000Z (about 7 years ago)
- Last Synced: 2024-12-25T17:42:20.439Z (6 months ago)
- Topics: barrier, channels, forall, multi-pascal, multi-threading, parallel-programming, spinlock, university, university-project
- Language: Go
- Size: 674 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# University Parallel
UniParallel is a simple atomic go library that provides you with some goodies in order to develop parallel software.
## What you get?
### Forall (from Multi Pascal)
In Multi-Pascal there is this grammar `forall` that is a parallel for. UniParallel provides the same functionality by a function called `ForAll`.The function gets a range `start` to `end` for the iterating range, grouping of the threads a function (`func (index int) { ... }`) to be the body of the for.
```go
parallel.ForAll(start, end, grouping, func(index int) {
fmt.Println( index )
})
```### Spin Lock
UniParallel provides a Spin Lock implementation for Go. The lock implementation is fairly easy to use:```go
var lock parallel.SpinLock
counter := 0
parallel.ForAll(1, 10, 4, func(index int) {
lock.Lock()
counter++
lock.Unlock()
})
```A higher level abstract is to use `RunSafe`. It locks the runtime and then runs a given function and unlocks as soon as the function ends. It's a very bad way to use the spin lock, very high footprint and so bad for the performance, but it's a pretty abstract:
```go
parallel.RunSafe(func() {
someFunctionRunningInLockedRuntime()
})
```### Terminal & I/O
As UniParallel is intended for use in a university course it has some easy functionality to handle data and terminal I/O to make it easier to write educational software