twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4
MIT License
1.99k stars 160 forks source link

SIMD (universal intrinsics) support? #265

Open fzyzcjy opened 3 years ago

fzyzcjy commented 3 years ago

Hi thanks for this lib! I wonder how we can have support for SIMD, i.e. universal intrinsics? Because this can boost the speed by, say, 4x!

twistedfall commented 3 years ago

Hi, are you referring to the particular (missing) APIs that are present in the C++ OpenCV? If so, can you please name them? Because otherwise I believe SIMD support depends on how the OpenCV itself is built.

fzyzcjy commented 3 years ago

@twistedfall Hi I mean this: https://docs.opencv.org/4.5.3/df/d91/group__core__hal__intrin.html

twistedfall commented 3 years ago

I see, I’ll see if those can be exported

fzyzcjy commented 3 years ago

Well after 3 days poking around the source code of this lib, I feel it may not be very possible. If I understand correctly, this binding will add try-catch on every call from rust to C++. However, intrinsics are very low-level and will be called with very high frequency indeed. So exporting it will make it not useful anymore...

twistedfall commented 3 years ago

You can mark functions as infallible, then the try/catch will be skipped. But I understand the performance implications, I’ll keep that in mind.

twistedfall commented 3 years ago

This is actionable, so let's leave this open

fzyzcjy commented 3 years ago

Ok