本文整理匯總了Golang中github.com/mumax/3/data.Slice.DevPtr方法的典型用法代碼示例。如果您正苦於以下問題:Golang Slice.DevPtr方法的具體用法?Golang Slice.DevPtr怎麽用?Golang Slice.DevPtr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mumax/3/data.Slice
的用法示例。
在下文中一共展示了Slice.DevPtr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ShiftX
// shift dst by shx cells (positive or negative) along X-axis.
// new edge value is clampL at left edge or clampR at right edge.
func ShiftX(dst, src *data.Slice, shiftX int, clampL, clampR float32) {
util.Argument(dst.NComp() == 1 && src.NComp() == 1)
util.Assert(dst.Len() == src.Len())
N := dst.Size()
cfg := make3DConf(N)
k_shiftx_async(dst.DevPtr(0), src.DevPtr(0), N[X], N[Y], N[Z], shiftX, clampL, clampR, cfg)
}
示例2: kernMulRSymm2Dxy_async
// kernel multiplication for 2D demag convolution on X and Y, exploiting full kernel symmetry.
func kernMulRSymm2Dxy_async(fftMx, fftMy, Kxx, Kyy, Kxy *data.Slice, Nx, Ny int) {
util.Argument(fftMy.NComp() == 1 && Kxx.NComp() == 1)
cfg := make3DConf([3]int{Nx, Ny, 1})
k_kernmulRSymm2Dxy_async(fftMx.DevPtr(0), fftMy.DevPtr(0),
Kxx.DevPtr(0), Kyy.DevPtr(0), Kxy.DevPtr(0),
Nx, Ny, cfg)
}
示例3: ZeroMask
// Sets vector dst to zero where mask != 0.
func ZeroMask(dst *data.Slice, mask LUTPtr, regions *Bytes) {
N := dst.Len()
cfg := make1DConf(N)
for c := 0; c < dst.NComp(); c++ {
k_zeromask_async(dst.DevPtr(c), unsafe.Pointer(mask), regions.Ptr, N, cfg)
}
}
示例4: SetTemperature
// Set Bth to thermal noise (Brown).
// see temperature.cu
func SetTemperature(Bth, noise *data.Slice, temp_red LUTPtr, k2mu0_VgammaDt float64, regions *Bytes) {
util.Argument(Bth.NComp() == 1 && noise.NComp() == 1)
N := Bth.Len()
cfg := make1DConf(N)
k_settemperature_async(Bth.DevPtr(0), noise.DevPtr(0), float32(k2mu0_VgammaDt), unsafe.Pointer(temp_red),
regions.Ptr, N, cfg)
}
示例5: RegionSelect
// 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)
}
}
示例6: copyUnPad
// 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)
}
示例7: Dot
// Dot product.
func Dot(a, b *data.Slice) float32 {
nComp := a.NComp()
util.Argument(nComp == b.NComp())
out := reduceBuf(0)
// not async over components
for c := 0; c < nComp; c++ {
k_reducedot_async(a.DevPtr(c), b.DevPtr(c), out, 0, a.Len(), reducecfg) // all components add to out
}
return copyback(out)
}
示例8: ExchangeDecode
// Finds the average exchange strength around each cell, for debugging.
func ExchangeDecode(dst *data.Slice, Aex_red SymmLUT, regions *Bytes, mesh *data.Mesh) {
c := mesh.CellSize()
wx := float32(2 * 1e-18 / (c[X] * c[X]))
wy := float32(2 * 1e-18 / (c[Y] * c[Y]))
wz := float32(2 * 1e-18 / (c[Z] * c[Z]))
N := mesh.Size()
pbc := mesh.PBC_code()
cfg := make3DConf(N)
k_exchangedecode_async(dst.DevPtr(0), unsafe.Pointer(Aex_red), regions.Ptr, wx, wy, wz, N[X], N[Y], N[Z], pbc, cfg)
}
示例9: SetTemperature
// Set Bth to thermal noise (Brown).
// see temperature.cu
func SetTemperature(Bth, noise *data.Slice, k2mu0_Mu0VgammaDt float64, Msat, Temp, Alpha MSlice) {
util.Argument(Bth.NComp() == 1 && noise.NComp() == 1)
N := Bth.Len()
cfg := make1DConf(N)
k_settemperature2_async(Bth.DevPtr(0), noise.DevPtr(0), float32(k2mu0_Mu0VgammaDt),
Msat.DevPtr(0), Msat.Mul(0),
Temp.DevPtr(0), Temp.Mul(0),
Alpha.DevPtr(0), Alpha.Mul(0),
N, cfg)
}
示例10: Memset
// Memset sets the Slice's components to the specified values.
// To be carefully used on unified slice (need sync)
func Memset(s *data.Slice, val ...float32) {
if Synchronous { // debug
Sync()
timer.Start("memset")
}
util.Argument(len(val) == s.NComp())
for c, v := range val {
cu.MemsetD32Async(cu.DevicePtr(uintptr(s.DevPtr(c))), math.Float32bits(v), int64(s.Len()), stream0)
}
if Synchronous { //debug
Sync()
timer.Stop("memset")
}
}
示例11: Crop
// Crop stores in dst a rectangle cropped from src at given offset position.
// dst size may be smaller than src.
func Crop(dst, src *data.Slice, offX, offY, offZ int) {
D := dst.Size()
S := src.Size()
util.Argument(dst.NComp() == src.NComp())
util.Argument(D[X]+offX <= S[X] && D[Y]+offY <= S[Y] && D[Z]+offZ <= S[Z])
cfg := make3DConf(D)
for c := 0; c < dst.NComp(); c++ {
k_crop_async(dst.DevPtr(c), D[X], D[Y], D[Z],
src.DevPtr(c), S[X], S[Y], S[Z],
offX, offY, offZ, cfg)
}
}
示例12: Resize
// Select and resize one layer for interactive output
func Resize(dst, src *data.Slice, layer int) {
dstsize := dst.Size()
srcsize := src.Size()
util.Assert(dstsize[Z] == 1)
util.Assert(dst.NComp() == 1 && src.NComp() == 1)
scalex := srcsize[X] / dstsize[X]
scaley := srcsize[Y] / dstsize[Y]
util.Assert(scalex > 0 && scaley > 0)
cfg := make3DConf(dstsize)
k_resize_async(dst.DevPtr(0), dstsize[X], dstsize[Y], dstsize[Z],
src.DevPtr(0), srcsize[X], srcsize[Y], srcsize[Z], layer, scalex, scaley, cfg)
}
示例13: SetMaxAngle
// SetMaxAngle sets dst to the maximum angle of each cells magnetization with all of its neighbors,
// provided the exchange stiffness with that neighbor is nonzero.
func SetMaxAngle(dst, m *data.Slice, Aex_red SymmLUT, regions *Bytes, mesh *data.Mesh) {
N := mesh.Size()
pbc := mesh.PBC_code()
cfg := make3DConf(N)
k_setmaxangle_async(dst.DevPtr(0),
m.DevPtr(X), m.DevPtr(Y), m.DevPtr(Z),
unsafe.Pointer(Aex_red), regions.Ptr,
N[X], N[Y], N[Z], pbc, cfg)
}
示例14: Recycle
// Returns a buffer obtained from GetBuffer to the pool.
func Recycle(s *data.Slice) {
if Synchronous {
Sync()
}
N := s.Len()
pool := buf_pool[N]
// put each component buffer back on the stack
for i := 0; i < s.NComp(); i++ {
ptr := s.DevPtr(i)
if _, ok := buf_check[ptr]; !ok {
log.Panic("recyle: was not obtained with getbuffer")
}
pool = append(pool, ptr)
}
s.Disable() // make it unusable, protect against accidental use after recycle
buf_pool[N] = pool
}
示例15: SetTopologicalCharge
// Set s to the toplogogical charge density s = m · (m/∂x ❌ ∂m/∂y)
// See topologicalcharge.cu
func SetTopologicalCharge(s *data.Slice, m *data.Slice, mesh *data.Mesh) {
cellsize := mesh.CellSize()
N := s.Size()
util.Argument(m.Size() == N)
cfg := make3DConf(N)
icxcy := float32(1.0 / (cellsize[X] * cellsize[Y]))
k_settopologicalcharge_async(s.DevPtr(X),
m.DevPtr(X), m.DevPtr(Y), m.DevPtr(Z),
icxcy, N[X], N[Y], N[Z], mesh.PBC_code(), cfg)
}