[Part 3] [ORC-timezone]: GPU kernel for DST-aware timezone conversion#4733
Open
res-life wants to merge 4 commits into
Open
[Part 3] [ORC-timezone]: GPU kernel for DST-aware timezone conversion#4733res-life wants to merge 4 commits into
res-life wants to merge 4 commits into
Conversation
Part 3 of NVIDIA#4432. Adds the CUDA implementation that computes ORC writer/reader timezone conversions with Daylight Saving Time support. No production behavior change: the Java DST gate in GpuTimeZoneDB.convertOrcTimezones still throws and no Java/JNI changes are included, so the DST capability is unreachable from production. The pre-existing non-DST ORC path is behavior-preserving -- it now routes through the new kernel via a backward-compatible overload. - timezones.hpp: add `struct dst_rule` (SimpleTimeZone-shaped DST descriptor consumed by the kernel) and a DST-capable `convert_orc_writer_reader_timezones` overload. - timezones.cu: civil-calendar / DST-offset device helpers (is_leap_year, days_*, compute_rule_day, compute_transition_utc_ms, millis_to_year, compute_dst_offset, get_transition_index, is_fixed_offset_tz), a shared-memory conversion kernel, and the DST-capable host launcher. A backward-compatible 5-arg overload of convert_orc_writer_reader_timezones forwards to the new path with has_dst=false and initial_offset=raw_offset, which reproduces the legacy non-DST behavior exactly (the only old/new divergence is the before-first-transition branch), so existing callers (the JNI binding and C++ tests) are unaffected. - tests/timezones.cpp: add ConvertOrcTimezonesReaderDstBeyondTable and ConvertOrcTimezonesSameDstZoneIsIdentity covering the DST math, and preserve the existing floor-division regression tests. Signed-off-by: Chong Gao <res_life@163.com>
Collaborator
Author
|
build |
1 similar comment
Collaborator
Author
|
build |
Signed-off-by: Chong Gao <res_life@163.com>
Collaborator
Author
|
build |
Signed-off-by: Chong Gao <res_life@163.com>
Collaborator
Author
|
build |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the CUDA-side implementation needed for DST-aware ORC writer↔reader timestamp timezone conversion (SimpleTimeZone semantics), while keeping the existing non-DST behavior available via a backward-compatible overload and extending C++ test coverage for the new DST logic.
Changes:
- Introduces
dst_ruleand a DST-capableconvert_orc_writer_reader_timezonesoverload (includingbase_offset_usand per-sideinitial_offset). - Implements GPU calendar/DST helpers plus a shared-memory conversion kernel + launcher, with NVTX ranges and CUDA launch error checking.
- Adds new C++ tests covering DST behavior beyond transition tables, identity conversion, base-offset fusion, and all SimpleTimeZone rule modes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/main/cpp/src/timezones.hpp |
Adds dst_rule and new DST-capable ORC conversion API + backward-compatible overload; minor doc fix and includes. |
src/main/cpp/src/timezones.cu |
Implements GPU DST/calendar logic, shared-memory conversion kernel, launcher instrumentation, and overload forwarding. |
src/main/cpp/tests/timezones.cpp |
Adds targeted tests for DST rule evaluation, rule modes, identity behavior, and base offset handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Signed-off-by: Chong Gao <res_life@163.com>
Collaborator
Author
|
Addressed the remaining review feedback in
The remaining inline review threads have been replied to and resolved. |
Collaborator
Author
|
build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Part 3 of the split of #4432 (full ORC DST GPU support). Part 1 (#4539, runtime build of
OrcTimezoneInfo) and Part 2 (#4635, Java-side DST rule extraction) are merged. This PR adds the CUDA implementation that converts ORC writer/reader timestamps with Daylight Saving Time support. It does not wire DST into the production dispatch path — production behavior is unchanged.What this adds
In
timezones.hpp:struct dst_rule— a SimpleTimeZone-shaped DST descriptor (raw/dst offsets, start/end month/day/dayOfWeek/time/mode) consumed by the GPU kernel. Field layout mirrors the JavaOrcDstRuleExtractor.DstRule(0-based month; dayOfWeek 1=Sun..7=Sat; mode 0=DOM/1=DOW_IN_MONTH/2=DOW_GE_DOM/3=DOW_LE_DOM; timeMode 0=WALL/1=STANDARD/2=UTC).convert_orc_writer_reader_timezonesoverload (addsbase_offset_us, per-sideinitial_offsetanddst_rule).In
timezones.cu:is_leap_year,days_in_month,days_before_month,days_from_epoch_to_year,compute_rule_day,compute_transition_utc_ms,millis_to_year,compute_dst_offset,get_transition_index,is_fixed_offset_tz. These implementSimpleTimeZone.getOffset()semantics for dates beyond the historical transition table.convert_orc_writer_reader_timezonesthat forwards to the new path withhas_dst=falseandinitial_offset=raw_offset. This reproduces the legacy non-DST behavior exactly (the only old/new divergence is the before-first-transition branch, which the mapping pins), so existing callers — the JNI binding and C++ tests — are unaffected.In
tests/timezones.cpp:ConvertOrcTimezonesReaderDstBeyondTable— fixed-UTC writer, US-style DST reader with no transition table; a winter instant is unchanged, a summer instant shifts back one hour.ConvertOrcTimezonesSameDstZoneIsIdentity— converting a DST zone to itself is the identity for both standard and daylight instants.ConvertOrcTimezonesAppliesBaseOffset— covers non-zerobase_offset_usfor both fixed-offset and transition-table paths.ConvertOrcTimezonesDstRuleModes— covers allSimpleTimeZonerule modes (DOM, positive/negativeDOW_IN_MONTH,DOW_GE_DOM,DOW_LE_DOM) plus normalized adjacent-month boundary behavior.Review follow-up
SRJ_FUNC_RANGE()coverage through the sharedconvert_timezoneslauncher and includednvtx_ranges.hpp.CUDF_CHECK_CUDA(stream.value())after the raw CUDA kernel launch.java.util.SimpleTimeZonebehavior and kept normalized-calendar semantics covered by tests.What this does not change
GpuTimeZoneDB.convertOrcTimezones— DST gate still throwsUnsupportedOperationExceptionfor DST zones.Verification
git diff --checkDiff size
+857 / -191across 3 files:timezones.cu+682 / -178timezones.hpp+102 / -13tests/timezones.cpp+264Follow-up parts
DstRuleserialization +GpuTimeZoneDBhost-side assembly of transition tables /dst_ruleand the JNI binding (still gated — no behavior change).convertOrcTimezones, dispatch DST zones through the kernel, add end-to-end Java tests. This is the only follow-up part that changes runtime behavior.