From 26ee43c419f8bc07c9d91a7b29f40ffe94c4a430 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Thu, 5 Dec 2024 14:43:06 -0500 Subject: [PATCH 1/2] Add anonymous namespace to libcudf test source --- cpp/tests/bitmask/set_nullmask_tests.cu | 14 +++++++------ cpp/tests/bitmask/valid_if_tests.cu | 2 ++ cpp/tests/column/bit_cast_test.cpp | 4 ++++ cpp/tests/column/compound_test.cu | 2 ++ .../device_atomics/device_atomics_test.cu | 2 ++ cpp/tests/fixed_point/fixed_point_tests.cpp | 2 ++ cpp/tests/fixed_point/fixed_point_tests.cu | 2 ++ cpp/tests/groupby/tdigest_tests.cu | 4 ++++ cpp/tests/interop/dlpack_test.cpp | 2 ++ cpp/tests/io/json/json_tree.cpp | 4 ++-- cpp/tests/io/json/json_tree_csr.cu | 3 +++ cpp/tests/io/parquet_chunked_reader_test.cu | 10 ++++++++++ .../optional_iterator_test_numeric.cu | 20 ++++++++++--------- .../iterator/pair_iterator_test_numeric.cu | 20 ++++++++++--------- .../quantiles/percentile_approx_test.cpp | 2 ++ cpp/tests/reductions/tdigest_tests.cu | 4 +++- cpp/tests/streams/interop_test.cpp | 2 ++ cpp/tests/transform/row_bit_count_test.cu | 2 ++ cpp/tests/wrappers/timestamps_test.cu | 4 ++++ 19 files changed, 78 insertions(+), 27 deletions(-) diff --git a/cpp/tests/bitmask/set_nullmask_tests.cu b/cpp/tests/bitmask/set_nullmask_tests.cu index e95c9fb41c6..f1beb9c796a 100644 --- a/cpp/tests/bitmask/set_nullmask_tests.cu +++ b/cpp/tests/bitmask/set_nullmask_tests.cu @@ -31,6 +31,7 @@ #include #include +namespace { struct valid_bit_functor { cudf::bitmask_type const* _null_mask; __device__ bool operator()(cudf::size_type element_index) const noexcept @@ -39,12 +40,13 @@ struct valid_bit_functor { } }; -std::ostream& operator<<(std::ostream& stream, thrust::host_vector const& bits) -{ - for (auto _bit : bits) - stream << int(_bit); - return stream; -} +// std::ostream& operator<<(std::ostream& stream, thrust::host_vector const& bits) +//{ +// for (auto _bit : bits) +// stream << int(_bit); +// return stream; +// } +} // namespace struct SetBitmaskTest : public cudf::test::BaseFixture { void expect_bitmask_equal(cudf::bitmask_type const* bitmask, // Device Ptr diff --git a/cpp/tests/bitmask/valid_if_tests.cu b/cpp/tests/bitmask/valid_if_tests.cu index 96f122f21a8..8ffcc552ecb 100644 --- a/cpp/tests/bitmask/valid_if_tests.cu +++ b/cpp/tests/bitmask/valid_if_tests.cu @@ -28,6 +28,7 @@ struct ValidIfTest : public cudf::test::BaseFixture {}; +namespace { struct odds_valid { __host__ __device__ bool operator()(cudf::size_type i) { return i % 2; } }; @@ -37,6 +38,7 @@ struct all_valid { struct all_null { __host__ __device__ bool operator()(cudf::size_type i) { return false; } }; +} // namespace TEST_F(ValidIfTest, EmptyRange) { diff --git a/cpp/tests/column/bit_cast_test.cpp b/cpp/tests/column/bit_cast_test.cpp index 5570a7d498c..1f29ea9e5fc 100644 --- a/cpp/tests/column/bit_cast_test.cpp +++ b/cpp/tests/column/bit_cast_test.cpp @@ -25,6 +25,7 @@ #include +namespace { template struct rep_type_impl { using type = void; @@ -47,12 +48,14 @@ struct rep_type_impl()>> { template using rep_type_t = typename rep_type_impl::type; +} // namespace template struct ColumnViewAllTypesTests : public cudf::test::BaseFixture {}; TYPED_TEST_SUITE(ColumnViewAllTypesTests, cudf::test::FixedWidthTypes); +namespace { template void do_bit_cast(cudf::column_view const& column_view, Iterator begin, Iterator end) { @@ -102,6 +105,7 @@ void do_bit_cast(cudf::column_view const& column_view, Iterator begin, Iterator } } } +} // namespace TYPED_TEST(ColumnViewAllTypesTests, BitCast) { diff --git a/cpp/tests/column/compound_test.cu b/cpp/tests/column/compound_test.cu index d7e93fb22a3..fff3282fdd5 100644 --- a/cpp/tests/column/compound_test.cu +++ b/cpp/tests/column/compound_test.cu @@ -34,6 +34,7 @@ struct CompoundColumnTest : public cudf::test::BaseFixture {}; +namespace { template struct checker_for_level1 { ColumnDeviceView d_column; @@ -62,6 +63,7 @@ struct checker_for_level2 { return bcheck; } }; +} // namespace TEST_F(CompoundColumnTest, ChildrenLevel1) { diff --git a/cpp/tests/device_atomics/device_atomics_test.cu b/cpp/tests/device_atomics/device_atomics_test.cu index b81f8196d89..2fb24f6b31e 100644 --- a/cpp/tests/device_atomics/device_atomics_test.cu +++ b/cpp/tests/device_atomics/device_atomics_test.cu @@ -31,6 +31,7 @@ #include +namespace { template CUDF_KERNEL void gpu_atomic_test(T* result, T* data, size_t size) { @@ -109,6 +110,7 @@ std::enable_if_t(), T> accumulate(cudf::host_span xs.begin(), xs.end(), ys.begin(), [](T const& ts) { return ts.time_since_epoch().count(); }); return T{typename T::duration{std::accumulate(ys.begin(), ys.end(), 0)}}; } +} // namespace template struct AtomicsTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/fixed_point/fixed_point_tests.cpp b/cpp/tests/fixed_point/fixed_point_tests.cpp index b96c6909e55..f8f8d525043 100644 --- a/cpp/tests/fixed_point/fixed_point_tests.cpp +++ b/cpp/tests/fixed_point/fixed_point_tests.cpp @@ -577,10 +577,12 @@ TEST_F(FixedPointTest, Decimal32FloatVector) float_vector_test(0.15, 20, -2, std::multiplies<>()); } +namespace { struct cast_to_int32_fn { using decimal32 = fixed_point; int32_t __host__ __device__ operator()(decimal32 fp) { return static_cast(fp); } }; +} // namespace TYPED_TEST(FixedPointTestAllReps, FixedPointColumnWrapper) { diff --git a/cpp/tests/fixed_point/fixed_point_tests.cu b/cpp/tests/fixed_point/fixed_point_tests.cu index f34760341d8..ddc48c97012 100644 --- a/cpp/tests/fixed_point/fixed_point_tests.cu +++ b/cpp/tests/fixed_point/fixed_point_tests.cu @@ -72,10 +72,12 @@ TYPED_TEST(FixedPointTestAllReps, DecimalXXThrust) EXPECT_EQ(vec2, vec3); } +namespace { struct cast_to_int32_fn { using decimal32 = fixed_point; int32_t __host__ __device__ operator()(decimal32 fp) { return static_cast(fp); } }; +} // namespace TEST_F(FixedPointTest, DecimalXXThrustOnDevice) { diff --git a/cpp/tests/groupby/tdigest_tests.cu b/cpp/tests/groupby/tdigest_tests.cu index 4ae5d06b214..883a5093bd1 100644 --- a/cpp/tests/groupby/tdigest_tests.cu +++ b/cpp/tests/groupby/tdigest_tests.cu @@ -30,6 +30,7 @@ #include #include +namespace { /** * @brief Functor to generate a tdigest by key. * @@ -116,6 +117,7 @@ struct tdigest_groupby_simple_merge_op { return std::move(result.second[0].results[0]); } }; +} // namespace template struct TDigestAllTypes : public cudf::test::BaseFixture {}; @@ -508,6 +510,7 @@ TEST_F(TDigestMergeTest, EmptyGroups) CUDF_TEST_EXPECT_COLUMNS_EQUAL(*expected, *result.second[0].results[0]); } +namespace { std::unique_ptr do_agg( cudf::column_view key, cudf::column_view val, @@ -537,6 +540,7 @@ std::unique_ptr do_agg( return std::make_unique(std::move(result_columns)); } +} // namespace TEST_F(TDigestMergeTest, AllValuesAreNull) { diff --git a/cpp/tests/interop/dlpack_test.cpp b/cpp/tests/interop/dlpack_test.cpp index ef4b9dd9b8a..b7106e823dd 100644 --- a/cpp/tests/interop/dlpack_test.cpp +++ b/cpp/tests/interop/dlpack_test.cpp @@ -26,6 +26,7 @@ #include +namespace { struct dlpack_deleter { void operator()(DLManagedTensor* tensor) { tensor->deleter(tensor); } }; @@ -60,6 +61,7 @@ void validate_dtype(DLDataType const& dtype) EXPECT_EQ(1, dtype.lanes); EXPECT_EQ(sizeof(T) * 8, dtype.bits); } +} // namespace class DLPackUntypedTests : public cudf::test::BaseFixture {}; diff --git a/cpp/tests/io/json/json_tree.cpp b/cpp/tests/io/json/json_tree.cpp index 887d4fa783f..5201a46ba7d 100644 --- a/cpp/tests/io/json/json_tree.cpp +++ b/cpp/tests/io/json/json_tree.cpp @@ -34,6 +34,8 @@ namespace cuio_json = cudf::io::json; +namespace { + // Host copy of tree_meta_t struct tree_meta_t2 { std::vector node_categories; @@ -43,8 +45,6 @@ struct tree_meta_t2 { std::vector node_range_end; }; -namespace { - tree_meta_t2 to_cpu_tree(cuio_json::tree_meta_t const& d_value, rmm::cuda_stream_view stream) { return {cudf::detail::make_std_vector_async(d_value.node_categories, stream), diff --git a/cpp/tests/io/json/json_tree_csr.cu b/cpp/tests/io/json/json_tree_csr.cu index f988ae24b38..a67830a7864 100644 --- a/cpp/tests/io/json/json_tree_csr.cu +++ b/cpp/tests/io/json/json_tree_csr.cu @@ -36,6 +36,8 @@ namespace cuio_json = cudf::io::json; +namespace { + struct h_tree_meta_t { std::vector node_categories; std::vector parent_node_ids; @@ -222,6 +224,7 @@ void run_test(std::string const& input, bool enable_lines = true) // assert equality between csr and meta formats ASSERT_TRUE(iseq); } +} // namespace struct JsonColumnTreeTests : public cudf::test::BaseFixture {}; diff --git a/cpp/tests/io/parquet_chunked_reader_test.cu b/cpp/tests/io/parquet_chunked_reader_test.cu index 153a8a0c5aa..369376b6c95 100644 --- a/cpp/tests/io/parquet_chunked_reader_test.cu +++ b/cpp/tests/io/parquet_chunked_reader_test.cu @@ -1074,6 +1074,7 @@ TEST_F(ParquetChunkedReaderTest, TestChunkedReadNullCount) } while (reader.has_next()); } +namespace { constexpr size_t input_limit_expected_file_count = 4; std::vector input_limit_get_test_names(std::string const& base_filename) @@ -1133,6 +1134,7 @@ void input_limit_test_read(std::vector const& test_filenames, CUDF_TEST_EXPECT_TABLES_EQUIVALENT(*result.first, t); } } +} // namespace struct ParquetChunkedReaderInputLimitConstrainedTest : public cudf::test::BaseFixture {}; @@ -1189,6 +1191,7 @@ TEST_F(ParquetChunkedReaderInputLimitConstrainedTest, MixedColumns) struct ParquetChunkedReaderInputLimitTest : public cudf::test::BaseFixture {}; +namespace { struct offset_gen { int const group_size; __device__ int operator()(int i) { return i * group_size; } @@ -1198,6 +1201,8 @@ template struct value_gen { __device__ T operator()(int i) { return i % 1024; } }; +} // namespace + TEST_F(ParquetChunkedReaderInputLimitTest, List) { auto base_path = temp_env->get_temp_filepath("list"); @@ -1263,6 +1268,7 @@ TEST_F(ParquetChunkedReaderInputLimitTest, List) input_limit_test_read(test_filenames, tbl, 32 * 1024 * 1024, 64 * 1024 * 1024, expected_c); } +namespace { void tiny_list_rowgroup_test(bool just_list_col) { auto iter = thrust::make_counting_iterator(0); @@ -1320,6 +1326,7 @@ void tiny_list_rowgroup_test(bool just_list_col) CUDF_TEST_EXPECT_TABLES_EQUAL(*expected, *(result.first)); } +} // namespace TEST_F(ParquetChunkedReaderInputLimitTest, TinyListRowGroupsSingle) { @@ -1333,6 +1340,7 @@ TEST_F(ParquetChunkedReaderInputLimitTest, TinyListRowGroupsMixed) tiny_list_rowgroup_test(false); } +namespace { struct char_values { __device__ int8_t operator()(int i) { @@ -1341,6 +1349,8 @@ struct char_values { return index == 0 ? 'a' : (index == 1 ? 'b' : 'c'); } }; +} // namespace + TEST_F(ParquetChunkedReaderInputLimitTest, Mixed) { auto base_path = temp_env->get_temp_filepath("mixed_types"); diff --git a/cpp/tests/iterator/optional_iterator_test_numeric.cu b/cpp/tests/iterator/optional_iterator_test_numeric.cu index 257c0979017..c81d5a846f2 100644 --- a/cpp/tests/iterator/optional_iterator_test_numeric.cu +++ b/cpp/tests/iterator/optional_iterator_test_numeric.cu @@ -26,15 +26,15 @@ using TestingTypes = cudf::test::NumericTypes; -namespace cudf { -// To print meanvar for debug. -// Needs to be in the cudf namespace for ADL -template -std::ostream& operator<<(std::ostream& os, cudf::meanvar const& rhs) -{ - return os << "[" << rhs.value << ", " << rhs.value_squared << ", " << rhs.count << "] "; -}; -} // namespace cudf +// namespace { +//// To print meanvar for debug. +//// Needs to be in the cudf namespace for ADL +// template +// std::ostream& operator<<(std::ostream& os, cudf::meanvar const& rhs) +//{ +// return os << "[" << rhs.value << ", " << rhs.value_squared << ", " << rhs.count << "] "; +// }; +// } // namespace template struct NumericOptionalIteratorTest : public IteratorTest {}; @@ -46,6 +46,7 @@ TYPED_TEST(NumericOptionalIteratorTest, nonull_optional_iterator) } TYPED_TEST(NumericOptionalIteratorTest, null_optional_iterator) { null_optional_iterator(*this); } +namespace { // Transformers and Operators for optional_iterator test template struct transformer_optional_meanvar { @@ -65,6 +66,7 @@ template struct optional_to_meanvar { CUDF_HOST_DEVICE inline T operator()(cuda::std::optional const& v) { return v.value_or(T{0}); } }; +} // namespace // TODO: enable this test also at __CUDACC_DEBUG__ // This test causes fatal compilation error only at device debug mode. diff --git a/cpp/tests/iterator/pair_iterator_test_numeric.cu b/cpp/tests/iterator/pair_iterator_test_numeric.cu index 3447aa0dde6..e11861451eb 100644 --- a/cpp/tests/iterator/pair_iterator_test_numeric.cu +++ b/cpp/tests/iterator/pair_iterator_test_numeric.cu @@ -24,15 +24,15 @@ using TestingTypes = cudf::test::NumericTypes; -namespace cudf { -// To print meanvar for debug. -// Needs to be in the cudf namespace for ADL -template -std::ostream& operator<<(std::ostream& os, cudf::meanvar const& rhs) -{ - return os << "[" << rhs.value << ", " << rhs.value_squared << ", " << rhs.count << "] "; -}; -} // namespace cudf +// namespace cudf { +//// To print meanvar for debug. +//// Needs to be in the cudf namespace for ADL +// template +// std::ostream& operator<<(std::ostream& os, cudf::meanvar const& rhs) +//{ +// return os << "[" << rhs.value << ", " << rhs.value_squared << ", " << rhs.count << "] "; +// }; +// } // namespace cudf template struct NumericPairIteratorTest : public IteratorTest {}; @@ -53,6 +53,7 @@ struct transformer_pair_meanvar { }; }; +namespace { struct sum_if_not_null { template CUDF_HOST_DEVICE inline thrust::pair operator()(thrust::pair const& lhs, @@ -66,6 +67,7 @@ struct sum_if_not_null { return {rhs}; } }; +} // namespace // TODO: enable this test also at __CUDACC_DEBUG__ // This test causes fatal compilation error only at device debug mode. diff --git a/cpp/tests/quantiles/percentile_approx_test.cpp b/cpp/tests/quantiles/percentile_approx_test.cpp index 37414eb3fba..c146fd2ea4e 100644 --- a/cpp/tests/quantiles/percentile_approx_test.cpp +++ b/cpp/tests/quantiles/percentile_approx_test.cpp @@ -33,6 +33,7 @@ #include +namespace { std::unique_ptr arrow_percentile_approx(cudf::column_view const& _values, int delta, std::vector const& percentages) @@ -315,6 +316,7 @@ cudf::data_type get_appropriate_type() if constexpr (cudf::is_fixed_point()) { return cudf::data_type{cudf::type_to_id(), -7}; } return cudf::data_type{cudf::type_to_id()}; } +} // namespace using PercentileApproxTypes = cudf::test::Concat; diff --git a/cpp/tests/reductions/tdigest_tests.cu b/cpp/tests/reductions/tdigest_tests.cu index c8fec51e1c9..184725e17e0 100644 --- a/cpp/tests/reductions/tdigest_tests.cu +++ b/cpp/tests/reductions/tdigest_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023, NVIDIA CORPORATION. + * Copyright (c) 2022-2024, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ template struct ReductionTDigestAllTypes : public cudf::test::BaseFixture {}; TYPED_TEST_SUITE(ReductionTDigestAllTypes, cudf::test::NumericTypes); +namespace { struct reduce_op { std::unique_ptr operator()(cudf::column_view const& values, int delta) const { @@ -60,6 +61,7 @@ struct reduce_merge_op { return cudf::make_structs_column(tbl.num_rows(), std::move(cols), 0, rmm::device_buffer()); } }; +} // namespace TYPED_TEST(ReductionTDigestAllTypes, Simple) { diff --git a/cpp/tests/streams/interop_test.cpp b/cpp/tests/streams/interop_test.cpp index 7133baf6df1..79ea6b7d6d4 100644 --- a/cpp/tests/streams/interop_test.cpp +++ b/cpp/tests/streams/interop_test.cpp @@ -23,9 +23,11 @@ #include +namespace { struct dlpack_deleter { void operator()(DLManagedTensor* tensor) { tensor->deleter(tensor); } }; +} // namespace struct DLPackTest : public cudf::test::BaseFixture {}; diff --git a/cpp/tests/transform/row_bit_count_test.cu b/cpp/tests/transform/row_bit_count_test.cu index 01a042130d6..7e203086fca 100644 --- a/cpp/tests/transform/row_bit_count_test.cu +++ b/cpp/tests/transform/row_bit_count_test.cu @@ -590,6 +590,7 @@ TEST_F(RowBitCount, EmptyChildColumnInListOfLists) cudf::test::fixed_width_column_wrapper{32, 32, 32, 32}); } +namespace { struct sum_functor { cudf::size_type const* s0; cudf::size_type const* s1; @@ -597,6 +598,7 @@ struct sum_functor { cudf::size_type operator() __device__(int i) { return s0[i] + s1[i] + s2[i]; } }; +} // namespace TEST_F(RowBitCount, Table) { diff --git a/cpp/tests/wrappers/timestamps_test.cu b/cpp/tests/wrappers/timestamps_test.cu index 4086c5a91bb..8e5129dfbd2 100644 --- a/cpp/tests/wrappers/timestamps_test.cu +++ b/cpp/tests/wrappers/timestamps_test.cu @@ -37,6 +37,7 @@ #include #include +namespace { template struct ChronoColumnTest : public cudf::test::BaseFixture { cudf::size_type size() { return cudf::size_type(100); } @@ -72,6 +73,7 @@ struct compare_chrono_elements_to_primitive_representation { return primitive == dur.count(); } }; +} // namespace TYPED_TEST_SUITE(ChronoColumnTest, cudf::test::ChronoTypes); @@ -103,6 +105,7 @@ TYPED_TEST(ChronoColumnTest, ChronoDurationsMatchPrimitiveRepresentation) *cudf::column_device_view::create(chrono_col)})); } +namespace { template struct compare_chrono_elements { cudf::binary_operator comp; @@ -129,6 +132,7 @@ struct compare_chrono_elements { } } }; +} // namespace TYPED_TEST(ChronoColumnTest, ChronosCanBeComparedInDeviceCode) { From e489fcf482c67772e4b6b74dd62ef6109028276a Mon Sep 17 00:00:00 2001 From: David Wendt Date: Fri, 6 Dec 2024 08:29:06 -0500 Subject: [PATCH 2/2] remove commented out lines --- cpp/tests/bitmask/set_nullmask_tests.cu | 7 ------- cpp/tests/iterator/optional_iterator_test_numeric.cu | 10 ---------- cpp/tests/iterator/pair_iterator_test_numeric.cu | 10 ---------- 3 files changed, 27 deletions(-) diff --git a/cpp/tests/bitmask/set_nullmask_tests.cu b/cpp/tests/bitmask/set_nullmask_tests.cu index f1beb9c796a..9f8d22ea94d 100644 --- a/cpp/tests/bitmask/set_nullmask_tests.cu +++ b/cpp/tests/bitmask/set_nullmask_tests.cu @@ -39,13 +39,6 @@ struct valid_bit_functor { return cudf::bit_is_set(_null_mask, element_index); } }; - -// std::ostream& operator<<(std::ostream& stream, thrust::host_vector const& bits) -//{ -// for (auto _bit : bits) -// stream << int(_bit); -// return stream; -// } } // namespace struct SetBitmaskTest : public cudf::test::BaseFixture { diff --git a/cpp/tests/iterator/optional_iterator_test_numeric.cu b/cpp/tests/iterator/optional_iterator_test_numeric.cu index c81d5a846f2..8377060b6ec 100644 --- a/cpp/tests/iterator/optional_iterator_test_numeric.cu +++ b/cpp/tests/iterator/optional_iterator_test_numeric.cu @@ -26,16 +26,6 @@ using TestingTypes = cudf::test::NumericTypes; -// namespace { -//// To print meanvar for debug. -//// Needs to be in the cudf namespace for ADL -// template -// std::ostream& operator<<(std::ostream& os, cudf::meanvar const& rhs) -//{ -// return os << "[" << rhs.value << ", " << rhs.value_squared << ", " << rhs.count << "] "; -// }; -// } // namespace - template struct NumericOptionalIteratorTest : public IteratorTest {}; diff --git a/cpp/tests/iterator/pair_iterator_test_numeric.cu b/cpp/tests/iterator/pair_iterator_test_numeric.cu index e11861451eb..5f707232953 100644 --- a/cpp/tests/iterator/pair_iterator_test_numeric.cu +++ b/cpp/tests/iterator/pair_iterator_test_numeric.cu @@ -24,16 +24,6 @@ using TestingTypes = cudf::test::NumericTypes; -// namespace cudf { -//// To print meanvar for debug. -//// Needs to be in the cudf namespace for ADL -// template -// std::ostream& operator<<(std::ostream& os, cudf::meanvar const& rhs) -//{ -// return os << "[" << rhs.value << ", " << rhs.value_squared << ", " << rhs.count << "] "; -// }; -// } // namespace cudf - template struct NumericPairIteratorTest : public IteratorTest {};