runtime: add parallel for algorithm

This is factored out part of:
https://golang.org/cl/5279048/
(parallel GC)

R=bsiegert, mpimenov, rsc, minux.ma, r
CC=golang-dev
https://golang.org/cl/5986054
This commit is contained in:
Dmitriy Vyukov 2012-05-11 10:50:03 +04:00
parent aa45e52e74
commit 95643647ae
5 changed files with 388 additions and 0 deletions

View file

@ -36,3 +36,28 @@ func lfstackpop2(head *uint64) *LFNode
var LFStackPush = lfstackpush
var LFStackPop = lfstackpop2
type ParFor struct {
body *byte
done uint32
Nthr uint32
nthrmax uint32
thrseq uint32
Cnt uint32
Ctx *byte
wait bool
}
func parforalloc2(nthrmax uint32) *ParFor
func parforsetup2(desc *ParFor, nthr, n uint32, ctx *byte, wait bool, body func(*ParFor, uint32))
func parfordo(desc *ParFor)
func parforiters(desc *ParFor, tid uintptr) (uintptr, uintptr)
var NewParFor = parforalloc2
var ParForSetup = parforsetup2
var ParForDo = parfordo
func ParForIters(desc *ParFor, tid uint32) (uint32, uint32) {
begin, end := parforiters(desc, uintptr(tid))
return uint32(begin), uint32(end)
}