/
conv_copypad.go
34 lines (26 loc) · 1.17 KB
/
conv_copypad.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
package cuda
import (
"unsafe"
"github.com/mumax/3/data"
"github.com/mumax/3/util"
)
// Copies src (larger) into dst (smaller).
// Used to extract demag field after convolution on padded m.
func copyUnPad(dst, src *data.Slice, dstsize, srcsize [3]int) {
util.Argument(dst.NComp() == 1 && src.NComp() == 1)
util.Argument(dst.Len() == prod(dstsize) && src.Len() == prod(srcsize))
cfg := make3DConf(dstsize)
k_copyunpad_async(dst.DevPtr(0), dstsize[X], dstsize[Y], dstsize[Z],
src.DevPtr(0), srcsize[X], srcsize[Y], srcsize[Z], cfg)
}
// Copies src into dst, which is larger, and multiplies by vol*Bsat.
// The remainder of dst is not filled with zeros.
// Used to zero-pad magnetization before convolution and in the meanwhile multiply m by its length.
func copyPadMul(dst, src, vol *data.Slice, dstsize, srcsize [3]int, Bsat LUTPtr, regions *Bytes) {
util.Argument(dst.NComp() == 1 && src.NComp() == 1)
util.Assert(dst.Len() == prod(dstsize) && src.Len() == prod(srcsize))
cfg := make3DConf(srcsize)
k_copypadmul_async(dst.DevPtr(0), dstsize[X], dstsize[Y], dstsize[Z],
src.DevPtr(0), vol.DevPtr(0), srcsize[X], srcsize[Y], srcsize[Z],
unsafe.Pointer(Bsat), regions.Ptr, cfg)
}