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

Unify template parameter dispatch for FIL inference and shared memory footprint estimation #4013

Merged
merged 38 commits into from
Oct 27, 2021

Conversation

levsnv
Copy link
Contributor

@levsnv levsnv commented Jun 24, 2021

No description provided.

@levsnv levsnv added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jun 24, 2021
@levsnv levsnv requested a review from canonizer June 24, 2021 08:54
@levsnv levsnv marked this pull request as ready for review June 24, 2021 08:54
@levsnv levsnv requested a review from a team as a code owner June 24, 2021 08:54
@levsnv levsnv added the 0 - Blocked Cannot progress due to external reasons label Jun 25, 2021
@levsnv
Copy link
Contributor Author

levsnv commented Jun 25, 2021

build fails with

ccache /usr/local/cuda/bin/nvcc -forward-unknown-to-host-compiler -ccbin=/usr/local/gcc9/bin/g++ -DCUML_CPP_API -DDISABLE_CUSPARSE_DEPRECATED -DDMLC_CORE_USE_CMAKE -DDMLC_USE_CXX11=1 -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -D__USE_XOPEN2K8 -Dcuml___EXPORTS -I../include -I/include -I../src -I../src_prims -I_deps/thrust-src -I_deps/thrust-src/dependencies/cub -I_deps/raft-src/cpp/include -I_deps/cuco-src/include -I_deps/libcudacxx-src/include -isystem=$PREFIX/include -isystem=/usr/local/cuda/include -isystem=$PREFIX/include/cumlprims -O3 -DNDEBUG --generate-code=arch=compute_60,code=[sm_60] --generate-code=arch=compute_70,code=[sm_70] --generate-code=arch=compute_75,code=[sm_75] --generate-code=arch=compute_80,code=[compute_80,sm_80] -Xcompiler=-fPIC --expt-extended-lambda --expt-relaxed-constexpr -Xcompiler=-Wno-deprecated-declarations -Xcompiler=-fopenmp -std=c++17 -MD -MT CMakeFiles/cuml++.dir/src/knn/knn_sparse.cu.o -MF CMakeFiles/cuml++.dir/src/knn/knn_sparse.cu.o.d -x cu -c ../src/knn/knn_sparse.cu -o CMakeFiles/cuml++.dir/src/knn/knn_sparse.cu.o
../src/knn/knn_sparse.cu(41): error: no instance of function template "raft::sparse::selection::brute_force_knn" matches the argument list
            argument types are: (const int *, const int *, const float *, size_t, int, int, const int *, const int *, const float *, size_t, int, int, int *, float *, int, cusparseHandle_t, std::shared_ptr<raft::mr::device::allocator>, cudaStream_t, size_t, size_t, raft::distance::DistanceType, float)

1 error detected in the compilation of "../src/knn/knn_sparse.cu".

@levsnv levsnv added 3 - Ready for Review Ready for review by team and removed 0 - Blocked Cannot progress due to external reasons labels Jun 25, 2021
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/fil.cu Outdated Show resolved Hide resolved
cpp/src/fil/infer.cu Outdated Show resolved Hide resolved
Copy link
Contributor Author

@levsnv levsnv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting for #4012 to rerun the CI

cpp/src/fil/fil.cu Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/infer.cu Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/infer.cu Outdated Show resolved Hide resolved
Copy link
Contributor

@canonizer canonizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this pull request is in a good shape, so nice work! The comments are mostly technical.

Specific points I'd like to highlight:

  • What happens if n_items or leaf_algo are negative?
  • Would it be possible to pass predict_params by value?

cpp/src/fil/common.cuh Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/test/sg/fil_test.cu Outdated Show resolved Hide resolved
cpp/test/sg/fil_test.cu Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
template <class KernelParams, class Func>
void dispatch_on_n_items(Func func, predict_params& params)
{
if (params.n_items == KernelParams::n_items) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if params.n_items == -1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the assert gets triggered

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine then.

template <class KernelParams, class Func>
void dispatch_on_leaf_algo(Func func, predict_params& params)
{
if (params.leaf_algo == KernelParams::leaf_algo) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if params.leaf_algo == -1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the assert gets triggered

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine then.

v21.12 Release automation moved this from PR-WIP to PR-Needs review Oct 8, 2021
@levsnv levsnv requested a review from canonizer October 9, 2021 00:44
Copy link
Contributor

@canonizer canonizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, provided that the comments are addressed.

cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
cpp/src/fil/common.cuh Outdated Show resolved Hide resolved
}
return func.run(params); // appeasing the compiler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way of appeasing the compiler?

Copy link
Contributor Author

@levsnv levsnv Oct 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could remove elses, since the branches return, and flip the if constexpr condition. But I thought you prefer else after return?
Alternatively, return dispatch_on_n_items<KernelParams>(func, params) might work.
Last, perhaps template <class KernelParams, class Func, class T = decltype(declval<Func>().run(params))> might resolve both this and the signature decltype question?

Copy link
Contributor

@canonizer canonizer Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need T to be in the template parameters? I guess yes if we want to use it in the return type, and no if we only need it in the function body.

In any case, even with T in the template parameters, it looks better if return T() or return T{} works. Perhaps you could add a documentation comment as to why you're doing this.

cpp/src/fil/fil.cu Outdated Show resolved Hide resolved
cpp/src/fil/fil.cu Outdated Show resolved Hide resolved
cpp/test/sg/fil_test.cu Outdated Show resolved Hide resolved
cpp/test/sg/fil_test.cu Outdated Show resolved Hide resolved
cpp/test/sg/fil_test.cu Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (branch-21.12@51c41c4). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@               Coverage Diff               @@
##             branch-21.12    #4013   +/-   ##
===============================================
  Coverage                ?   86.06%           
===============================================
  Files                   ?      231           
  Lines                   ?    18691           
  Branches                ?        0           
===============================================
  Hits                    ?    16087           
  Misses                  ?     2604           
  Partials                ?        0           
Flag Coverage Δ
dask 47.01% <0.00%> (?)
non-dask 78.75% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


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 51c41c4...9528148. Read the comment docs.

@levsnv levsnv added 4 - Waiting on Author Waiting for author to respond to review and removed 3 - Ready for Review Ready for review by team 4 - Waiting on Reviewer Waiting for reviewer to review or respond labels Oct 19, 2021
@levsnv levsnv requested a review from dantegd October 19, 2021 21:26
@levsnv levsnv added 4 - Waiting on Reviewer Waiting for reviewer to review or respond and removed 4 - Waiting on Author Waiting for author to respond to review labels Oct 20, 2021
@levsnv levsnv removed the request for review from a team October 20, 2021 06:32
v21.12 Release automation moved this from PR-Needs review to PR-Reviewer approved Oct 27, 2021
@dantegd
Copy link
Member

dantegd commented Oct 27, 2021

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 92a40e0 into rapidsai:branch-21.12 Oct 27, 2021
v21.12 Release automation moved this from PR-Reviewer approved to Done Oct 27, 2021
vimarsh6739 pushed a commit to vimarsh6739/cuml that referenced this pull request Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - Waiting on Reviewer Waiting for reviewer to review or respond CUDA/C++ improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants