Example #1
0
// internal base func for all slice() functions
func (s *slice) slice(start, stop int, elemsize uintptr) slice {
	if start >= s.cap_ || start < 0 || stop > s.cap_ || stop < 0 {
		panic("cuda4/safe: slice index out of bounds")
	}
	if start > stop {
		panic("cuda4/safe: inverted slice range")
	}
	return slice{cu.DevicePtr(uintptr(s.ptr_) + uintptr(start)*elemsize), stop - start, s.cap_ - start}
}
Example #2
0
// Manually set the pointer, length and capacity.
// Side-steps the security mechanisms, use with caution.
func (s *slice) UnsafeSet(pointer unsafe.Pointer, length, capacity int) {
	s.ptr_ = cu.DevicePtr(uintptr(pointer))
	s.len_ = length
	s.cap_ = capacity
}