From fd2f6a6fd11f9220d999bc32ab2f435fc4bedb48 Mon Sep 17 00:00:00 2001 From: Vukasin Milovanovic Date: Fri, 8 Dec 2023 13:29:03 -0800 Subject: [PATCH] Fix synchronization issue when writing string columns with dictionary to ORC (#14595) Changes in https://github.com/rapidsai/cudf/pull/14295 introduced a synchronization issue in `build_dictionaries`. After stripe_dicts are initialized on the host, we copy them to the device and then launch kernels that read the dicts (device copy). However, after these kernels we deallocate buffers that are not longer needed and clear the dicts' views to these buffers on the host. The problem is that, without synchronization after the H2D copy, the host modification can be done before the H2D copy is performed, and we run the kernels with the altered state. This PR adds a sync point to make sure the copy is done before host-side modification. Authors: - Vukasin Milovanovic (https://github.com/vuule) Approvers: - Nghia Truong (https://github.com/ttnghia) - Alessandro Bellina (https://github.com/abellina) - Bradley Dice (https://github.com/bdice) --- cpp/src/io/orc/writer_impl.cu | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/src/io/orc/writer_impl.cu b/cpp/src/io/orc/writer_impl.cu index ac5993e764e..29661285ed8 100644 --- a/cpp/src/io/orc/writer_impl.cu +++ b/cpp/src/io/orc/writer_impl.cu @@ -2137,7 +2137,8 @@ stripe_dictionaries build_dictionaries(orc_table_view& orc_table, } } } - stripe_dicts.host_to_device_async(stream); + // Synchronize to ensure the copy is complete before we clear `map_slots` + stripe_dicts.host_to_device_sync(stream); gpu::collect_map_entries(stripe_dicts, stream); gpu::get_dictionary_indices(stripe_dicts, orc_table.d_columns, stream);