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

Warnings are errors #4075

Merged
merged 29 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
07b557f
Enable warnings as errors and fix all current warnings
harrism Jul 21, 2021
74fadac
Merge branch 'branch-21.08' into fix-cuml-warnings-as-errors
harrism Jul 21, 2021
694a038
Merge branch 'branch-21.10' into fix-cuml-warnings-as-errors
harrism Jul 21, 2021
1d73c48
Use is_nan
harrism Jul 21, 2021
6ae8fae
std::size_t
harrism Jul 22, 2021
0ba156f
Eliminate #pragma unroll warnings
harrism Jul 22, 2021
173311c
Don't ignore unknown pragma warnings anymore.
harrism Jul 22, 2021
eb3373d
Respond to review feedback, std::size_t, include cstddef
harrism Jul 27, 2021
d48cf6c
Add `detail::bit_cast`
harrism Jul 27, 2021
bf8bf32
Merge branch 'branch-21.10' into fix-cuml-warnings-as-errors
harrism Jul 28, 2021
fea66f6
Fix new warning in rf_test.cu
harrism Jul 28, 2021
07f1efe
Merge branch 'branch-21.10' into fix-cuml-warnings-as-errors
harrism Aug 3, 2021
5f065fd
Fix warning in runner.cuh
harrism Aug 3, 2021
80c572a
Enable CUDA device code warnings are errors.
harrism Aug 3, 2021
06b44b1
Fix warning in contingencyMatrix.cuh
harrism Aug 3, 2021
60f04e6
Use size_t in batched matrix class.
harrism Aug 3, 2021
0d6c8e8
More auto
harrism Aug 3, 2021
fed871f
Next warnings fix...
harrism Aug 4, 2021
7a83c7d
NVCC Warnings as errors only for 11.2+
harrism Aug 4, 2021
4d82043
Another fix
harrism Aug 4, 2021
3a6a24f
More fixes in csr.cuh
harrism Aug 4, 2021
e1aee79
Next attempt
harrism Aug 4, 2021
1506dce
Temporarily disable -Werror
harrism Aug 4, 2021
d3ac9b9
Fix uninitialized variables.
harrism Aug 5, 2021
df2c6e2
Fix more warnings
harrism Aug 5, 2021
32939d2
Re-enable -Werror
harrism Aug 5, 2021
71bb6d5
Update cpp/cmake/modules/ConfigureCUDA.cmake
harrism Aug 7, 2021
b9bfa80
Remove unused parameter name.
harrism Aug 9, 2021
da342bf
Merge branch 'fix-cuml-warnings-as-errors' of github.com:harrism/cuml…
harrism Aug 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpp/cmake/modules/ConfigureCUDA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ endif()
list(APPEND CUML_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr)

# set warnings as errors
# list(APPEND CUML_CUDA_FLAGS -Werror=cross-execution-space-call)
# list(APPEND CUML_CUDA_FLAGS -Xcompiler=-Wall,-Werror,-Wno-error=deprecated-declarations)
list(APPEND CUML_CUDA_FLAGS -Werror=cross-execution-space-call)
list(APPEND CUML_CUDA_FLAGS -Xcompiler=-Wall,-Werror,-Wno-error=deprecated-declarations)

if(DISABLE_DEPRECATION_WARNING)
list(APPEND CUML_CXX_FLAGS -Wno-deprecated-declarations)
Expand Down
5 changes: 5 additions & 0 deletions cpp/include/cuml/ensemble/randomforest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
#include <cuml/common/logger.hpp>
#include <cuml/ensemble/treelite_defs.hpp>
#include <cuml/tree/decisiontree.hpp>

#include <map>

namespace raft {
class handle_t; // forward decl
}

