Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get CUDA code to compile with clang CUDA and without CUDA #3800

Open
wants to merge 6 commits into
base: 4.x
Choose a base branch
from

Conversation

vrabaud
Copy link
Contributor

@vrabaud vrabaud commented Sep 26, 2024

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

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch

@cudawarped
Copy link
Contributor

  • 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.

@vrabaud
Copy link
Contributor Author

vrabaud commented Sep 26, 2024

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);
      |                                           ^                                                                       

@asmorkalov
Copy link
Contributor

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

@vrabaud
Copy link
Contributor Author

vrabaud commented Sep 26, 2024

@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
Copy link
Contributor Author

vrabaud commented Oct 2, 2024

I am done adding missing implementations, PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants