示例#1
0
文件: slice.go 项目: shenyp09/mx3
func newSlice(nComp int, m *data.Mesh, alloc func(int64) unsafe.Pointer, memType int8) *data.Slice {
	data.EnableGPU(memFree, cu.MemFreeHost, memCpy, memCpyDtoH, memCpyHtoD)
	length := m.NCell()
	bytes := int64(length) * cu.SIZEOF_FLOAT32
	ptrs := make([]unsafe.Pointer, nComp)
	for c := range ptrs {
		ptrs[c] = unsafe.Pointer(alloc(bytes))
		cu.MemsetD32(cu.DevicePtr(ptrs[c]), 0, int64(length))
	}
	return data.SliceFromPtrs(m, memType, ptrs)
}
示例#2
0
文件: float32s.go 项目: postfix/cuda5
// 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()
}