opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

Get CUDA code to compile with clang CUDA and without CUDA

Open vrabaud opened this issue 1 year ago • 5 comments
trafficstars

Changelist:

  • there are some syntactic changes: << < -> <<<. For some reason, I do not need to change all those in the code.
  • ::min -> std::min in __host__ code
  • modules/cudaimgproc/src/moments.cpp needs to have the CUDA code in the #ifdef
  • The signature of cv::cuda::swapChannels is not exactly the same as the C++ one in modules/cudaimgproc/src/color.cpp
  • cv::cuda::FarnebackOpticalFlow::create needs to be explicit about which FarnebackOpticalFlow it returns

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • [x] I agree to contribute to the project under Apache 2 License.
  • [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • [x] The PR is proposed to the proper branch

vrabaud avatar Sep 26 '24 07:09 vrabaud

  • there are some syntactic changes: << < -> <<<. For some reason, I do not need to change all those in the code.

On Windows this is an annoying default in Visual Studio, what errors does clang give from this? I'm concerned that if any new kernel's are added by users of VS then it will brake the clang build.

Strangely it build fine for me on Ubuntu 20:04 - clang version 10.0.0-4ubuntu1.

cudawarped avatar Sep 26 '24 09:09 cudawarped

Thx @cudawarped . I am ok fixing the << < as it goes with whatever new code comes in. This is the kind of error I get:

polar_cart.cu.cc:195:43: error:
 expected expression                                                                                                      
  195 |             polarToCartImpl_<T, false> << <grid, block, 0, stream >> >(shrinkPtr(magc), shrinkPtr(anglec), shrinkP
tr(xc), shrinkPtr(yc), scale, anglec.rows, anglec.cols);
      |                                           ^                                                                       

vrabaud avatar Sep 26 '24 09:09 vrabaud

@vrabaud Could you add some notes how you build OpenCV + CUDA + Clang. Just to be sure that we are talking about the same thing.

asmorkalov avatar Sep 26 '24 09:09 asmorkalov

@asmorkalov , for my purpose, I do not use nvcc but clang cuda instead. This is all internal to Google so I actually have no idea of the command lines unfortunately.

vrabaud avatar Sep 26 '24 09:09 vrabaud

I am done adding missing implementations, PTAL

vrabaud avatar Oct 02 '24 13:10 vrabaud