Example #1
0
// Sets the cuda stream for this plan
func (plan Handle) SetStream(stream cu.Stream) {
	err := Result(C.cufftSetStream(
		C.cufftHandle(plan),
		C.cudaStream_t(unsafe.Pointer(uintptr(stream)))))
	if err != SUCCESS {
		panic(err)
	}
}
Example #2
0
// UNSAFE
// Push grid size on the execution stack. To be followed by SetupArgument()
func ConfigureCall(gridDim, blockDim dim3, sharedMem uint, stream Stream) {
	var grid, block C.dim3
	grid.x = C.uint(gridDim.X)
	grid.y = C.uint(gridDim.Y)
	grid.z = C.uint(gridDim.Z)
	block.x = C.uint(blockDim.X)
	block.y = C.uint(blockDim.Y)
	block.z = C.uint(blockDim.Z)
	err := Error(C.cudaConfigureCall((grid), (block), C.size_t(sharedMem), C.cudaStream_t(unsafe.Pointer(uintptr(stream)))))
	if err != Success {
		panic(err)
	}
}
Example #3
0
// Low-level asynchronous unsafe memory copy
// Works on device memory or page-locked host memory.
func MemcpyAsync(dest, source uintptr, bytes int, direction MemcpyKind, stream Stream) {
	err := Error(C.cudaMemcpyAsync(unsafe.Pointer(dest), unsafe.Pointer(source), C.size_t(bytes), uint32(direction), C.cudaStream_t(unsafe.Pointer(uintptr(stream)))))
	if err != Success {
		panic(err)
	}
}
Example #4
0
// Blocks until the stream has completed.
func (s Stream) Synchronize() {
	err := Error(C.cudaStreamSynchronize(C.cudaStream_t(unsafe.Pointer(uintptr(s)))))
	if err != Success {
		panic(err)
	}
}
Example #5
0
// Returns Success if all operations have completed, ErrorNotReady otherwise
func StreamQuery(stream Stream) Error {
	return Error(C.cudaStreamQuery(C.cudaStream_t(unsafe.Pointer(uintptr(stream)))))
}
Example #6
0
// Destroys an asynchronous stream
func StreamDestroy(stream Stream) {
	err := Error(C.cudaStreamDestroy(C.cudaStream_t(unsafe.Pointer(uintptr(stream)))))
	if err != Success {
		panic(err)
	}
}