Example #1
0
func (c *DemagConvolution) init() {
	{ // init FFT plans
		padded := c.kernSize
		c.stream = cu.StreamCreate()
		c.fwPlan = newFFT3DR2C(padded[0], padded[1], padded[2], c.stream)
		c.bwPlan = newFFT3DC2R(padded[0], padded[1], padded[2], c.stream)
	}

	{ // init device buffers
		// 2D re-uses fftBuf[1] as fftBuf[0], 3D needs all 3 fftBufs.
		for i := 1; i < 3; i++ {
			c.fftCBuf[i] = makeFloats(fftR2COutputSizeFloats(c.kernSize))
		}
		if c.is3D() {
			c.fftCBuf[0] = makeFloats(fftR2COutputSizeFloats(c.kernSize))
		} else {
			c.fftCBuf[0] = c.fftCBuf[1]
		}
		for i := 0; i < 3; i++ {
			c.fftRBuf[i] = c.fftCBuf[i].Slice(0, prod(c.kernSize))
		}
	}

	if c.is2D() {
		c.initFFTKern2D()
	} else {
		c.initFFTKern3D()
	}
}
Example #2
0
func initStreampool() {
	streamPool = make(chan cu.Stream, streamPoolSize)
	for i := 0; i < streamPoolSize; i++ {
		streamPool <- cu.StreamCreate()
	}
}