Skip to content

Commit

Permalink
Remove unneeded includes from cudf::string_view headers (#8594)
Browse files Browse the repository at this point in the history
This PR removes some unnecessary include statements from `string_view.hpp` and `string_view.cuh`. It also includes a `#ifdef` to help re-use this class in the https://github.com/rapidsai/strings_udf repo to avoid maintaining a separate string-view class that can be NVRTC compiled with https://github.com/NVIDIA/jitify.

Also removing the `VARIABLE_CHAR_WIDTH` constant which is no longer needed and should've been removed in a previous PR.

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

Approvers:
  - Devavret Makkar (https://github.com/devavret)
  - Mike Wilson (https://github.com/hyperbolic2346)

URL: #8594
  • Loading branch information
davidwendt authored Jun 29, 2021
1 parent 5ff663a commit e6a0fe3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
16 changes: 14 additions & 2 deletions cpp/include/cudf/strings/string_view.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
#pragma once

#include <cudf/strings/string_view.hpp>

#ifndef __CUDA_ARCH__
#include <cudf/utilities/error.hpp>
#endif

// This is defined when including this header in a https://github.com/NVIDIA/jitify
// or jitify2 source file. The jitify cannot include thrust headers at this time.
#ifndef CUDF_JIT_UDF
#include <thrust/count.h>
#include <thrust/find.h>
#include <cstdlib>
#endif

// This file should only include device code logic.
// Host-only or host/device code should be defined in the string_view.hpp header file.
Expand All @@ -41,8 +46,15 @@ __device__ inline size_type characters_in_string(const char* str, size_type byte
{
if ((str == 0) || (bytes == 0)) return 0;
auto ptr = reinterpret_cast<uint8_t const*>(str);
#ifndef CUDF_JIT_UDF
return thrust::count_if(
thrust::seq, ptr, ptr + bytes, [](uint8_t chr) { return is_begin_utf8_char(chr); });
#else
size_type chars = 0;
auto const end = ptr + bytes;
while (ptr < end) { chars += is_begin_utf8_char(*ptr++); }
return chars;
#endif
}

/**
Expand Down
9 changes: 1 addition & 8 deletions cpp/include/cudf/strings/string_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
*/
#pragma once

#include <cuda_runtime.h>
#include <cstddef>
#include <cudf/types.hpp>

#include <iterator>

/**
Expand All @@ -36,12 +35,6 @@ using char_utf8 = uint32_t; ///< UTF-8 characters are 1-4 bytes
*/
constexpr cudf::size_type UNKNOWN_STRING_LENGTH{-1};

/**
* @brief This value is assigned to the _char_width member if the string
* contains characters of different widths.
*/
constexpr int8_t VARIABLE_CHAR_WIDTH{0};

/**
* @brief A non-owning, immutable view of device data that is a variable length
* char array representing a UTF-8 string.
Expand Down

0 comments on commit e6a0fe3

Please sign in to comment.