New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failing tests on s390c, ppc64le, and MIPS #442
Comments
VOLK does not provide optimizations for these architectures. Thus, only the generic kernels are used. We ran tests on these archs with TravisCI but need to stop it because of TravisCI policy changes. Can you run your build with |
You are right, it's segfaulting:
I will run it through the debugger. |
bt for the volk_32fc_s32fc_multiply_32fc_test.sh, compiled with -g -O0 -fno-strict-aliasing:
|
To be honest I have no idea why there are non sense values at |
The same problem occurred with gcc 9.3.1. |
The problem is caused by |
Stripped down reproducer:
Both |
I created gcc bug and let's see :) https://bugzilla.redhat.com/show_bug.cgi?id=1918519 |
Thank you, @yarda! |
The standard doesn't say they're interchangeable so you're relying on undefined behaviour. All the standard says is that they have the same memory layout, so you can access |
It works if you just pass the complex number by address instead of by value, see https://bugzilla.redhat.com/show_bug.cgi?id=1918519#c3 |
@jwakely Thanks for the thorough explanation. Now it becomes quite obvious why all those three |
@jdemel, well, the only way for current/previously released C++ software that uses However, not all is bleak: We can fix this for GR master, 3.9.0.1, 3.8.2.1 (or whatever the next 3.8 is) by actually not relying on it being For people with un-upgradeable software that links against VOLK 3, you could just add a |
You could add overloads on the C++ side which take That would allow the C++ code to keep calling the function and passing But I don't see how to fix existing C++ code that has already been compiled and passes a |
@jwakely exactly, all you can do is have a compatibility mode for this legacy software activated with a
Application-wise, copying the data even once is not an option; VOLK is library for SIMD-accelerated direct operation on uniform vectors in memory, and copying that nullifies nearly every benefit you get from it. Therefore, you really need to cast the pointers passed around here, not the values, in C-land. While I'm certain we could trick enough compilers to at least accept that a So, yeah, I think we shouldn't ever had a C++ API that |
Ah yes, that's not appropriate then. Even with LTO you're unlikely to get those extra copies and forwarding functions inlined away.
100% agreed. |
The issue "we rely on undefined behavior" slipped through for a long time. Now, that we know about it, we need to come up with a clever solution. The clean and long term goal should be a simplified interface. Given the current scope of VOLK
I'd argue, we should try to make sure that we only offer a C interface. Then we have tooling for hazzle free work with C++. Essentially, I can't think of a fix for this issue that wouldn't break our API. Thus, a VOLK version that includes such a fix requires a major version bump. A good reason to move to VOLK 3. But we want to avoid breakage. So, if we would break our API, we should first gather all the necessary changes that should go into a new major version. We'd avoid to have a VOLK 4 release for a longer period. If we can get away with something like "declare everything:
Users would "only" need to recompile. But we'd need to confirm that we add this declaration in every place where it is needed. I'd be really happy to discuss this situation. I'm sure we'll come up with a good solution. @jwakely @yarda How urgent is your need for a fix? It'd be a bummer to not have VOLK in Fedora at all. |
I think the same problem exists in older gnuradio where the volk is bundled and nobody has complained so far. This can mean that in Fedora it is not much used by ppc64le and s390x users. So I think I could go ahead now, bypass the tests and just document this problem. Another possible solution is to exclude gnuradio/volk from the ppc64le and s390x in Fedora, but I think it could be somehow usable even with this known problem. In the meantime I hit another problem on s390x (not on ppc64le) which I haven't time to investigate, the |
@yarda I don't know about If a |
It's caused by the following volk CMakeLists.txt code:
I.e. on the s390x the cpu_features are disabled. I quickly checked the cpu_features code and it seems it doesn't support s390x. The |
@yarda I suppose this is the correct way to go for VOLK as well. We shouldn't add tools that are not part of our core project. |
VOLK does have an issue with its interface on s390x and ppc64le. I hope this won't be an issue for other architectures. Still, I think it is reasonable to find a solution for VOLK that does not rely on undefined behavior. Otherwise it'll bite us some day. Here I'd like to outline a few thoughts I had to fix this issue. Comments and feedback are welcome. Since VOLK is a C project, I'd argue that it is reasonable to stick with C. Thus, my idea for an improved interface would be to strictly follow C. Then we can build bindings around it. I don't want to remove our C++ convenience though. Our C interface is supposed to look like this: lv_32fc_t *result = (lv_32fc_t*) volk_malloc(sizeof(lv_32fc_t) * 16, volk_alignment() );
lv_32fc_t *source = (lv_32fc_t*) volk_malloc(sizeof(lv_32fc_t) * 16, volk_alignment() );
lv_32fc_t value = lv_32fc_t(1.0f, 1.0f);
volk_32fc_s32fc_operation_32fc(result, source, value, 16); Vectors are passed around by pointer and scalars are passed by value. I'd like to have a wrapper for C++ that works smth like this: volk::vector<std::complex<float> > result(16);
volk::vector<std::complex<float> > source(16);
std::complex<float> value(1.0f, 1.0f);
volk_32fc_s32fc_operation_32fc(result.data(), source.data(), value, result.size()); (I just wrote this code from the top of my head. It might have some issue.) I want to avoid to write extra code for the C++ interface for VOLK developers. For VOLK users I want to avoid the need to do casts like |
As per maintainer request, re-titled the issue to include MIPS. |
Passing lv_32fc_t arguments by value results in Undefined Behaviour, as explained in gnuradio/volk#442. To avoid this, we use VOLK 3.1.0's updated API, where lv_32fc_t arguments are passed in using pointers. Three of the affected volk_32fc_s32fc_multiply_32fc calls (all in gr-dtv) did not actually use a complex scalar, so I switched those calls to volk_32f_s32f_multiply_32f instead. Signed-off-by: Clayton Smith <argilo@gmail.com>
Passing lv_32fc_t arguments by value results in Undefined Behaviour, as explained in gnuradio/volk#442. To avoid this, we use VOLK 3.1.0's updated API, where lv_32fc_t arguments are passed in using pointers. Three of the affected volk_32fc_s32fc_multiply_32fc calls (all in gr-dtv) did not actually use a complex scalar, so I switched those calls to volk_32f_s32f_multiply_32f instead. Signed-off-by: Clayton Smith <argilo@gmail.com>
Passing lv_32fc_t arguments by value results in Undefined Behaviour, as explained in gnuradio/volk#442. To avoid this, we use VOLK 3.1.0's updated API, where lv_32fc_t arguments are passed in using pointers. Three of the affected volk_32fc_s32fc_multiply_32fc calls (all in gr-dtv) did not actually use a complex scalar, so I switched those calls to volk_32f_s32f_multiply_32f instead. Signed-off-by: Clayton Smith <argilo@gmail.com>
Passing lv_32fc_t arguments by value results in Undefined Behaviour, as explained in gnuradio/volk#442. To avoid this, we use VOLK 3.1.0's updated API, where lv_32fc_t arguments are passed in using pointers. Three of the affected volk_32fc_s32fc_multiply_32fc calls (all in gr-dtv) did not actually use a complex scalar, so I switched those calls to volk_32f_s32f_multiply_32f instead. Signed-off-by: Clayton Smith <argilo@gmail.com> (cherry picked from commit bdaf5df) Signed-off-by: Jeff Long <willcode4@gmail.com>
Passing lv_32fc_t arguments by value results in Undefined Behaviour, as explained in gnuradio/volk#442. To avoid this, we use VOLK 3.1.0's updated API, where lv_32fc_t arguments are passed in using pointers. Three of the affected volk_32fc_s32fc_multiply_32fc calls (all in gr-dtv) did not actually use a complex scalar, so I switched those calls to volk_32f_s32f_multiply_32f instead. Signed-off-by: Clayton Smith <argilo@gmail.com> (cherry picked from commit bdaf5df) Signed-off-by: Jeff Long <willcode4@gmail.com>
We are trying to rebase gnuradio to 3.9.0.0 in Fedora, but we found out that the volk-2.4.1 testsuite doesn't pass on s390x and ppc64le. We build with standard distro flags plus -fno-strict-aliasing. The following tests are failing:
92 - qa_volk_32fc_s32fc_multiply_32fc (Failed)
93 - qa_volk_32fc_s32fc_rotatorpuppet_32fc (Failed)
102 - qa_volk_32fc_x2_s32fc_multiply_conjugate_add_32fc (Failed)
Build logs:
https://jskarvad.fedorapeople.org/volk/ppc64le_build_failure.txt
https://jskarvad.fedorapeople.org/volk/s390x_build_failure.txt
The text was updated successfully, but these errors were encountered: