]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: avoid closure in parfor test
authorRuss Cox <rsc@golang.org>
Fri, 22 Feb 2013 17:11:12 +0000 (12:11 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 22 Feb 2013 17:11:12 +0000 (12:11 -0500)
R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/7395051

src/pkg/runtime/parfor_test.go

index b382b76a7b2b687e642310298dc94d46e87e696e..4c69a68ceeaa042fc842b1e6488aae94065cb9ab 100644 (file)
@@ -13,6 +13,8 @@ import (
        "unsafe"
 )
 
+var gdata []uint64
+
 // Simple serial sanity test for parallelfor.
 func TestParFor(t *testing.T) {
        const P = 1
@@ -22,7 +24,12 @@ func TestParFor(t *testing.T) {
                data[i] = i
        }
        desc := NewParFor(P)
+       // Avoid making func a closure: parfor cannot invoke them.
+       // Since it doesn't happen in the C code, it's not worth doing
+       // just for the test.
+       gdata = data
        ParForSetup(desc, P, N, nil, true, func(desc *ParFor, i uint32) {
+               data := gdata
                data[i] = data[i]*data[i] + 1
        })
        ParForDo(desc)
@@ -111,7 +118,9 @@ func TestParForParallel(t *testing.T) {
        P := GOMAXPROCS(-1)
        c := make(chan bool, P)
        desc := NewParFor(uint32(P))
+       gdata = data
        ParForSetup(desc, uint32(P), uint32(N), nil, false, func(desc *ParFor, i uint32) {
+               data := gdata
                data[i] = data[i]*data[i] + 1
        })
        for p := 1; p < P; p++ {