From f95f9768aded91ce2e48b6f47b4caf388ca6c68e Mon Sep 17 00:00:00 2001 From: Allard Hendriksen Date: Wed, 11 Jan 2023 18:10:45 +0100 Subject: [PATCH 1/2] Add raft::no_op functor This makes it easier to see if a lambda is unused. --- cpp/include/raft/core/operators.hpp | 10 +++++++++- cpp/include/raft/distance/detail/canberra.cuh | 8 ++------ cpp/include/raft/distance/detail/chebyshev.cuh | 9 +++------ cpp/include/raft/distance/detail/l1.cuh | 8 ++------ 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/cpp/include/raft/core/operators.hpp b/cpp/include/raft/core/operators.hpp index de521cc945..79f31b6af2 100644 --- a/cpp/include/raft/core/operators.hpp +++ b/cpp/include/raft/core/operators.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,14 @@ struct identity_op { } }; +struct no_op { + template + constexpr RAFT_INLINE_FUNCTION void operator()(const Type& in, UnusedArgs...) const + { + return; + } +}; + template struct cast_op { template diff --git a/cpp/include/raft/distance/detail/canberra.cuh b/cpp/include/raft/distance/detail/canberra.cuh index 90ed3940e1..e953fbff22 100644 --- a/cpp/include/raft/distance/detail/canberra.cuh +++ b/cpp/include/raft/distance/detail/canberra.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,11 +81,7 @@ static void canberraImpl(const DataT* x, }; // epilogue operation lambda for final value calculation - auto epilog_lambda = [] __device__(AccT acc[KPolicy::AccRowsPerTh][KPolicy::AccColsPerTh], - DataT * regxn, - DataT * regyn, - IdxT gridStrideX, - IdxT gridStrideY) { return; }; + auto epilog_lambda = raft::no_op(); if (isRowMajor) { auto canberraRowMajor = pairwiseDistanceMatKernel #include namespace raft { @@ -77,11 +78,7 @@ static void chebyshevImpl(const DataT* x, }; // epilogue operation lambda for final value calculation - auto epilog_lambda = [] __device__(AccT acc[KPolicy::AccRowsPerTh][KPolicy::AccColsPerTh], - DataT * regxn, - DataT * regyn, - IdxT gridStrideX, - IdxT gridStrideY) { return; }; + auto epilog_lambda = raft::no_op(); if (isRowMajor) { auto chebyshevRowMajor = pairwiseDistanceMatKernel Date: Wed, 11 Jan 2023 18:55:23 +0100 Subject: [PATCH 2/2] Rename raft::no_op to raft::void_op --- cpp/include/raft/core/operators.hpp | 6 +++--- cpp/include/raft/distance/detail/canberra.cuh | 2 +- cpp/include/raft/distance/detail/chebyshev.cuh | 2 +- cpp/include/raft/distance/detail/l1.cuh | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp/include/raft/core/operators.hpp b/cpp/include/raft/core/operators.hpp index 79f31b6af2..398354df46 100644 --- a/cpp/include/raft/core/operators.hpp +++ b/cpp/include/raft/core/operators.hpp @@ -40,9 +40,9 @@ struct identity_op { } }; -struct no_op { - template - constexpr RAFT_INLINE_FUNCTION void operator()(const Type& in, UnusedArgs...) const +struct void_op { + template + constexpr RAFT_INLINE_FUNCTION void operator()(UnusedArgs...) const { return; } diff --git a/cpp/include/raft/distance/detail/canberra.cuh b/cpp/include/raft/distance/detail/canberra.cuh index e953fbff22..43a904edba 100644 --- a/cpp/include/raft/distance/detail/canberra.cuh +++ b/cpp/include/raft/distance/detail/canberra.cuh @@ -81,7 +81,7 @@ static void canberraImpl(const DataT* x, }; // epilogue operation lambda for final value calculation - auto epilog_lambda = raft::no_op(); + auto epilog_lambda = raft::void_op(); if (isRowMajor) { auto canberraRowMajor = pairwiseDistanceMatKernel