Skip to content

Commit

Permalink
rename reclass_span reclass_range
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwendt committed Jun 6, 2022
1 parent 9432582 commit f11ebe1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions cpp/src/strings/regex/regcomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ class regex_parser {
}

// transform pairs of literals to spans
std::vector<reclass_span> spans;
std::vector<reclass_range> spans;
auto const evens = thrust::make_transform_iterator(thrust::make_counting_iterator(0),
[](auto i) { return i * 2; });
std::transform(
evens, evens + (literals.size() / 2), std::back_inserter(spans), [&literals](auto idx) {
return reclass_span{literals[idx], literals[idx + 1]};
return reclass_range{literals[idx], literals[idx + 1]};
});
// sort the spans to help with detecting overlapping entries
std::sort(spans.begin(), spans.end(), [](auto l, auto r) {
Expand All @@ -268,7 +268,7 @@ class regex_parser {
auto const curr = *itr;
if (curr.first <= prev.last + 1) {
// if these 2 spans intersect, expand the current one
*itr = reclass_span{prev.first, std::max(prev.last, curr.last)};
*itr = reclass_range{prev.first, std::max(prev.last, curr.last)};
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/strings/regex/regcomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum InstType {
/**
* @brief Range used for literals in reclass classes.
*/
struct reclass_span {
struct reclass_range {
char32_t first{}; /// first character in span
char32_t last{}; /// last character in span (inclusive)
};
Expand All @@ -60,10 +60,10 @@ struct reclass_span {
*/
struct reclass {
int32_t builtins{0}; // bit mask identifying builtin classes
std::vector<reclass_span> literals;
std::vector<reclass_range> literals;
reclass() {}
reclass(int m) : builtins(m) {}
reclass(int m, std::vector<reclass_span>&& l) : builtins(m), literals(std::move(l)) {}
reclass(int m, std::vector<reclass_range>&& l) : builtins(m), literals(std::move(l)) {}
};

constexpr int32_t CCLASS_W{1 << 0}; // [a-z], [A-Z], [0-9], and '_'
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/strings/regex/regex.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ constexpr int32_t MINIMUM_THREADS = 256; // Minimum threads for computing w
struct alignas(16) reclass_device {
int32_t builtins{};
int32_t count{};
reclass_span const* literals{};
reclass_range const* literals{};

__device__ inline bool is_match(char32_t const ch, uint8_t const* flags) const;
};
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/strings/regex/regex.inl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ __device__ __forceinline__ void reprog_device::store(void* buffer) const
auto classes = reinterpret_cast<reclass_device*>(ptr);
result->_classes = classes;
// fill in each class
auto d_ptr = reinterpret_cast<reclass_span*>(classes + _classes_count);
auto d_ptr = reinterpret_cast<reclass_range*>(classes + _classes_count);
for (int idx = 0; idx < _classes_count; ++idx) {
classes[idx] = _classes[idx];
classes[idx].literals = d_ptr;
Expand Down
10 changes: 5 additions & 5 deletions cpp/src/strings/regex/regexec.cu
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ std::unique_ptr<reprog_device, std::function<void(reprog_device*)>> reprog_devic
h_prog.classes_data() + h_prog.classes_count(),
classes_count * sizeof(_classes[0]),
std::plus<std::size_t>{},
[&h_prog](auto& cls) { return cls.literals.size() * sizeof(reclass_span); });
[&h_prog](auto& cls) { return cls.literals.size() * sizeof(reclass_range); });
// make sure each section is aligned for the subsequent section's data type
auto const memsize = cudf::util::round_up_safe(insts_size, sizeof(_startinst_ids[0])) +
cudf::util::round_up_safe(startids_size, sizeof(_classes[0])) +
Expand Down Expand Up @@ -112,11 +112,11 @@ std::unique_ptr<reprog_device, std::function<void(reprog_device*)>> reprog_devic
auto h_class = h_prog.class_at(idx);
reclass_device d_class{h_class.builtins,
static_cast<int32_t>(h_class.literals.size()),
reinterpret_cast<reclass_span*>(d_end)};
reinterpret_cast<reclass_range*>(d_end)};
*classes++ = d_class;
memcpy(h_end, h_class.literals.data(), h_class.literals.size() * sizeof(reclass_span));
h_end += h_class.literals.size() * sizeof(reclass_span);
d_end += h_class.literals.size() * sizeof(reclass_span);
memcpy(h_end, h_class.literals.data(), h_class.literals.size() * sizeof(reclass_range));
h_end += h_class.literals.size() * sizeof(reclass_range);
d_end += h_class.literals.size() * sizeof(reclass_range);
}

// initialize the rest of the elements
Expand Down

0 comments on commit f11ebe1

Please sign in to comment.