Esempio n. 1
0
// Memset sets the Slice's components to the specified values.
func Memset(s *data.Slice, val ...float32) {
	util.Argument(len(val) == s.NComp())
	str := stream()
	for c, v := range val {
		cu.MemsetD32Async(cu.DevicePtr(s.DevPtr(c)), math.Float32bits(v), int64(s.Len()), str)
	}
	syncAndRecycle(str)
}
Esempio n. 2
0
// return a 1-float CUDA reduction buffer from a pool
// initialized to initVal
func reduceBuf(initVal float32) unsafe.Pointer {
	if reduceBuffers == nil {
		initReduceBuf()
	}
	buf := <-reduceBuffers
	str := stream()
	cu.MemsetD32Async(cu.DevicePtr(buf), math.Float32bits(initVal), 1, str)
	syncAndRecycle(str)
	return buf
}
Esempio n. 3
0
// Set the entire slice to this value, asynchronously.
func (s Float32s) MemsetAsync(value float32, stream cu.Stream) {
	cu.MemsetD32Async(s.Pointer(), math.Float32bits(value), int64(s.Len()), stream)
}
Esempio n. 4
0
// zero 1-component slice
func zero1(dst *data.Slice, str cu.Stream) {
	cu.MemsetD32Async(cu.DevicePtr(dst.DevPtr(0)), 0, int64(dst.Len()), str)
}