Ask Your Question

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

asked 2015-06-02 06:42:10 -0500

jachstet-sea gravatar image

updated 2015-06-02 06:46:47 -0500

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 (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?

edit retag flag offensive close merge delete


@berak, you're right. The loop counters are initialized before the #ifdef and are not re-initialized at the loops of the generic code. Neat one :)

If you'd written that as answer, I were able to accept it ;D

jachstet-sea gravatar imagejachstet-sea ( 2015-06-02 06:49:44 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-06-02 06:44:46 -0500

berak gravatar image

hehe, thought so, too initially. but if you look at the loop counter, the unoptimized code won't run, if the optimized one ran before.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-06-02 06:42:10 -0500

Seen: 180 times

Last updated: Jun 02 '15