Skip to content

Commit

Permalink
Fix memcheck error in TypeInference.Timestamp gtest (#11905)
Browse files Browse the repository at this point in the history
Fixes an error in the `TypeInference.Timestamp` gtest where the `size` parameter was incorrect.

This error was found by the nightly builds and could be recreated using
```
compute-sanitizer --tool memcheck gtests/TYPE_INFERENCE_TEST --gtest_filter=TypeInference.Timestamp --rmm_mode=cuda
```

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Vukasin Milovanovic (https://github.com/vuule)
  - Nghia Truong (https://github.com/ttnghia)

URL: #11905
  • Loading branch information
davidwendt authored Oct 12, 2022
1 parent 75a6973 commit 8b5ab23
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions cpp/tests/io/type_inference_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ TEST_F(TypeInference, Basic)
auto d_data = cudf::make_string_scalar(data);
auto& d_string_scalar = static_cast<cudf::string_scalar&>(*d_data);

std::size_t constexpr size = 3;
auto const string_offset = std::vector<int32_t>{1, 4, 7};
auto const string_length = std::vector<std::size_t>{2, 2, 1};
auto const string_offset = std::vector<int32_t>{1, 4, 7};
auto const string_length = std::vector<std::size_t>{2, 2, 1};
rmm::device_vector<int32_t> d_string_offset{string_offset};
rmm::device_vector<std::size_t> d_string_length{string_length};

Expand All @@ -63,7 +62,7 @@ TEST_F(TypeInference, Basic)
infer_data_type(options.json_view(),
{d_string_scalar.data(), static_cast<std::size_t>(d_string_scalar.size())},
d_col_strings,
size,
string_offset.size(),
stream);

EXPECT_EQ(res_type, cudf::data_type{cudf::type_id::INT64});
Expand All @@ -82,9 +81,8 @@ TEST_F(TypeInference, Null)
auto d_data = cudf::make_string_scalar(data);
auto& d_string_scalar = static_cast<cudf::string_scalar&>(*d_data);

std::size_t constexpr size = 3;
auto const string_offset = std::vector<int32_t>{1, 1, 4};
auto const string_length = std::vector<std::size_t>{0, 2, 1};
auto const string_offset = std::vector<int32_t>{1, 1, 4};
auto const string_length = std::vector<std::size_t>{0, 2, 1};
rmm::device_vector<int32_t> d_string_offset{string_offset};
rmm::device_vector<std::size_t> d_string_length{string_length};

Expand All @@ -95,7 +93,7 @@ TEST_F(TypeInference, Null)
infer_data_type(options.json_view(),
{d_string_scalar.data(), static_cast<std::size_t>(d_string_scalar.size())},
d_col_strings,
size,
string_offset.size(),
stream);

EXPECT_EQ(res_type,
Expand All @@ -115,9 +113,8 @@ TEST_F(TypeInference, AllNull)
auto d_data = cudf::make_string_scalar(data);
auto& d_string_scalar = static_cast<cudf::string_scalar&>(*d_data);

std::size_t constexpr size = 3;
auto const string_offset = std::vector<int32_t>{1, 1, 1};
auto const string_length = std::vector<std::size_t>{0, 0, 4};
auto const string_offset = std::vector<int32_t>{1, 1, 1};
auto const string_length = std::vector<std::size_t>{0, 0, 4};
rmm::device_vector<int32_t> d_string_offset{string_offset};
rmm::device_vector<std::size_t> d_string_length{string_length};

Expand All @@ -128,7 +125,7 @@ TEST_F(TypeInference, AllNull)
infer_data_type(options.json_view(),
{d_string_scalar.data(), static_cast<std::size_t>(d_string_scalar.size())},
d_col_strings,
size,
string_offset.size(),
stream);

EXPECT_EQ(res_type, cudf::data_type{cudf::type_id::INT8}); // INT8 if all nulls
Expand All @@ -147,9 +144,8 @@ TEST_F(TypeInference, String)
auto d_data = cudf::make_string_scalar(data);
auto& d_string_scalar = static_cast<cudf::string_scalar&>(*d_data);

std::size_t constexpr size = 3;
auto const string_offset = std::vector<int32_t>{1, 8, 12};
auto const string_length = std::vector<std::size_t>{6, 3, 4};
auto const string_offset = std::vector<int32_t>{1, 8, 12};
auto const string_length = std::vector<std::size_t>{6, 3, 4};
rmm::device_vector<int32_t> d_string_offset{string_offset};
rmm::device_vector<std::size_t> d_string_length{string_length};

Expand All @@ -160,7 +156,7 @@ TEST_F(TypeInference, String)
infer_data_type(options.json_view(),
{d_string_scalar.data(), static_cast<std::size_t>(d_string_scalar.size())},
d_col_strings,
size,
string_offset.size(),
stream);

EXPECT_EQ(res_type, cudf::data_type{cudf::type_id::STRING});
Expand All @@ -179,9 +175,8 @@ TEST_F(TypeInference, Bool)
auto d_data = cudf::make_string_scalar(data);
auto& d_string_scalar = static_cast<cudf::string_scalar&>(*d_data);

std::size_t constexpr size = 3;
auto const string_offset = std::vector<int32_t>{1, 6, 12};
auto const string_length = std::vector<std::size_t>{4, 5, 5};
auto const string_offset = std::vector<int32_t>{1, 6, 12};
auto const string_length = std::vector<std::size_t>{4, 5, 5};
rmm::device_vector<int32_t> d_string_offset{string_offset};
rmm::device_vector<std::size_t> d_string_length{string_length};

Expand All @@ -192,7 +187,7 @@ TEST_F(TypeInference, Bool)
infer_data_type(options.json_view(),
{d_string_scalar.data(), static_cast<std::size_t>(d_string_scalar.size())},
d_col_strings,
size,
string_offset.size(),
stream);

EXPECT_EQ(res_type, cudf::data_type{cudf::type_id::BOOL8});
Expand All @@ -211,9 +206,8 @@ TEST_F(TypeInference, Timestamp)
auto d_data = cudf::make_string_scalar(data);
auto& d_string_scalar = static_cast<cudf::string_scalar&>(*d_data);

std::size_t constexpr size = 3;
auto const string_offset = std::vector<int32_t>{1, 10};
auto const string_length = std::vector<std::size_t>{8, 9};
auto const string_offset = std::vector<int32_t>{1, 10};
auto const string_length = std::vector<std::size_t>{8, 9};
rmm::device_vector<int32_t> d_string_offset{string_offset};
rmm::device_vector<std::size_t> d_string_length{string_length};

Expand All @@ -224,7 +218,7 @@ TEST_F(TypeInference, Timestamp)
infer_data_type(options.json_view(),
{d_string_scalar.data(), static_cast<std::size_t>(d_string_scalar.size())},
d_col_strings,
size,
string_offset.size(),
stream);

// All data time (quoted and unquoted) is inferred as string for now
Expand All @@ -244,9 +238,8 @@ TEST_F(TypeInference, InvalidInput)
auto d_data = cudf::make_string_scalar(data);
auto& d_string_scalar = static_cast<cudf::string_scalar&>(*d_data);

std::size_t constexpr size = 5;
auto const string_offset = std::vector<int32_t>{1, 3, 5, 7, 9};
auto const string_length = std::vector<std::size_t>{1, 1, 1, 1, 1};
auto const string_offset = std::vector<int32_t>{1, 3, 5, 7, 9};
auto const string_length = std::vector<std::size_t>{1, 1, 1, 1, 1};
rmm::device_vector<int32_t> d_string_offset{string_offset};
rmm::device_vector<std::size_t> d_string_length{string_length};

Expand All @@ -257,7 +250,7 @@ TEST_F(TypeInference, InvalidInput)
infer_data_type(options.json_view(),
{d_string_scalar.data(), static_cast<std::size_t>(d_string_scalar.size())},
d_col_strings,
size,
string_offset.size(),
stream);

// Invalid input is inferred as string for now
Expand Down

0 comments on commit 8b5ab23

Please sign in to comment.