This is a code generator issue, as the final signature of the C function of __return is a scalar and not a pointer (okay calling it on the Python side must also be different then).
The ability to return scalars is an intended behaviour, see CompiledSDFG._convert_return_values() that handles this case, but it does not work.
PR#1609 adds unit tests for properly testing this case (previously only array returns where tested).
Furthermore, it patches the validation to detect such cases and rejects such SDFG, however, it is not a solution.
A true solution would allow that any (global) scalar can be used to pass information to the outside, as it is possible with arrays.
By dropping the return value annotation in the above code, the frontend would actually promote the return value to an array and it would work, but no scalar is returned then.
It is impossible to return a scalar from an SDFG.
This is a code generator issue, as the final signature of the C function of
__return
is a scalar and not a pointer (okay calling it on the Python side must also be different then). The ability to return scalars is an intended behaviour, seeCompiledSDFG._convert_return_values()
that handles this case, but it does not work.PR#1609 adds unit tests for properly testing this case (previously only array returns where tested). Furthermore, it patches the validation to detect such cases and rejects such SDFG, however, it is not a solution. A true solution would allow that any (global) scalar can be used to pass information to the outside, as it is possible with arrays.
Code to reproduce:
By dropping the return value annotation in the above code, the frontend would actually promote the return value to an array and it would work, but no scalar is returned then.