Skip to content

Commit

Permalink
update cuda tests
Browse files Browse the repository at this point in the history
  • Loading branch information
barnex committed Nov 27, 2013
1 parent 4c0bfc0 commit e0d7baa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
13 changes: 4 additions & 9 deletions cuda/buffer_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package cuda

import (
"github.com/mumax/3/data"
"testing"
)
import "testing"

func init() {
Init(0, "auto", false)
}

func TestBuffer(t *testing.T) {
C := 1e-9
m1 := data.NewMesh(2, 1024, 2048, C, C, C)
m2 := data.NewMesh(4, 1024, 2048, C, C, C)
m1 := [3]int{2, 1024, 2048}
m2 := [3]int{4, 1024, 2048}
a := Buffer(3, m1)
b := Buffer(3, m2)
c := Buffer(1, m1)
Expand All @@ -31,8 +27,7 @@ func TestBuffer(t *testing.T) {

func BenchmarkBuffer(b *testing.B) {
b.StopTimer()
C := 1e-9
m := data.NewMesh(2, 1024, 2048, C, C, C)
m := [3]int{2, 1024, 2048}
a := Buffer(3, m)
Recycle(a)
b.StartTimer()
Expand Down
4 changes: 2 additions & 2 deletions cuda/reduce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func initTest() {
}

func toGPU(list []float32) *data.Slice {
mesh := data.NewMesh(1, 1, len(list), 1, 1, 1)
mesh := [3]int{1, 1, len(list)}
h := data.SliceFromList([][]float32{list}, mesh)
d := NewSlice(1, mesh)
data.Copy(d, h)
Expand Down Expand Up @@ -59,7 +59,7 @@ func TestReduceDot(t *testing.T) {

// test for 3 comp
const N = 32
mesh := data.NewMesh(1, 1, N, 1, 1, 1)
mesh := [3]int{1, 1, N}
c := NewSlice(3, mesh)
d := NewSlice(3, mesh)
Memset(c, 1, 2, 3)
Expand Down
18 changes: 7 additions & 11 deletions cuda/slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ func init() {

func TestSlice(t *testing.T) {
N0, N1, N2 := 2, 4, 8
c := 1e-6
m := data.NewMesh(N0, N1, N2, c, c, c)
m := [3]int{N0, N1, N2}
N := N0 * N1 * N2

a := NewSlice(3, m)
Expand All @@ -39,15 +38,15 @@ func TestSlice(t *testing.T) {
if b.NComp() != 1 {
t.Error("b.NComp", b.NComp())
}
if *b.Mesh() != *a.Mesh() {
if b.Size() != a.Size() {
t.Fail()
}
}

func TestCpy(t *testing.T) {
N0, N1, N2 := 2, 4, 32
N := N0 * N1 * N2
mesh := data.NewMesh(N0, N1, N2, 1, 1, 1)
mesh := [3]int{N0, N1, N2}

h1 := make([]float32, N)
for i := range h1 {
Expand Down Expand Up @@ -75,8 +74,7 @@ func TestCpy(t *testing.T) {
func TestSliceFree(t *testing.T) {
LockThread()
N0, N1, N2 := 128, 1024, 1024
c := 1e-6
m := data.NewMesh(N0, N1, N2, c, c, c)
m := [3]int{N0, N1, N2}
N := 17
// not freeing would attempt to allocate 17GB.
for i := 0; i < N; i++ {
Expand All @@ -91,8 +89,7 @@ func TestSliceFree(t *testing.T) {
func TestSliceHost(t *testing.T) {
LockThread()
N0, N1, N2 := 1, 10, 10
c := 1e-6
m := data.NewMesh(N0, N1, N2, c, c, c)
m := [3]int{N0, N1, N2}
a := NewSlice(3, m)
defer a.Free()

Expand All @@ -111,8 +108,7 @@ func TestSliceHost(t *testing.T) {
func TestSliceSlice(t *testing.T) {
LockThread()
N0, N1, N2 := 1, 10, 10
c := 1e-6
m := data.NewMesh(N0, N1, N2, c, c, c)
m := [3]int{N0, N1, N2}
a := NewSlice(3, m)
b := a.Slice(20, 30).HostCopy()
if b.Len() != 30-20 {
Expand All @@ -121,7 +117,7 @@ func TestSliceSlice(t *testing.T) {
if b.NComp() != a.NComp() {
t.Fail()
}
if *a.Mesh() != *b.Mesh() {
if a.Size() != b.Size() {
t.Fail()
}
}

0 comments on commit e0d7baa

Please sign in to comment.