Ask Your Question

Revision history [back]

Optimized (SSE/NEON) methods: algorithm executed twice?

This is not about OpenCV-usage but related to OpenCV-code itself. I just had a short look at the method "int normHamming(const uchar* a, int n)" defined in "modules/hal/src/stat.cpp" (line 83 of current git master).

Let's assume CV_NEON is defined. In that case, the code inside the curly braces after the #ifdef is executed. However, since there is no return, the code below/after is ALSO executed. If CV_NEON were not defined, only the unoptimized code were executed. This seems to me as if the algorithm is first executed via NEON (optimized) and then again via the generic implementation?

This also applies to more methods in the same file (example: "int normL1_(const uchar* a, const uchar* b, int n)" in line 258) and also methods in other files.

Is this a bug or is there an explanation?

Optimized (SSE/NEON) methods: algorithm executed twice?

This is not about OpenCV-usage but related to OpenCV-code itself. I just had a short look at the method "int normHamming(const uchar* a, int n)" defined in "modules/hal/src/stat.cpp" (line 83 of current git master).

Let's assume CV_NEON is defined. In that case, the code inside the curly braces after the #ifdef is executed. However, since there is no return, return (and no "else" for the code after), the code below/after is ALSO executed. If CV_NEON were not defined, only the unoptimized code were executed. This seems to me as if the algorithm is first executed via NEON (optimized) and then again via the generic implementation?

This also applies to more methods in the same file (example: "int normL1_(const uchar* a, const uchar* b, int n)" in line 258) and also methods in other files.

Is this a bug or is there an explanation?