UDF from floats to symbol #2062
-
I have tried to implement a user-defined functor which takes two numbers and returns a symbol. AFAIU, it needs to be a stateful functor to be able to access the symbol table. I tried this:
and
but this results in a segfault.
What is the correct way to do this? EDIT: updated code to a complete example |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 7 replies
-
In the interface-tests you have some examples. Can you start from there? That might be easier. Have a look here: |
Beta Was this translation helpful? Give feedback.
-
Can you run gdb / lldb and check where it is crashing? |
Beta Was this translation helpful? Give feedback.
-
Did you compile with 32bit or 64bit RAM_DOMAIN_SIZE? If there is a mismatch between the dynamic library and souffle, it will lead to a crash. My interpretation (but I don't want to pre-empt it) is that the argument-passing fails and an exception is thrown because the floating-point number is not passed properly. |
Beta Was this translation helpful? Give feedback.
-
Note the passing is always done as RamSigned (also stored internally as such). Perhaps you use RamSigned for x and do a bitcast for the floating point number. There are macros for the conversion. |
Beta Was this translation helpful? Give feedback.
-
The functor examples in tests/interface are doing the argument passing correctly. Perhaps you run them outside the test suite first and see whether you can get them to work outside the test suite. If it works, construct an identity function for floats. See what will happen... |
Beta Was this translation helpful? Give feedback.
-
as discussed in #2069 the sample code above is supposed to work and does work if |
Beta Was this translation helpful? Give feedback.
-
Great - can you get your functor to work as well? |
Beta Was this translation helpful? Give feedback.
-
Have you checked memory issues with valgrind? |
Beta Was this translation helpful? Give feedback.
as discussed in #2069 the sample code above is supposed to work and does work if
functors.cpp
is compiled with-fopenmp
.