"unsafe"
)
+var gdata []uint64
+
// Simple serial sanity test for parallelfor.
func TestParFor(t *testing.T) {
const P = 1
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)
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++ {