dajuric
dajuric

Reputation: 2507

SSE Instructions: Find elements above threshold

Are there SSE instructions that could replace part or whole algorithm written below.

There is very long array of short values (byte, or long are acceptable). A value that is greater than some threshold must be found.

Thank you.

Upvotes: 0

Views: 764

Answers (1)

Paul R
Paul R

Reputation: 212969

Yes, you can just do the following (pseudo code):

Init threshold vector
Found = FALSE
For each vector of N elements
    Load vector (_mm_load_si128)
    Compare greater than threshold (_mm_cmpgt_XXX)
    Move comparison vector to mask (_mm_movemask_epi8)
    If mask != 0
        Found = TRUE
        Break
    End
End

Upvotes: 2

Related Questions