I have a question. I'd like to make a very simple thing. I need to make FFT (say 2 points), but my signal has 6 points. Before making FFT I'd like to modify my input data so that I have 2 points instead of 6, just summing it. So instead of a0,a1,a2,a3,a4,a5 I want to have a0+a1+a2, a3+a4+a5 and use these two point as FFT input.
I wrote a transformation for FFT:
import numpy as np
from reikna.fft import FFT
from reikna.core import Annotation, Type, Transformation, Parameter
from reikna.cluda import dtypes, ocl_api, functions
api = ocl_api()
thr = api.Thread.create(device_filters={'include_platforms': 'NVIDIA'})
a = np.arange(3 * 2, dtype=np.complex64)
a.imag = a.real
tr = Transformation(
[
Parameter('out', Annotation(Type(np.complex64, shape=(2,)), 'o')),
Parameter('indata', Annotation(Type(np.complex64, shape=(2,)), 'i')),
],
"""
VSIZE_T idx1 = ${idxs[0]};
##${indata.ctype} integr = ${indata.load_idx}(idx1) + ${indata.load_idx}(idx1 + 1) + ${indata.load_idx}(idx1 + 2);
${indata.ctype} integr = ${indata.load_idx}(idx1);
${out.store_idx}(idx1, integr);
##${out.store_same}(integr);
""",
connectors=['indata']
)
fft = FFT(np.empty(2, dtype=a.dtype))
fft.parameter.output.connect(tr, tr.indata, out=tr.out)
fftc = fft.compile(thr)
data_dev = thr.to_device(a)
res_dev = thr.to_device(np.zeros(2, dtype=np.complex64))
fftc(res_dev, data_dev)
thr.synchronize()
myfft = res_dev.get()
pass
In the code I have two comments. First I replaced sum of 3 just by one (like decimation) and since I want to avoid FFT right now (for debugging), I replaced store_same by store_idx, which doesn't invoke FFT afaik.
But the problem is that I have an Exception: Template rendering failed
It doesn't like ${indata.load_idx}(idx1);
Can't understand why? How can I access current input point and a few after?
Thanks
Now it works... I feel myself like a blind kitten since OpenCL, Mako and reikna are new for me.
How would you recommend to debug myself? Foe example this transformation, it always ends up (by definition) with FFT. So if I want to figure out whether my TRANSFORMATION is correct, I have no chance to see its output. Maybe only is I take a result and make IFFT :) But is there any proper way to debug different stages of transformation or even computation?