示例#1
0
文件: slice.go 项目: abduld/cuda-go
// internal base func for all makeXXX() functions
func makeslice(len_ int, elemsize int) slice {
	bytes := int64(len_) * int64(elemsize)
	s := slice{0, len_, len_}
	if bytes > 0 {
		s.ptr_ = cu.MemAlloc(bytes)
		cu.MemsetD8(s.ptr_, 0, bytes)
		cu.CtxSynchronize()
	}
	return s
}
示例#2
0
// Set the entire slice to this value.
func (s Float32s) Memset(value float32) {
	cu.MemsetD32(s.Pointer(), math.Float32bits(value), int64(s.Len()))
	cu.CtxSynchronize()
}