-
Notifications
You must be signed in to change notification settings - Fork 1
/
region.go
35 lines (29 loc) · 1009 Bytes
/
region.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
package cuda
import (
"unsafe"
"github.com/mumax/3/data"
"github.com/mumax/3/util"
)
// dst += LUT[region], for vectors. Used to add terms to excitation.
func RegionAddV(dst *data.Slice, lut LUTPtrs, regions *Bytes) {
util.Argument(dst.NComp() == 3)
N := dst.Len()
cfg := make1DConf(N)
k_regionaddv_async(dst.DevPtr(X), dst.DevPtr(Y), dst.DevPtr(Z),
lut[X], lut[Y], lut[Z], regions.Ptr, N, cfg)
}
// decode the regions+LUT pair into an uncompressed array
func RegionDecode(dst *data.Slice, lut LUTPtr, regions *Bytes) {
N := dst.Len()
cfg := make1DConf(N)
k_regiondecode_async(dst.DevPtr(0), unsafe.Pointer(lut), regions.Ptr, N, cfg)
}
// select the part of src within the specified region, set 0's everywhere else.
func RegionSelect(dst, src *data.Slice, regions *Bytes, region byte) {
util.Argument(dst.NComp() == src.NComp())
N := dst.Len()
cfg := make1DConf(N)
for c := 0; c < dst.NComp(); c++ {
k_regionselect_async(dst.DevPtr(c), src.DevPtr(c), regions.Ptr, region, N, cfg)
}
}