Exemplo n.º 1
0
// Set a single value
func (b *Array) Set(comp, x, y, z int, value float64) {
	b.checkBounds(comp, x, y, z)
	acomp := b.Comp[comp]
	index := acomp.indexOf(x, y, z)
	cu.MemcpyHtoD(cu.DevicePtr(offset(uintptr(acomp.pointer), SIZEOF_FLOAT*index)),
		cu.HostPtr(unsafe.Pointer(&value)),
		1*SIZEOF_FLOAT)
}
Exemplo n.º 2
0
// Copy from host array to device array.
func (dst *Array) CopyFromHost(src *host.Array) {
	CheckSize(dst.size4D, src.Size4D)

	partPlaneN := dst.partSize[1] * dst.partSize[2]    // floats per YZ plane per GPU
	planeN := dst.size3D[1] * dst.size3D[2]            // total floats per YZ plane
	NPlane := dst.size4D[0] * dst.size3D[0]            // total YZ planes (NComp * X size)
	partPlaneBytes := SIZEOF_FLOAT * int64(partPlaneN) // bytes per YZ plane per GPU

	for i := 0; i < NPlane; i++ {
		dstOffset := i * partPlaneN
		dstPtr := ArrayOffset(uintptr(dst.pointer), dstOffset)

		srcOffset := i * planeN

		cu.MemcpyHtoD(cu.DevicePtr(dstPtr), cu.HostPtr(&src.List[srcOffset]), partPlaneBytes)
	}
}