-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
to_arrow_device
function to cudf interop using nanoarrow (#15047)
Introduce new `to_arrow_device` and `to_arrow_schema` functions to utilize the `ArrowDeviceArray` structure for zero-copy passing of libcudf::table. Add nanoarrow as a vendored lib and a script to update it. Initial step towards addressing #14926 Authors: - Matt Topol (https://github.com/zeroshade) - Vyas Ramasubramani (https://github.com/vyasr) - David Wendt (https://github.com/davidwendt) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - David Wendt (https://github.com/davidwendt) URL: #15047
- Loading branch information
Showing
9 changed files
with
1,882 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# ============================================================================= | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License | ||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. See the License for the specific language governing permissions and limitations under | ||
# the License. | ||
# ============================================================================= | ||
|
||
# This function finds nanoarrow and sets any additional necessary environment variables. | ||
function(find_and_configure_nanoarrow) | ||
set(oneValueArgs VERSION FORK PINNED_TAG) | ||
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
rapids_cpm_find( | ||
nanoarrow ${PKG_VERSION} | ||
GLOBAL_TARGETS nanoarrow | ||
CPM_ARGS | ||
GIT_REPOSITORY https://github.com/${PKG_FORK}/arrow-nanoarrow.git | ||
GIT_TAG ${PKG_PINNED_TAG} | ||
# TODO: Commit hashes are not supported with shallow clones. Can switch this if and when we pin | ||
# to an actual tag. | ||
GIT_SHALLOW FALSE | ||
OPTIONS "BUILD_SHARED_LIBS OFF" "NANOARROW_NAMESPACE cudf" | ||
) | ||
set_target_properties(nanoarrow PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
endfunction() | ||
|
||
find_and_configure_nanoarrow( | ||
VERSION 0.4.0 FORK apache PINNED_TAG c97720003ff863b81805bcdb9f7c91306ab6b6a8 | ||
) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <nanoarrow/nanoarrow.hpp> | ||
|
||
// from Arrow C Device Data Interface | ||
// https://arrow.apache.org/docs/format/CDeviceDataInterface.html | ||
#ifndef ARROW_C_DEVICE_DATA_INTERFACE | ||
#define ARROW_C_DEVICE_DATA_INTERFACE | ||
|
||
// Device type for the allocated memory | ||
typedef int32_t ArrowDeviceType; | ||
|
||
// CPU device, same as using ArrowArray directly | ||
#define ARROW_DEVICE_CPU 1 | ||
// CUDA GPU Device | ||
#define ARROW_DEVICE_CUDA 2 | ||
// Pinned CUDA CPU memory by cudaMallocHost | ||
#define ARROW_DEVICE_CUDA_HOST 3 | ||
// CUDA managed/unified memory allocated by cudaMallocManaged | ||
#define ARROW_DEVICE_CUDA_MANAGED 13 | ||
|
||
struct ArrowDeviceArray { | ||
struct ArrowArray array; | ||
int64_t device_id; | ||
ArrowDeviceType device_type; | ||
void* sync_event; | ||
|
||
// reserved bytes for future expansion | ||
int64_t reserved[3]; | ||
}; | ||
|
||
#endif // ARROW_C_DEVICE_DATA_INTERFACE |
Oops, something went wrong.