-
Notifications
You must be signed in to change notification settings - Fork 2
/
memtypes.go
89 lines (78 loc) · 1.5 KB
/
memtypes.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package opencl
/*
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
*/
import "C"
import (
"fmt"
)
type MemCacheType int
const (
CacheNone = MemCacheType(iota)
CacheReadOnly
CacheReadWrite
)
func memCacheType(t C.cl_device_mem_cache_type) (MemCacheType, error) {
switch t {
case C.CL_NONE:
return CacheNone, nil
case C.CL_READ_ONLY_CACHE:
return CacheReadOnly, nil
case C.CL_READ_WRITE_CACHE:
return CacheReadWrite, nil
default:
return CacheNone, fmt.Errorf("unknown mem cache type: %d", t)
}
}
func (t MemCacheType) Name() string {
switch t {
case CacheNone:
return "none"
case CacheReadOnly:
return "read only"
case CacheReadWrite:
return "read write"
default:
return "unknown"
}
}
func (t MemCacheType) String() string {
return fmt.Sprintf("MemCacheType{%s}", t.Name())
}
type LocalMemType int
const (
LocalMemNone = LocalMemType(iota)
LocalMemLocal
LocalMemGlobal
)
func localMemType(t C.cl_device_local_mem_type) (LocalMemType, error) {
switch t {
case C.CL_NONE:
return LocalMemNone, nil
case C.CL_LOCAL:
return LocalMemLocal, nil
case C.CL_GLOBAL:
return LocalMemGlobal, nil
default:
return LocalMemNone, fmt.Errorf("unknown local memory type: %d", t)
}
}
func (t LocalMemType) Name() string {
switch t {
case LocalMemNone:
return "none"
case LocalMemLocal:
return "local"
case LocalMemGlobal:
return "global"
default:
return "unknown"
}
}
func (t LocalMemType) String() string {
return fmt.Sprintf("LocalMemType{%s}", t.Name())
}