Hi Bogdan,
Sorry but I have a further question - if you would be so kind.
I have now moved on a bit and I am trying to implement a test computation where I have two datasets and I want to FFT one, multiply it by the second and then IFFT that result. I have written a multiply transform and utilise the complex transform from before. I have tested both of these in isolation with the PureParallel.from_trf and work as expected. My code is as follows - apologies the data is not real as it is pulled from a larger file.
import numpy as np
from reikna.cluda import dtypes, ocl_api, functions
from reikna.fft import FFT
from reikna.core import Annotation, Type, Transformation, Parameter, Computation
from reikna.algorithms import PureParallel
import reikna.helpers as helpers
def get_complex_trf(arr):
complex_dtype = dtypes.complex_for(arr.dtype)
return Transformation(
[Parameter('output', Annotation(Type(complex_dtype, arr.shape), 'o')),
Parameter('input', Annotation(arr, 'i'))],
"""
${output.store_same}(
COMPLEX_CTR(${output.ctype})(
${input.load_same},
0));
""")
def get_multiply_trf(arr):
return Transformation(
[Parameter('output', Annotation(arr, 'o')),
Parameter('input1', Annotation(arr, 'i')),
Parameter('input2', Annotation(arr, 'i'))],
"${output.store_same}(${mul}(${input1.load_same}, ${input2.load_same}));",
connectors=['output', 'input1'],
render_kwds=dict(mul=functions.mul(arr.dtype, arr.dtype, out_dtype=arr.dtype))
)
class TestComp(Computation):
def __init__(self, arr1, arr2):
Computation.__init__(self,[
Parameter('output', Annotation(arr2, 'o')),
Parameter('input1', Annotation(arr1, 'i')),
Parameter('input2', Annotation(arr2, 'i'))]),
def _build_plan(self, plan_factory, device_params, output, input1, input2):
plan=plan_factory()
complex_trf = get_complex_trf(input1)
mul_trf=get_multiply_trf(input2)
fft=FFT(complex_trf.output)
fft.parameter.input.connect(complex_trf, complex_trf.output, new_input=complex_trf.input)
fft.parameter.output.connect(mul_trf, mul_trf.input1, IRFArr=mul_trf.input2, op=mul_trf.output)
int_arr=plan.temp_array_like(input2)
plan.computation_call(fft, int_arr, input2, input1, inverse=0)
ifft=FFT(int_arr)
output_arr=plan.temp_array_like(int_arr)
plan.computation_call(ifft, output_arr, int_arr, inverse=1)
return plan
api=ocl_api()
device=api.get_platforms()[0].get_devices()[2]
print('Performing on {}'.format(device))
thread=api.Thread(device)
#data1 is a complex128
#data2 is float64
data1_dev=thread.to_device(data1)
data2_dev=thread.to_device(data2)
res_dev=thread.array(data2.shape, np.complex128)
planC=TestComp(data2_dev, data1_dev)
planC.compile(thread)
planC(res_dev, data2_dev, data1_dev)
result=res_dev.get()
I have worked through several issues to get here but now I am the line planC.compile(thread) and I get a large stream of errors. First a failed to compile warning and a large stream of output (Seems to print functions from reikna.cluda to console) then the Traceback ends in:
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/reikna/cluda/api.py", line 563, in compile_static
return StaticKernel(self, template_src, name, global_size,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/reikna/cluda/api.py", line 783, in __init__
program = Program(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/reikna/cluda/api.py", line 654, in __init__
self._program = thr._create_program(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/reikna/cluda/api.py", line 503, in _create_program
program = self._compile(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/reikna/cluda/ocl.py", line 146, in _compile
return cl.Program(self._context, src).build(options=options, cache_dir=temp_dir)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyopencl/__init__.py", line 537, in build
self._prg, was_cached = self._build_and_catch_errors(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyopencl/__init__.py", line 585, in _build_and_catch_errors
raise err
pyopencl._cl.RuntimeError: clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE
Followed by the incredibly helpful openCL error:
SC failed. No reason given.
Any help appreciated, I have been staring at it for a few days now and cannot see the error. This is on an AMD Radeon Pro 5300M in a MacBook Pro.
Many thanks,
Gregor