// copy back single float result from GPU and recycle buffer func copyback(buf unsafe.Pointer) float32 { var result_ [1]float32 result := result_[:] cu.MemcpyDtoH(unsafe.Pointer(&result[0]), cu.DevicePtr(buf), 1*cu.SIZEOF_FLOAT32) reduceBuffers <- buf return result_[0] }
func (src *slice) copyDtoH(dst unsafe.Pointer, dstlen int, elemsize int) { if dstlen != src.Len() { panic(fmt.Errorf("cuda4/safe: len mismatch: src.Len()=%v (device), len(dst)=%v (host)", src.Len(), dstlen)) } cu.MemcpyDtoH(dst, src.Pointer(), int64(elemsize)*int64(dstlen)) }
func memCpyDtoH(dst, src unsafe.Pointer, bytes int64) { cu.MemcpyDtoH(dst, cu.DevicePtr(src), bytes) }