-
Notifications
You must be signed in to change notification settings - Fork 64
/
device_test.go
68 lines (56 loc) · 1.12 KB
/
device_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package cu
import (
"bytes"
"fmt"
"testing"
)
func TestDevice(t *testing.T) {
devices, err := NumDevices()
if err != nil {
t.Fatal(err)
}
if devices == 0 {
return
}
buf := new(bytes.Buffer)
for id := 0; id < devices; id++ {
d, err := GetDevice(id)
if err != nil {
t.Fatal(err)
}
name, err := d.Name()
if err != nil {
t.Fatal(err)
}
cr, err := d.Attribute(ClockRate)
if err != nil {
t.Fatal(err)
}
mem, err := d.TotalMem()
if err != nil {
t.Fatal(err)
}
maj, err := d.Attribute(ComputeCapabilityMajor)
if err != nil {
t.Fatal(err)
}
min, err := d.Attribute(ComputeCapabilityMinor)
if err != nil {
t.Fatal(err)
}
uuid, err := d.UUID()
if err != nil {
t.Fatal(err)
}
fmt.Fprintf(buf, "Device %d\n========\nName :\t%q\n", d, name)
fmt.Fprintf(buf, "Clock Rate:\t%v kHz\n", cr)
fmt.Fprintf(buf, "Memory :\t%v bytes\n", mem)
fmt.Fprintf(buf, "Compute :\t%d.%d\n", maj, min)
fmt.Fprintf(buf, "UUID :\t%v\n", uuid)
t.Log(buf.String())
buf.Reset()
}
}
func TestVersion(t *testing.T) {
t.Logf("CUDA Toolkit version: %v", Version())
}