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

Use __CUDA__ macro with __NVCC__. #3539

Merged
merged 1 commit into from
Aug 2, 2018
Merged

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Jul 31, 2018

  • __CUDA__ is defined in clang. Making the change won't make clang
    compile xgboost, but syntax checking for *.cu from clang is at least partially
    working.

@codecov-io
Copy link

codecov-io commented Jul 31, 2018

Codecov Report

Merging #3539 into master will increase coverage by 0.09%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3539      +/-   ##
============================================
+ Coverage     45.64%   45.74%   +0.09%     
  Complexity      188      188              
============================================
  Files           166      166              
  Lines         13234    13233       -1     
  Branches        445      445              
============================================
+ Hits           6041     6053      +12     
+ Misses         6989     6976      -13     
  Partials        204      204
Impacted Files Coverage Δ Complexity Δ
include/xgboost/base.h 100% <ø> (ø) 0 <0> (ø) ⬇️
...ala/org/apache/spark/SparkParallelismTracker.scala 89.18% <0%> (-0.29%) 9% <0%> (ø)
src/data/sparse_page_dmatrix.cc 92.89% <0%> (+0.59%) 0% <0%> (ø) ⬇️
src/data/sparse_page_raw_format.cc 64.15% <0%> (+22.64%) 0% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6cf97b4...e1a4292. Read the comment docs.

@hcho3
Copy link
Collaborator

hcho3 commented Jul 31, 2018

Can you elaborate your reasoning for replacing __NVCC__ with __CUDA__? Does this improve compatibility?

@trivialfis
Copy link
Member Author

trivialfis commented Jul 31, 2018

@hcho3 To some degree. __CUDA__ is a macro defined by clang to indicate the current scope, __NVCC__ is a similar macro defined by NVCC. As you can see from the patch, it's not really replacing, just checking for the right one to use. With this patch clang can compile a larger portion of the code, but still not the whole project.

But the reason for myself is I can use better syntax checking and code static analyse tools from clang. Now I can see error/warning and do code navigation for CUDA interactively in my editor just like normal c++ code. NVCC provides very primitive error handling facility and confusing error message.

So the patch is mainly for easy development. :)

@RAMitchell
Copy link
Member

I'm not sure I like substituting macros with more macros. It can be a little confusing. What about doing this:

#if defined(__NVCC__) || defined(__CUDA__)

* __CUDA__ is defined in clang. Making the change won't make clang
compile xgboost, but syntax checking from clang is at least partially
working.
@trivialfis trivialfis changed the title Use __CUDA__ macro instead of __NVCC__. Use __CUDA__ macro with __NVCC__. Aug 1, 2018
@trivialfis
Copy link
Member Author

@RAMitchell Done.

@RAMitchell RAMitchell merged commit 34dc915 into dmlc:master Aug 2, 2018
@trivialfis trivialfis deleted the NVCC-to-CUDA branch August 14, 2018 00:34
@lock lock bot locked as resolved and limited conversation to collaborators Nov 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants