Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(extensions/nanoarrow_device): Draft DeviceArray interface #205

Merged
merged 104 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
8dcd72c
sketch device extension
paleolimbot May 25, 2023
76f4e4e
more boilerplate
paleolimbot May 25, 2023
2967b0e
add draft device header
paleolimbot May 25, 2023
1c25735
sketch the ArrowDevice
paleolimbot May 25, 2023
76fc7ca
cpu methods
paleolimbot May 26, 2023
30090ac
always set error on return
paleolimbot May 26, 2023
c4b6176
stream wrapper implementation
paleolimbot May 26, 2023
a335660
symbol namespace
paleolimbot May 26, 2023
bd839cc
add hpp and scaffold test
paleolimbot May 26, 2023
41b1a02
test stream wrapper
paleolimbot May 26, 2023
89467c7
some ci, docs for device extension
paleolimbot May 26, 2023
13ffc7f
fix for doc changes
paleolimbot May 26, 2023
465535b
more CI
paleolimbot May 26, 2023
826a9fc
maybe fix bundling
paleolimbot May 26, 2023
69d101a
maybe release callback on the device
paleolimbot May 26, 2023
1a42008
maybe namespaces
paleolimbot May 26, 2023
ccadd50
basic dummy non-cpu tests
paleolimbot May 26, 2023
01fa32b
hpp helper for now-releaseable device
paleolimbot May 26, 2023
c085e94
sketch metal impl sources
paleolimbot May 26, 2023
6975479
add metal helper
paleolimbot May 26, 2023
9e668de
CMake shenanegins for metal to work
paleolimbot May 26, 2023
362cf43
linking but can't find the default device
paleolimbot May 26, 2023
862c7b9
whee! linking QuartzCore did it!
paleolimbot May 26, 2023
ca92264
add test for ID
paleolimbot May 26, 2023
c926bbe
metal buffers
paleolimbot May 27, 2023
60d27af
better name for function
paleolimbot May 27, 2023
fee9b10
check array append
paleolimbot May 27, 2023
70d20fc
more array + buffer stuff
paleolimbot May 27, 2023
bd38810
better names
paleolimbot May 30, 2023
7a45ee1
better name for existing bufer initializer
paleolimbot May 30, 2023
8764621
add some more buffery methods
paleolimbot May 30, 2023
6a98943
test cpu buffer
paleolimbot May 31, 2023
fb54565
sketch metal buffer mover
paleolimbot May 31, 2023
c8142d2
redo buffer copiers again
paleolimbot May 31, 2023
b2e7731
document some Metal weirdness
paleolimbot May 31, 2023
cd5240c
more doc
paleolimbot May 31, 2023
4797c4c
with build
paleolimbot May 31, 2023
38f3b21
fix test
paleolimbot May 31, 2023
246a496
with passing buffer tests
paleolimbot May 31, 2023
827369f
maybe fix namespace
paleolimbot May 31, 2023
631fb7c
with test demo for mem alignment
paleolimbot May 31, 2023
c912bae
maybe refactor just using really good alignment
paleolimbot May 31, 2023
5290477
with passing tests!
paleolimbot May 31, 2023
b078f52
while I still remember that there's an offset
paleolimbot May 31, 2023
a1f0ce6
sketch array set/validate
paleolimbot Jun 2, 2023
4ef6fc2
in theory, device array view setter
paleolimbot Jun 2, 2023
eabdc36
namespace
paleolimbot Jun 2, 2023
d1bb488
test array view array setting
paleolimbot Jun 2, 2023
c3a6af5
test list types
paleolimbot Jun 2, 2023
419c193
unique device array view
paleolimbot Jun 2, 2023
6a7996b
doc updates
paleolimbot Jun 2, 2023
80a74b1
sketch hypothetical do-we-need-to-copy calculator
paleolimbot Jun 2, 2023
95566d2
sketch array copier
paleolimbot Jun 2, 2023
7df024c
namespace attempt
paleolimbot Jun 2, 2023
d9912da
test copiers on cpu
paleolimbot Jun 2, 2023
ecc00b3
testing device copier/mover for another device
paleolimbot Jun 2, 2023
70f92ee
maybe get metal initializer to work
paleolimbot Jun 2, 2023
34bf098
fix crash
paleolimbot Jun 2, 2023
303ea13
maybe fix namespace
paleolimbot Jun 2, 2023
f7c41ce
maybe fix leak
paleolimbot Jun 2, 2023
776166f
nix the sync event since no backend actually copies memory that way
paleolimbot Jun 2, 2023
1a996e6
add CUDA extension
paleolimbot Jun 6, 2023
bf30825
sketch synchronize
paleolimbot Jun 7, 2023
73bb87e
sketch more buffer copiers
paleolimbot Jun 7, 2023
223f054
maybe initializers
paleolimbot Jun 7, 2023
9276f9f
maybe working copiers
paleolimbot Jun 7, 2023
406181e
passing buffer init test
paleolimbot Jun 9, 2023
2f786d6
passing buffer init
paleolimbot Jun 9, 2023
2015e84
buffer copy cuda test
paleolimbot Jun 9, 2023
1c846f6
sketch array copy tests
paleolimbot Jun 9, 2023
9001057
passing array copy tests
paleolimbot Jun 9, 2023
d8a0182
passing string copy test
paleolimbot Jun 9, 2023
daa98df
test with CUDA_HOST, too
paleolimbot Jun 9, 2023
efc0de5
test roundtrip of list
paleolimbot Jun 9, 2023
39ff3f8
also test CUDA_HOST
paleolimbot Jun 9, 2023
a20a63c
support dictionary
paleolimbot Jun 9, 2023
33d6d28
flatten metal implementation into one folder
paleolimbot Jun 9, 2023
573e182
add some tests that would have failed before the cuda implementation
paleolimbot Jun 9, 2023
5be1258
Update extensions/nanoarrow_device/CMakeLists.txt
paleolimbot Jun 12, 2023
8406b40
use updated device interface
paleolimbot Jun 20, 2023
c33e064
simplify synchronize_event
paleolimbot Jun 20, 2023
8119476
fix one more sync reference
paleolimbot Jun 20, 2023
2cacb3b
assume pointer arithmetic and remove ArrowDeviceBuffer
paleolimbot Jun 20, 2023
8d6666d
add minimal version of setarray
paleolimbot Jun 20, 2023
fee2a83
start on cuda-specific device with event memory
paleolimbot Jun 20, 2023
c89566a
passing tests
paleolimbot Jun 21, 2023
a78c3a4
use cudaMemcpyHostToHost
paleolimbot Jun 21, 2023
16d51fd
use the bufferdeallocator pattern
paleolimbot Jun 21, 2023
e50344a
theoretically handle more than one device
paleolimbot Jun 21, 2023
b8e714f
be even lazier about resolving buffer sizes
paleolimbot Jun 21, 2023
973ac50
typo
paleolimbot Jun 21, 2023
99a15f9
always make the array move/copy distinction explicit
paleolimbot Jun 21, 2023
56658bb
start on new array move
paleolimbot Jun 21, 2023
9952fa9
implement the cuda mover
paleolimbot Jun 21, 2023
5a6f388
maybe use new copier for CUDA
paleolimbot Jun 21, 2023
0f97256
fix metal build
paleolimbot Jun 21, 2023
5810495
remove copy_required and old array mover
paleolimbot Jun 21, 2023
f41e8fd
maybe start on event handling with metal
paleolimbot Jun 21, 2023
c1f98b4
theoretically create the event for the proper device
paleolimbot Jun 22, 2023
b2f3b9b
use static lib for now
paleolimbot Jun 22, 2023
8ad1925
more cudaMemcpy
paleolimbot Jun 22, 2023
e6ca953
add README
paleolimbot Jun 22, 2023
9d78b5d
add a comment about sync order
paleolimbot Jun 22, 2023
3b5ee6c
RAT for readme
paleolimbot Jun 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/build-and-test-device.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

