From 4788ae885fdcf634b44deaf82d303fd60d71c915 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Thu, 9 Mar 2023 01:39:20 +0530 Subject: [PATCH 1/3] Fix FST_TEST gtests coded in namespace cudf::test --- cpp/tests/io/fst/common.hpp | 5 +---- cpp/tests/io/fst/fst_test.cu | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/cpp/tests/io/fst/common.hpp b/cpp/tests/io/fst/common.hpp index ce09c810e88..382d21fabb8 100644 --- a/cpp/tests/io/fst/common.hpp +++ b/cpp/tests/io/fst/common.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. @@ -20,7 +20,6 @@ #include #include -namespace cudf::test::io::json { //------------------------------------------------------------------------------ // TEST FST SPECIFICATIONS //------------------------------------------------------------------------------ @@ -81,5 +80,3 @@ std::array const pda_sgs{"{", "[", "}", "]", // The DFA's starting state constexpr char start_state = static_cast(dfa_states::TT_OOS); - -} // namespace cudf::test::io::json diff --git a/cpp/tests/io/fst/fst_test.cu b/cpp/tests/io/fst/fst_test.cu index 64ecf1f7329..1866719aa66 100644 --- a/cpp/tests/io/fst/fst_test.cu +++ b/cpp/tests/io/fst/fst_test.cu @@ -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. @@ -116,8 +116,6 @@ static std::pair fst_baseline(InputItT begin, } return {out_tape, out_index_tape}; } - -using namespace cudf::test::io::json; } // namespace // Base test fixture for tests From b0f0444ac28be79da1eb9296e11097715230ce1a Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Thu, 9 Mar 2023 01:40:37 +0530 Subject: [PATCH 2/3] Fix NESTED_JSON_TEST gtests coded in namespace cudf::test, fix other usage of namespace --- cpp/tests/io/json_tree.cpp | 248 ++++++++++++++++++------------------- 1 file changed, 121 insertions(+), 127 deletions(-) diff --git a/cpp/tests/io/json_tree.cpp b/cpp/tests/io/json_tree.cpp index 963fc698e70..c6b181fe8a1 100644 --- a/cpp/tests/io/json_tree.cpp +++ b/cpp/tests/io/json_tree.cpp @@ -34,20 +34,19 @@ #include namespace cuio_json = cudf::io::json; -namespace cudf::io::json { + // Host copy of tree_meta_t struct tree_meta_t2 { - std::vector node_categories; - std::vector parent_node_ids; - std::vector node_levels; - std::vector node_range_begin; - std::vector node_range_end; + std::vector node_categories; + std::vector parent_node_ids; + std::vector node_levels; + std::vector node_range_begin; + std::vector node_range_end; }; -} // namespace cudf::io::json namespace { std::string get_node_string(std::size_t const node_id, - cuio_json::tree_meta_t2 const& tree_rep, + tree_meta_t2 const& tree_rep, std::string const& json_input) { auto node_to_str = [](cuio_json::PdaTokenT const token) { @@ -70,8 +69,7 @@ std::string get_node_string(std::size_t const node_id, "'>"; } -void print_tree_representation(std::string const& json_input, - cuio_json::tree_meta_t2 const& tree_rep) +void print_tree_representation(std::string const& json_input, tree_meta_t2 const& tree_rep) { for (std::size_t i = 0; i < tree_rep.node_categories.size(); i++) { auto parent_id = tree_rep.parent_node_ids[i]; @@ -91,12 +89,8 @@ void print_tree_representation(std::string const& json_input, std::cout << "\n"; } } -} // namespace -namespace cudf::io::json { -namespace test { - -tree_meta_t2 to_cpu_tree(tree_meta_t const& d_value, rmm::cuda_stream_view stream) +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), cudf::detail::make_std_vector_async(d_value.parent_node_ids, stream), @@ -108,12 +102,12 @@ tree_meta_t2 to_cpu_tree(tree_meta_t const& d_value, rmm::cuda_stream_view strea // DEBUG prints auto to_cat = [](auto v) -> std::string { switch (v) { - case NC_STRUCT: return " S"; - case NC_LIST: return " L"; - case NC_STR: return " \""; - case NC_VAL: return " V"; - case NC_FN: return " F"; - case NC_ERR: return "ER"; + case cuio_json::NC_STRUCT: return " S"; + case cuio_json::NC_LIST: return " L"; + case cuio_json::NC_STR: return " \""; + case cuio_json::NC_VAL: return " V"; + case cuio_json::NC_FN: return " F"; + case cuio_json::NC_ERR: return "ER"; default: return "UN"; }; }; @@ -131,7 +125,7 @@ void print_tree(tree_meta_t2 const& cpu_tree) print_vec(cpu_tree.node_range_begin, "node_range_begin", to_int); print_vec(cpu_tree.node_range_end, "node_range_end", to_int); } -void print_tree(tree_meta_t const& d_gpu_tree) +void print_tree(cuio_json::tree_meta_t const& d_gpu_tree) { auto const cpu_tree = to_cpu_tree(d_gpu_tree, cudf::get_default_stream()); print_tree(cpu_tree); @@ -166,7 +160,9 @@ bool compare_vector(std::vector const& cpu_vec, return compare_vector(cpu_vec, gpu_vec, name); } -void compare_trees(tree_meta_t2 const& cpu_tree, tree_meta_t const& d_gpu_tree, bool print = false) +void compare_trees(tree_meta_t2 const& cpu_tree, + cuio_json::tree_meta_t const& d_gpu_tree, + bool print = false) { auto cpu_num_nodes = cpu_tree.node_categories.size(); EXPECT_EQ(cpu_num_nodes, d_gpu_tree.node_categories.size()); @@ -230,36 +226,38 @@ auto translate_col_id(T const& col_id) return new_col_ids; } -tree_meta_t2 get_tree_representation_cpu(device_span tokens_gpu, - device_span token_indices_gpu1, - cudf::io::json_reader_options const& options, - rmm::cuda_stream_view stream) +tree_meta_t2 get_tree_representation_cpu( + cudf::device_span tokens_gpu, + cudf::device_span token_indices_gpu1, + cudf::io::json_reader_options const& options, + rmm::cuda_stream_view stream) { constexpr bool include_quote_char = true; // Copy the JSON tokens to the host - thrust::host_vector tokens = cudf::detail::make_host_vector_async(tokens_gpu, stream); - thrust::host_vector token_indices = + thrust::host_vector tokens = + cudf::detail::make_host_vector_async(tokens_gpu, stream); + thrust::host_vector token_indices = cudf::detail::make_host_vector_async(token_indices_gpu1, stream); // Make sure tokens have been copied to the host stream.synchronize(); // DEBUG print - [[maybe_unused]] auto to_token_str = [](PdaTokenT token) { + [[maybe_unused]] auto to_token_str = [](cuio_json::PdaTokenT token) { switch (token) { - case token_t::StructBegin: return " {"; - case token_t::StructEnd: return " }"; - case token_t::ListBegin: return " ["; - case token_t::ListEnd: return " ]"; - case token_t::FieldNameBegin: return "FB"; - case token_t::FieldNameEnd: return "FE"; - case token_t::StringBegin: return "SB"; - case token_t::StringEnd: return "SE"; - case token_t::ErrorBegin: return "er"; - case token_t::ValueBegin: return "VB"; - case token_t::ValueEnd: return "VE"; - case token_t::StructMemberBegin: return " <"; - case token_t::StructMemberEnd: return " >"; + case cuio_json::token_t::StructBegin: return " {"; + case cuio_json::token_t::StructEnd: return " }"; + case cuio_json::token_t::ListBegin: return " ["; + case cuio_json::token_t::ListEnd: return " ]"; + case cuio_json::token_t::FieldNameBegin: return "FB"; + case cuio_json::token_t::FieldNameEnd: return "FE"; + case cuio_json::token_t::StringBegin: return "SB"; + case cuio_json::token_t::StringEnd: return "SE"; + case cuio_json::token_t::ErrorBegin: return "er"; + case cuio_json::token_t::ValueBegin: return "VB"; + case cuio_json::token_t::ValueEnd: return "VE"; + case cuio_json::token_t::StructMemberBegin: return " <"; + case cuio_json::token_t::StructMemberEnd: return " >"; default: return "."; } }; @@ -272,95 +270,97 @@ tree_meta_t2 get_tree_representation_cpu(device_span tokens_gpu } // Whether a token does represent a node in the tree representation - auto is_node = [](PdaTokenT const token) { + auto is_node = [](cuio_json::PdaTokenT const token) { switch (token) { - case token_t::StructBegin: - case token_t::ListBegin: - case token_t::StringBegin: - case token_t::ValueBegin: - case token_t::FieldNameBegin: - case token_t::ErrorBegin: return true; + case cuio_json::token_t::StructBegin: + case cuio_json::token_t::ListBegin: + case cuio_json::token_t::StringBegin: + case cuio_json::token_t::ValueBegin: + case cuio_json::token_t::FieldNameBegin: + case cuio_json::token_t::ErrorBegin: return true; default: return false; }; }; // The node that a token represents - auto token_to_node = [](PdaTokenT const token) { + auto token_to_node = [](cuio_json::PdaTokenT const token) { switch (token) { - case token_t::StructBegin: return NC_STRUCT; - case token_t::ListBegin: return NC_LIST; - case token_t::StringBegin: return NC_STR; - case token_t::ValueBegin: return NC_STR; // NC_VAL; - case token_t::FieldNameBegin: return NC_FN; - default: return NC_ERR; + case cuio_json::token_t::StructBegin: return cuio_json::NC_STRUCT; + case cuio_json::token_t::ListBegin: return cuio_json::NC_LIST; + case cuio_json::token_t::StringBegin: return cuio_json::NC_STR; + case cuio_json::token_t::ValueBegin: return cuio_json::NC_STR; // NC_VAL; + case cuio_json::token_t::FieldNameBegin: return cuio_json::NC_FN; + default: return cuio_json::NC_ERR; }; }; // Includes quote char for end-of-string token or Skips the quote char for beginning-of-field-name - auto get_token_index = [include_quote_char](PdaTokenT const token, - SymbolOffsetT const token_index) { - constexpr SymbolOffsetT quote_char_size = 1; + auto get_token_index = [include_quote_char](cuio_json::PdaTokenT const token, + cuio_json::SymbolOffsetT const token_index) { + constexpr cuio_json::SymbolOffsetT quote_char_size = 1; switch (token) { // Strip off or include quote char for StringBegin - case token_t::StringBegin: return token_index + (include_quote_char ? 0 : quote_char_size); + case cuio_json::token_t::StringBegin: + return token_index + (include_quote_char ? 0 : quote_char_size); // Strip off or Include trailing quote char for string values for StringEnd - case token_t::StringEnd: return token_index + (include_quote_char ? quote_char_size : 0); + case cuio_json::token_t::StringEnd: + return token_index + (include_quote_char ? quote_char_size : 0); // Strip off quote char included for FieldNameBegin - case token_t::FieldNameBegin: return token_index + quote_char_size; + case cuio_json::token_t::FieldNameBegin: return token_index + quote_char_size; default: return token_index; }; }; // Whether a token expects to be followed by its respective end-of-* token partner - auto is_begin_of_section = [](PdaTokenT const token) { + auto is_begin_of_section = [](cuio_json::PdaTokenT const token) { switch (token) { - case token_t::StringBegin: - case token_t::ValueBegin: - case token_t::FieldNameBegin: return true; + case cuio_json::token_t::StringBegin: + case cuio_json::token_t::ValueBegin: + case cuio_json::token_t::FieldNameBegin: return true; default: return false; }; }; // The end-of-* partner token for a given beginning-of-* token - auto end_of_partner = [](PdaTokenT const token) { + auto end_of_partner = [](cuio_json::PdaTokenT const token) { switch (token) { - case token_t::StringBegin: return token_t::StringEnd; - case token_t::ValueBegin: return token_t::ValueEnd; - case token_t::FieldNameBegin: return token_t::FieldNameEnd; - default: return token_t::ErrorBegin; + case cuio_json::token_t::StringBegin: return cuio_json::token_t::StringEnd; + case cuio_json::token_t::ValueBegin: return cuio_json::token_t::ValueEnd; + case cuio_json::token_t::FieldNameBegin: return cuio_json::token_t::FieldNameEnd; + default: return cuio_json::token_t::ErrorBegin; }; }; // Whether the token pops from the parent node stack - auto does_pop = [](PdaTokenT const token) { + auto does_pop = [](cuio_json::PdaTokenT const token) { switch (token) { - case token_t::StructEnd: - case token_t::ListEnd: return true; + case cuio_json::token_t::StructEnd: + case cuio_json::token_t::ListEnd: return true; default: return false; }; }; // Whether the token pushes onto the parent node stack - auto does_push = [](PdaTokenT const token) { + auto does_push = [](cuio_json::PdaTokenT const token) { switch (token) { - case token_t::StructBegin: - case token_t::ListBegin: return true; + case cuio_json::token_t::StructBegin: + case cuio_json::token_t::ListBegin: return true; default: return false; }; }; // The node id sitting on top of the stack becomes the node's parent // The full stack represents the path from the root to the current node - std::stack> parent_stack; + std::stack> parent_stack; constexpr bool field_name_node = true; constexpr bool no_field_name_node = false; - std::vector node_categories; - std::vector parent_node_ids; - std::vector node_levels; - std::vector node_range_begin; - std::vector node_range_end; + std::vector node_categories; + std::vector parent_node_ids; + std::vector node_levels; + std::vector node_range_begin; + std::vector node_range_end; std::size_t node_id = 0; for (std::size_t i = 0; i < tokens.size(); i++) { @@ -372,7 +372,7 @@ tree_meta_t2 get_tree_representation_cpu(device_span tokens_gpu // Identify this node's parent node id std::size_t parent_node_id = - (parent_stack.size() > 0) ? parent_stack.top().first : parent_node_sentinel; + (parent_stack.size() > 0) ? parent_stack.top().first : cuio_json::parent_node_sentinel; // If this token is the beginning-of-{value, string, field name}, also consume the next end-of-* // token @@ -395,7 +395,7 @@ tree_meta_t2 get_tree_representation_cpu(device_span tokens_gpu } // Modify the stack if needed - if (token == token_t::FieldNameBegin) { + if (token == cuio_json::token_t::FieldNameBegin) { parent_stack.push({node_id, field_name_node}); } else { if (does_push(token)) { @@ -422,20 +422,20 @@ tree_meta_t2 get_tree_representation_cpu(device_span tokens_gpu std::move(node_range_end)}; } -std::tuple, std::vector> records_orient_tree_traversal_cpu( - host_span input, - tree_meta_t2 const& tree, - bool is_array_of_arrays, - bool is_enabled_lines, - rmm::cuda_stream_view stream) +std::tuple, std::vector> +records_orient_tree_traversal_cpu(cudf::host_span input, + tree_meta_t2 const& tree, + bool is_array_of_arrays, + bool is_enabled_lines, + rmm::cuda_stream_view stream) { - std::vector node_ids(tree.parent_node_ids.size()); + std::vector node_ids(tree.parent_node_ids.size()); std::iota(node_ids.begin(), node_ids.end(), 0); - NodeIndexT const row_array_children_level = is_enabled_lines ? 1 : 2; - std::unordered_map list_indices; + const cuio_json::NodeIndexT row_array_children_level = is_enabled_lines ? 1 : 2; + std::unordered_map list_indices; if (is_array_of_arrays) { - NodeIndexT parent_node = -1, child_index = 0; + cuio_json::NodeIndexT parent_node = -1, child_index = 0; for (size_t i = 0; i < tree.node_levels.size(); i++) { if (tree.node_levels[i] == row_array_children_level) { if (tree.parent_node_ids[i] != parent_node) { @@ -460,15 +460,17 @@ std::tuple, std::vector> records_orient_tree_ } // print_vec(tree.parent_node_ids, "tree.parent_node_ids (before)"); - constexpr NodeIndexT top_node = -1; + constexpr cuio_json::NodeIndexT top_node = -1; // CPU version of the algorithm // Calculate row offsets too. auto hash_path = [&](auto node_id) { size_t seed = 0; while (node_id != top_node) { - seed = cudf::detail::hash_combine(seed, std::hash{}(tree.node_levels[node_id])); - seed = cudf::detail::hash_combine(seed, std::hash{}(tree.node_categories[node_id])); - if (tree.node_categories[node_id] == node_t::NC_FN) { + seed = cudf::detail::hash_combine( + seed, std::hash{}(tree.node_levels[node_id])); + seed = cudf::detail::hash_combine( + seed, std::hash{}(tree.node_categories[node_id])); + if (tree.node_categories[node_id] == cuio_json::node_t::NC_FN) { auto field_name = std::string_view(input.data() + tree.node_range_begin[node_id], tree.node_range_end[node_id] - tree.node_range_begin[node_id]); @@ -485,7 +487,7 @@ std::tuple, std::vector> records_orient_tree_ while (is_equal and node_id1 != top_node and node_id2 != top_node) { is_equal &= tree.node_levels[node_id1] == tree.node_levels[node_id2]; is_equal &= tree.node_categories[node_id1] == tree.node_categories[node_id2]; - if (is_equal and tree.node_categories[node_id1] == node_t::NC_FN) { + if (is_equal and tree.node_categories[node_id1] == cuio_json::node_t::NC_FN) { auto field_name1 = std::string_view(input.data() + tree.node_range_begin[node_id1], tree.node_range_end[node_id1] - tree.node_range_begin[node_id1]); @@ -503,8 +505,8 @@ std::tuple, std::vector> records_orient_tree_ } return is_equal and node_id1 == top_node and node_id2 == top_node; }; - std::unordered_map node_id_map( - 10, hash_path, equal_path); + std::unordered_map + node_id_map(10, hash_path, equal_path); auto unique_col_id = 0; for (auto& node_idx : node_ids) { if (node_id_map.count(node_idx) == 0) { @@ -535,7 +537,7 @@ std::tuple, std::vector> records_orient_tree_ col_id_current_offset[current_col_id]++; row_offsets[i] = col_id_current_offset[current_col_id] - 1; } else { - if (tree.node_categories[parent_node_id] == node_t::NC_LIST and + if (tree.node_categories[parent_node_id] == cuio_json::node_t::NC_LIST and !(is_array_of_arrays and tree.node_levels[i] == row_array_children_level)) { col_id_current_offset[current_col_id]++; row_offsets[i] = col_id_current_offset[current_col_id] - 1; @@ -551,10 +553,7 @@ std::tuple, std::vector> records_orient_tree_ return {std::move(node_ids), std::move(row_offsets)}; } -} // namespace test -} // namespace cudf::io::json - -namespace json_test = cudf::io::json::test; +} // namespace // Base test fixture for tests struct JsonTest : public cudf::test::BaseFixture { @@ -593,9 +592,8 @@ TEST_F(JsonTest, TreeRepresentation) // Get the JSON's tree representation auto gpu_tree = cuio_json::detail::get_tree_representation(tokens_gpu, token_indices_gpu, stream); // host tree generation - auto cpu_tree = - cuio_json::test::get_tree_representation_cpu(tokens_gpu, token_indices_gpu, options, stream); - json_test::compare_trees(cpu_tree, gpu_tree); + auto cpu_tree = get_tree_representation_cpu(tokens_gpu, token_indices_gpu, options, stream); + compare_trees(cpu_tree, gpu_tree); // Print tree representation if (std::getenv("NJP_DEBUG_DUMP") != nullptr) { print_tree_representation(input, cpu_tree); } @@ -680,9 +678,8 @@ TEST_F(JsonTest, TreeRepresentation2) // Get the JSON's tree representation auto gpu_tree = cuio_json::detail::get_tree_representation(tokens_gpu, token_indices_gpu, stream); // host tree generation - auto cpu_tree = - cuio_json::test::get_tree_representation_cpu(tokens_gpu, token_indices_gpu, options, stream); - json_test::compare_trees(cpu_tree, gpu_tree); + auto cpu_tree = get_tree_representation_cpu(tokens_gpu, token_indices_gpu, options, stream); + compare_trees(cpu_tree, gpu_tree); // Print tree representation if (std::getenv("NJP_DEBUG_DUMP") != nullptr) { print_tree_representation(input, cpu_tree); } @@ -754,9 +751,8 @@ TEST_F(JsonTest, TreeRepresentation3) // Get the JSON's tree representation auto gpu_tree = cuio_json::detail::get_tree_representation(tokens_gpu, token_indices_gpu, stream); // host tree generation - auto cpu_tree = - cuio_json::test::get_tree_representation_cpu(tokens_gpu, token_indices_gpu, options, stream); - json_test::compare_trees(cpu_tree, gpu_tree); + auto cpu_tree = get_tree_representation_cpu(tokens_gpu, token_indices_gpu, options, stream); + compare_trees(cpu_tree, gpu_tree); // Print tree representation if (std::getenv("NJP_DEBUG_DUMP") != nullptr) { print_tree_representation(input, cpu_tree); } @@ -858,22 +854,21 @@ TEST_P(JsonTreeTraversalTest, CPUvsGPUTraversal) const auto [tokens_gpu, token_indices_gpu] = cudf::io::json::detail::get_token_stream(d_input, options, stream); // host tree generation - auto cpu_tree = - cuio_json::test::get_tree_representation_cpu(tokens_gpu, token_indices_gpu, options, stream); + auto cpu_tree = get_tree_representation_cpu(tokens_gpu, token_indices_gpu, options, stream); bool const is_array_of_arrays = (cpu_tree.node_categories.size() > 0 and cpu_tree.node_categories[0] == cudf::io::json::NC_LIST) and (json_lines or (cpu_tree.node_categories.size() > 1 and cpu_tree.node_categories[1] == cudf::io::json::NC_LIST)); // host tree traversal - auto [cpu_col_id, cpu_row_offsets] = cuio_json::test::records_orient_tree_traversal_cpu( - input, cpu_tree, is_array_of_arrays, json_lines, stream); + auto [cpu_col_id, cpu_row_offsets] = + records_orient_tree_traversal_cpu(input, cpu_tree, is_array_of_arrays, json_lines, stream); // gpu tree generation auto gpu_tree = cuio_json::detail::get_tree_representation(tokens_gpu, token_indices_gpu, stream); // Print tree representation if (std::getenv("NJP_DEBUG_DUMP") != nullptr) { printf("BEFORE traversal (gpu_tree):\n"); - json_test::print_tree(gpu_tree); + print_tree(gpu_tree); } // gpu tree traversal auto [gpu_col_id, gpu_row_offsets] = cuio_json::detail::records_orient_tree_traversal( @@ -881,12 +876,11 @@ TEST_P(JsonTreeTraversalTest, CPUvsGPUTraversal) // Print tree representation if (std::getenv("NJP_DEBUG_DUMP") != nullptr) { printf("AFTER traversal (gpu_tree):\n"); - json_test::print_tree(gpu_tree); + print_tree(gpu_tree); } // convert to sequence because gpu col id might be have random id - auto gpu_col_id2 = - json_test::translate_col_id(cudf::detail::make_std_vector_async(gpu_col_id, stream)); - EXPECT_FALSE(json_test::compare_vector(cpu_col_id, gpu_col_id2, "col_id")); - EXPECT_FALSE(json_test::compare_vector(cpu_row_offsets, gpu_row_offsets, "row_offsets")); + auto gpu_col_id2 = translate_col_id(cudf::detail::make_std_vector_async(gpu_col_id, stream)); + EXPECT_FALSE(compare_vector(cpu_col_id, gpu_col_id2, "col_id")); + EXPECT_FALSE(compare_vector(cpu_row_offsets, gpu_row_offsets, "row_offsets")); } From 2fff639fe1ea41d3b98dba3ac2078bb2e4918547 Mon Sep 17 00:00:00 2001 From: Karthikeyan Natarajan Date: Thu, 9 Mar 2023 01:41:32 +0530 Subject: [PATCH 3/3] Fix FST_NVBENCH benchmark coded in namespace cudf --- cpp/benchmarks/io/fst.cu | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/cpp/benchmarks/io/fst.cu b/cpp/benchmarks/io/fst.cu index 7acf69e9d8e..7fb505f1d34 100644 --- a/cpp/benchmarks/io/fst.cu +++ b/cpp/benchmarks/io/fst.cu @@ -37,11 +37,10 @@ #include -namespace cudf { namespace { auto make_test_json_data(nvbench::state& state) { - auto const string_size{size_type(state.get_int64("string_size"))}; + auto const string_size{cudf::size_type(state.get_int64("string_size"))}; // Test input std::string input = R"( {)" @@ -59,13 +58,12 @@ auto make_test_json_data(nvbench::state& state) R"("price": 8.95)" R"(} {} [] [ ])"; - auto d_input_scalar = cudf::make_string_scalar(input); - auto& d_string_scalar = static_cast(*d_input_scalar); - const size_type repeat_times = string_size / input.size(); + auto d_input_scalar = cudf::make_string_scalar(input); + auto& d_string_scalar = static_cast(*d_input_scalar); + const cudf::size_type repeat_times = string_size / input.size(); return cudf::strings::repeat_string(d_string_scalar, repeat_times); } -using namespace cudf::test::io::json; // Type used to represent the atomic symbol type used within the finite-state machine using SymbolT = char; // Type sufficiently large to index symbols within the input and output (may be unsigned) @@ -78,9 +76,9 @@ constexpr std::size_t single_item = 1; void BM_FST_JSON(nvbench::state& state) { - CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits::max(), + CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits::max(), "Benchmarks only support up to size_type's maximum number of items"); - auto const string_size{size_type(state.get_int64("string_size"))}; + auto const string_size{cudf::size_type(state.get_int64("string_size"))}; // Prepare cuda stream for data transfers & kernels rmm::cuda_stream stream{}; rmm::cuda_stream_view stream_view(stream); @@ -113,9 +111,9 @@ void BM_FST_JSON(nvbench::state& state) void BM_FST_JSON_no_outidx(nvbench::state& state) { - CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits::max(), + CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits::max(), "Benchmarks only support up to size_type's maximum number of items"); - auto const string_size{size_type(state.get_int64("string_size"))}; + auto const string_size{cudf::size_type(state.get_int64("string_size"))}; // Prepare cuda stream for data transfers & kernels rmm::cuda_stream stream{}; rmm::cuda_stream_view stream_view(stream); @@ -148,9 +146,9 @@ void BM_FST_JSON_no_outidx(nvbench::state& state) void BM_FST_JSON_no_out(nvbench::state& state) { - CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits::max(), + CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits::max(), "Benchmarks only support up to size_type's maximum number of items"); - auto const string_size{size_type(state.get_int64("string_size"))}; + auto const string_size{cudf::size_type(state.get_int64("string_size"))}; // Prepare cuda stream for data transfers & kernels rmm::cuda_stream stream{}; rmm::cuda_stream_view stream_view(stream); @@ -181,9 +179,9 @@ void BM_FST_JSON_no_out(nvbench::state& state) void BM_FST_JSON_no_str(nvbench::state& state) { - CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits::max(), + CUDF_EXPECTS(state.get_int64("string_size") <= std::numeric_limits::max(), "Benchmarks only support up to size_type's maximum number of items"); - auto const string_size{size_type(state.get_int64("string_size"))}; + auto const string_size{cudf::size_type(state.get_int64("string_size"))}; // Prepare cuda stream for data transfers & kernels rmm::cuda_stream stream{}; rmm::cuda_stream_view stream_view(stream); @@ -228,5 +226,3 @@ NVBENCH_BENCH(BM_FST_JSON_no_out) NVBENCH_BENCH(BM_FST_JSON_no_str) .set_name("FST_JSON_no_str") .add_int64_power_of_two_axis("string_size", nvbench::range(20, 30, 1)); - -} // namespace cudf