namespace ML {

enum RF_type {
Expand Down
7 changes: 3 additions & 4 deletions cpp/include/cuml/tree/decisiontree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
*/

#pragma once
#include <vector>

#include "algo_helper.h"
#include "flatnode.h"

namespace raft {
class handle_t;
}
#include <string>
#include <vector>

namespace ML {

Expand Down
7 changes: 4 additions & 3 deletions cpp/src/common/tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <raft/cudart_utils.h>
#include <raft/mr/device/allocator.hpp>
#include <raft/mr/host/allocator.hpp>

#include <vector>

namespace ML {
Expand Down Expand Up @@ -171,17 +172,17 @@ class Tensor {
std::shared_ptr<raft::mr::host::allocator> _hAllocator;

/// Raw pointer to where the tensor data begins
DataPtrT _data;
DataPtrT _data{};

/// Array of strides (in sizeof(T) terms) per each dimension
IndexT _stride[Dim];

/// Size per each dimension
IndexT _size[Dim];

AllocState _state;
AllocState _state{};

cudaStream_t _stream;
cudaStream_t _stream{};
};

}; // end namespace ML
14 changes: 7 additions & 7 deletions cpp/src/dbscan/adjgraph/algo.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@

#pragma once

#include <thrust/device_ptr.h>
#include <thrust/scan.h>
#include <common/allocatorAdapter.hpp>
#include <raft/cuda_utils.cuh>
#include "../common.cuh"
#include "pack.h"

#include <common/allocatorAdapter.hpp>

#include <raft/cuda_utils.cuh>
#include <raft/sparse/convert/csr.cuh>

#include <thrust/device_ptr.h>
#include <thrust/scan.h>

using namespace thrust;

namespace ML {
namespace Dbscan {
namespace AdjGraph {
namespace Algo {

using namespace MLCommon;

static const int TPB_X = 256;

/**
Expand Down Expand Up @@ -61,4 +61,4 @@ void launcher(const raft::handle_t& handle,
} // namespace Algo
} // namespace AdjGraph
} // namespace Dbscan
} // namespace ML
} // namespace ML
22 changes: 12 additions & 10 deletions cpp/src/dbscan/dbscan.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

#pragma once

#include "runner.cuh"

#include <common/nvtx.hpp>

#include <cuml/cluster/dbscan.hpp>
#include <cuml/common/device_buffer.hpp>
#include <cuml/common/logger.hpp>
#include "runner.cuh"

#include <algorithm>

Expand Down Expand Up @@ -65,7 +67,7 @@ size_t compute_batch_size(size_t& estimated_memory,

// To avoid overflow, we need: batch_size <= MAX_LABEL / n_rows (floor div)
Index_ MAX_LABEL = std::numeric_limits<Index_>::max();
if (batch_size > MAX_LABEL / n_rows) {
if (batch_size > static_cast<std::size_t>(MAX_LABEL / n_rows)) {
harrism marked this conversation as resolved.
Show resolved Hide resolved
Index_ new_batch_size = MAX_LABEL / n_rows;
CUML_LOG_WARN(
"Batch size limited by the chosen integer type (%d bytes). %d -> %d. "
Expand All @@ -77,7 +79,8 @@ size_t compute_batch_size(size_t& estimated_memory,
}

// Warn when a smaller index type could be used
if (sizeof(Index_) > sizeof(int) && batch_size < std::numeric_limits<int>::max() / n_rows) {
if ((sizeof(Index_) > sizeof(int)) &&
(batch_size < std::numeric_limits<int>::max() / static_cast<std::size_t>(n_rows))) {
CUML_LOG_WARN(
"You are using an index type of size (%d bytes) but a smaller index "
"type (%d bytes) would be sufficient. Using the smaller integer type "
Expand Down Expand Up @@ -110,8 +113,11 @@ void dbscanFitImpl(const raft::handle_t& handle,
int algo_adj = 1;
int algo_ccl = 2;

int my_rank, n_rank;
Index_ start_row, n_owned_rows;
int my_rank{0};
int n_rank{1};
Index_ start_row{0};
Index_ n_owned_rows{n_rows};

if (opg) {
const auto& comm = handle.get_comms();
my_rank = comm.get_rank();
Expand All @@ -122,10 +128,6 @@ void dbscanFitImpl(const raft::handle_t& handle,
n_owned_rows = max(Index_(0), end_row - start_row);
// Note: it is possible for a node to have no work in theory. It won't
// happen in practice (because n_rows is much greater than n_rank)
} else {
my_rank = 0;
n_rank = 1;
n_owned_rows = n_rows;
}

CUML_LOG_DEBUG("#%d owns %ld rows", (int)my_rank, (unsigned long)n_owned_rows);
Expand Down Expand Up @@ -200,4 +202,4 @@ void dbscanFitImpl(const raft::handle_t& handle,
}

} // namespace Dbscan
} // namespace ML
} // namespace ML
1 change: 1 addition & 0 deletions cpp/src/dbscan/mergelabels/runner.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <label/merge_labels.cuh>

#include <raft/handle.hpp>
namespace ML {
namespace Dbscan {
namespace MergeLabels {
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/dbscan/mergelabels/tree_reduction.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

#include "runner.cuh"

#include <common/nvtx.hpp>

#include <cuml/common/logger.hpp>

namespace ML {
namespace Dbscan {
namespace MergeLabels {
Expand Down
30 changes: 16 additions & 14 deletions cpp/src/dbscan/runner.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@

#pragma once

#include <raft/cudart_utils.h>
#include <common/nvtx.hpp>
#include <cuml/common/device_buffer.hpp>
#include <label/classlabels.cuh>
#include <raft/cuda_utils.cuh>
#include <raft/mr/device/allocator.hpp>
#include <raft/sparse/csr.cuh>
#include "adjgraph/runner.cuh"
#include "corepoints/compute.cuh"
#include "corepoints/exchange.cuh"
#include "mergelabels/runner.cuh"
#include "mergelabels/tree_reduction.cuh"
#include "vertexdeg/runner.cuh"

#include <cuml/common/device_buffer.hpp>
#include <cuml/common/logger.hpp>

#include <common/nvtx.hpp>

#include <label/classlabels.cuh>

#include <raft/cudart_utils.h>
#include <raft/cuda_utils.cuh>
#include <raft/mr/device/allocator.hpp>
#include <raft/sparse/csr.cuh>

namespace ML {
namespace Dbscan {

Expand Down Expand Up @@ -302,13 +305,12 @@ size_t run(const raft::handle_t& handle,

// Perform stream reduction on the core points. The core_pts acts as the stencil and we use
// thrust::counting_iterator to return the index
auto core_point_count =
thrust::copy_if(thrust_exec_policy,
index_iterator,
index_iterator + N,
dev_core_pts,
dev_core_indices,
[=] __device__(const bool is_core_point) { return is_core_point; });
thrust::copy_if(thrust_exec_policy,
index_iterator,
index_iterator + N,
dev_core_pts,
dev_core_indices,
[=] __device__(const bool is_core_point) { return is_core_point; });

ML::POP_RANGE();
}
Expand Down
29 changes: 17 additions & 12 deletions cpp/src/decisiontree/decisiontree.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,37 @@
*/

#pragma once
#include <common/Timer.h>

#include "batched-levelalgo/builder.cuh"
#include "quantile/quantile.h"
#include "treelite_util.h"

#include <cuml/tree/algo_helper.h>
#include <cuml/tree/flatnode.h>
#include <cuml/common/logger.hpp>
#include <cuml/tree/decisiontree.hpp>

#include <common/Timer.h>
#include <common/iota.cuh>
#include <common/nvtx.hpp>

#include <raft/cudart_utils.h>
#include <raft/handle.hpp>
#include <raft/mr/device/allocator.hpp>
#include <raft/mr/host/allocator.hpp>

#include <treelite/c_api.h>
#include <treelite/tree.h>

#include <algorithm>
#include <climits>
#include <common/iota.cuh>
#include <cuml/common/logger.hpp>
#include <cuml/tree/decisiontree.hpp>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <raft/handle.hpp>
#include <raft/mr/device/allocator.hpp>
#include <raft/mr/host/allocator.hpp>
#include <random>
#include <type_traits>
#include <vector>
#include "batched-levelalgo/builder.cuh"
#include "quantile/quantile.h"
#include "treelite_util.h"

#include <common/nvtx.hpp>

/** check for treelite runtime API errors and assert accordingly */
#define TREELITE_CHECK(call) \
Expand Down
22 changes: 11 additions & 11 deletions cpp/src/fil/fil.cu
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ struct forest {
// for GROVE_PER_CLASS, averaging happens in infer_k
ot = output_t(ot & ~output_t::AVG);
params.num_outputs = params.num_classes;
do_transform = ot != output_t::RAW && ot != output_t::SOFTMAX || global_bias != 0.0f;
do_transform = (ot != output_t::RAW && ot != output_t::SOFTMAX) || global_bias != 0.0f;
break;
case leaf_algo_t::CATEGORICAL_LEAF:
params.num_outputs = params.num_classes;
Expand All @@ -276,7 +276,7 @@ struct forest {
// for VECTOR_LEAF, averaging happens in infer_k
ot = output_t(ot & ~output_t::AVG);
params.num_outputs = params.num_classes;
do_transform = ot != output_t::RAW && ot != output_t::SOFTMAX || global_bias != 0.0f;
do_transform = (ot != output_t::RAW && ot != output_t::SOFTMAX) || global_bias != 0.0f;
break;
default: ASSERT(false, "internal error: invalid leaf_algo_");
}
Expand Down Expand Up @@ -633,12 +633,12 @@ void tl2fil_leaf_payload(fil_node_t* fil_node,
auto vec = tl_tree.LeafVector(tl_node_id);
switch (forest_params.leaf_algo) {
case leaf_algo_t::CATEGORICAL_LEAF:
ASSERT(vec.size() == forest_params.num_classes,
ASSERT(vec.size() == static_cast<std::size_t>(forest_params.num_classes),
"inconsistent number of classes in treelite leaves");
fil_node->val.idx = find_class_label_from_one_hot(&vec[0], vec.size());
break;
case leaf_algo_t::VECTOR_LEAF: {
ASSERT(vec.size() == forest_params.num_classes,
ASSERT(vec.size() == static_cast<std::size_t>(forest_params.num_classes),
"inconsistent number of classes in treelite leaves");
fil_node->val.idx = *leaf_counter;
for (int k = 0; k < forest_params.num_classes; k++) {
Expand Down Expand Up @@ -769,14 +769,14 @@ inline void tree_depth_hist(const tl::Tree<T, L>& tree, std::vector<level_entry>
stack.pop();

while (!tree.IsLeaf(node_id)) {
if (depth >= hist.size()) hist.resize(depth + 1, {0, 0});
if (static_cast<std::size_t>(depth) >= hist.size()) hist.resize(depth + 1, {0, 0});
hist[depth].n_branch_nodes++;
stack.push({tree.LeftChild(node_id), depth + 1});
node_id = tree.RightChild(node_id);
depth++;
}

if (depth >= hist.size()) hist.resize(depth + 1, {0, 0});
if (static_cast<std::size_t>(depth) >= hist.size()) hist.resize(depth + 1, {0, 0});
hist[depth].n_leaves++;
}
}
Expand All @@ -794,7 +794,7 @@ std::stringstream depth_hist_and_max(const tl::ModelImpl<T, L>& model)
ios default_state(nullptr);
default_state.copyfmt(forest_shape);
forest_shape << "Depth histogram:" << endl << "depth branches leaves nodes" << endl;
for (int level = 0; level < hist.size(); ++level) {
for (std::size_t level = 0; level < hist.size(); ++level) {
level_entry e = hist[level];
forest_shape << setw(5) << level << setw(9) << e.n_branch_nodes << setw(7) << e.n_leaves
<< setw(8) << e.n_branch_nodes + e.n_leaves << endl;
Expand Down Expand Up @@ -928,7 +928,7 @@ void tl2fil_dense(std::vector<dense_node>* pnodes,
vector_leaf->resize(max_leaves_per_tree * params->num_trees * params->num_classes);
}
pnodes->resize(num_nodes, dense_node());
for (int i = 0; i < model.trees.size(); ++i) {
for (std::size_t i = 0; i < model.trees.size(); ++i) {
size_t leaf_counter = max_leaves_per_tree * i;
tree2fil_dense(pnodes,
i * tree_num_nodes(params->depth),
Expand Down Expand Up @@ -976,10 +976,10 @@ struct tl2fil_sparse_check_t<sparse_node8> {

// check the number of tree nodes
const std::vector<tl::Tree<threshold_t, leaf_t>>& trees = model.trees;
for (int i = 0; i < trees.size(); ++i) {
for (std::size_t i = 0; i < trees.size(); ++i) {
int num_nodes = trees[i].num_nodes;
ASSERT(num_nodes <= MAX_TREE_NODES,
"tree %d has %d nodes, "
"tree %lu has %d nodes, "
"but only %d supported for 8-byte sparse nodes",
i,
num_nodes,
Expand Down Expand Up @@ -1019,7 +1019,7 @@ void tl2fil_sparse(std::vector<int>* ptrees,

// convert the nodes
#pragma omp parallel for
for (int i = 0; i < num_trees; ++i) {
for (std::size_t i = 0; i < num_trees; ++i) {
// Max number of leaves processed so far
size_t leaf_counter = ((*ptrees)[i] + i) / 2;
tree2fil_sparse(*pnodes, (*ptrees)[i], model.trees[i], *params, vector_leaf, &leaf_counter);
Expand Down
Loading