name: test-c-device

on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- 'CMakeLists.txt'
- '.github/workflows/build-and-test-device.yaml'
- 'src/nanoarrow/**'
- 'extensions/nanoarrow_device/**'

jobs:
test-c-device:

runs-on: ubuntu-latest

name: ${{ matrix.config.label }}

strategy:
fail-fast: false
matrix:
config:
- {label: default-build}
- {label: namespaced-build, cmake_args: "-DNANOARROW_NAMESPACE=SomeUserNamespace"}
- {label: bundled-build, cmake_args: "-DNANOARROW_DEVICE_BUNDLE=ON"}

env:
SUBDIR: 'extensions/nanoarrow_device'
NANOARROW_ARROW_TESTING_DIR: '${{ github.workspace }}/arrow-testing'

steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Checkout arrow-testing
uses: actions/checkout@v3
with:
repository: apache/arrow-testing
fetch-depth: 0
path: arrow-testing

- name: Install dependencies
run: |
sudo apt-get update
sudo apt install -y -V ca-certificates lsb-release wget cmake valgrind
wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt-get install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
sudo apt-get update
sudo apt-get install -y -V libarrow-dev
rm apache-arrow-apt-*.deb

- name: Build
run: |
cd $SUBDIR
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/dist/lib
sudo ldconfig
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DNANOARROW_DEVICE_BUILD_TESTS=ON ${{ matrix.config.cmake_args }}
cmake --build .

- name: Check for non-namespaced symbols in namespaced build
if: matrix.config.label == 'namespaced-build'
run: |
cd $SUBDIR

# Dump all symbols
nm --extern-only build/libnanoarrow_device.a

# Check for non-namespaced ones
ARROW_SYMBOLS=`nm --extern-only build/libnanoarrow_device.a | grep "T Arrow" || true`
if [ -z "$ARROW_SYMBOLS" ]; then
exit 0
fi

echo "Found the following non-namespaced extern symbols:"
echo $ARROW_SYMBOLS
exit 1

- name: Run tests
run: |
cd $SUBDIR

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/dist/lib
sudo ldconfig
cd build
ctest -T test --output-on-failure .

- name: Run tests with valgrind
if: matrix.config.label == 'default-build' || matrix.config.label == 'default-noatomics'
run: |
cd $SUBDIR

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/dist/lib
sudo ldconfig
cd build
ctest -T memcheck .

- name: Upload memcheck results
if: failure() && matrix.config.label == 'default-build'
uses: actions/upload-artifact@main
with:
name: nanoarrow-device-memcheck
path: extensions/nanoarrow_device/build/Testing/Temporary/MemoryChecker.*.log
8 changes: 8 additions & 0 deletions .github/workflows/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ jobs:
cmake --build .
cmake --install . --prefix=../../../nanoarrow-latest

- name: Bundle nanoarrow_device
run: |
cd extensions/nanoarrow_device
mkdir build && cd build
cmake .. -DNANOARROW_DEVICE_BUNDLE=ON
cmake --build .
cmake --install . --prefix=../../../nanoarrow-latest

- name: Compress bundle
run: |
zip nanoarrow-latest.zip $(find nanoarrow-latest -type f)
Expand Down
7 changes: 5 additions & 2 deletions ci/scripts/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,21 @@ main() {
rm -rf docs/_build
mkdir -p docs/_build

# Run doxygen
show_header "Run Doxygen for C library"
pushd src/apidoc
doxygen
popd

# Run doxygen
show_header "Run Doxygen for IPC extension"
pushd extensions/nanoarrow_ipc/src/apidoc
doxygen
popd

show_header "Run Doxygen for device extension"
pushd extensions/nanoarrow_device/src/apidoc
doxygen
popd

pushd docs

show_header "Build Sphinx project"
Expand Down
14 changes: 14 additions & 0 deletions ci/scripts/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ function main() {

pushd "${SANDBOX_DIR}"

# Build + run tests with gcov for device extension
show_header "Build + test nanoarrow_device"
mkdir "${SANDBOX_DIR}/nanoarrow_device"
pushd "${SANDBOX_DIR}/nanoarrow_device"

cmake "${TARGET_NANOARROW_DIR}/extensions/nanoarrow_device" \
-DNANOARROW_DEVICE_BUILD_TESTS=ON -DNANOARROW_DEVICE_CODE_COVERAGE=ON
cmake --build .
ctest .

popd

pushd "${SANDBOX_DIR}"

# Generate coverage.info file for both cmake projects using lcov
show_header "Calculate CMake project coverage"
lcov --capture --directory . \
Expand Down
7 changes: 3 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
# Breathe configuration
breathe_projects = {
"nanoarrow_c": "../../src/apidoc/xml",
"nanoarrow_ipc": "../../extensions/nanoarrow_ipc/src/apidoc/xml"
"nanoarrow_ipc": "../../extensions/nanoarrow_ipc/src/apidoc/xml",
"nanoarrow_device": "../../extensions/nanoarrow_device/src/apidoc/xml"
}
breathe_default_project = "nanoarrow_c"

Expand All @@ -75,9 +76,7 @@
html_theme_options = {
"show_toc_level": 2,
"use_edit_page_button": True,
"external_links": [
{"name": "R Package", "url": "r/index.html"},
],
"external_links": [],
}

html_context = {
Expand Down
4 changes: 1 addition & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ Contents
:maxdepth: 2

Getting Started <getting-started>
C API Reference <c>
C++ API Reference <cpp>
IPC Extension Reference <ipc>
API Reference <reference/index>
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions docs/source/reference/device.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.. Licensed to the Apache Software Foundation (ASF) under one
.. or more contributor license agreements. See the NOTICE file
.. distributed with this work for additional information
.. regarding copyright ownership. The ASF licenses this file
.. to you 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.

Device Extension Reference
==========================

C API
------------------------

.. doxygengroup:: nanoarrow_device
:project: nanoarrow_device
:members:

C++ Helpers
------------------------

.. doxygengroup:: nanoarrow_device_hpp-unique
:project: nanoarrow_device
:members:

Arrow C Device Interface
------------------------

.. doxygengroup:: nanoarrow_device-arrow-cdata
:project: nanoarrow_device
:members:
:undoc-members:

.. doxygengroup:: arrow-device-types
:project: nanoarrow_device
:members:
:undoc-members:
28 changes: 28 additions & 0 deletions docs/source/reference/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. Licensed to the Apache Software Foundation (ASF) under one
.. or more contributor license agreements. See the NOTICE file
.. distributed with this work for additional information
.. regarding copyright ownership. The ASF licenses this file
.. to you 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.

API Reference
=============

.. toctree::
:maxdepth: 2

R API Reference <r>
C API Reference <c>
C++ API Reference <cpp>
IPC Extension Reference <ipc>
Device Extension Reference <device>
File renamed without changes.
21 changes: 21 additions & 0 deletions docs/source/reference/r.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. Licensed to the Apache Software Foundation (ASF) under one
.. or more contributor license agreements. See the NOTICE file
.. distributed with this work for additional information
.. regarding copyright ownership. The ASF licenses this file
.. to you 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.

R API Reference
==================

See `R Documentation <../r/reference/index.html>`__.
18 changes: 18 additions & 0 deletions extensions/nanoarrow_device/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

dist/
Loading