You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by pa...@apache.org on 2024/06/25 12:58:02 UTC

(arrow-nanoarrow) branch main updated: chore(ci): Add CUDA runner for testing device extension (#490)

This is an automated email from the ASF dual-hosted git repository.

paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 749349d0 chore(ci): Add CUDA runner for testing device extension (#490)
749349d0 is described below

commit 749349d0df8c7deb7e05f72c77548268bbbd78e2
Author: Dewey Dunnington <de...@dunnington.ca>
AuthorDate: Tue Jun 25 12:57:57 2024 +0000

    chore(ci): Add CUDA runner for testing device extension (#490)
    
    This PR adds the INFRA-provided runner `["self-hosted", "cuda"]` so that
    PRs that modify CUDA code get better CI feedback (before this, the
    extension pretty much was only ever built on my local setup).
    
    The self-hosted runner is running an older linux than the usual
    `ubuntu-latest`, so a few modifications were needed to reflect compiler
    warning policies. The cache key we were using for Arrow C++ is also no
    longer sufficient for the device workflow because a cache restore
    results in an unusable Arrow C++ static library on the self-hosted
    runner. This shouldn't be necessary for much longer (just until Arrow
    C++-dependent tests are factored out and run separately).
---
 .github/workflows/build-and-test-device.yaml | 25 ++++++++++++++++++++++++-
 src/nanoarrow/common/inline_buffer.h         |  2 +-
 src/nanoarrow/common/inline_types.h          |  2 +-
 src/nanoarrow/device/cuda_test.cc            |  3 +--
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/build-and-test-device.yaml b/.github/workflows/build-and-test-device.yaml
index 8362bfc7..80941512 100644
--- a/.github/workflows/build-and-test-device.yaml
+++ b/.github/workflows/build-and-test-device.yaml
@@ -47,6 +47,7 @@ jobs:
           - {runner: ubuntu-latest, label: namespaced-build, cmake_args: "-DNANOARROW_NAMESPACE=SomeUserNamespace"}
           - {runner: ubuntu-latest, label: bundled-build, cmake_args: "-DNANOARROW_DEVICE_BUNDLE=ON"}
           - {runner: macOS-latest, label: with-metal, cmake_args: "-DNANOARROW_DEVICE_WITH_METAL=ON"}
+          - {runner: ["self-hosted", "cuda"], label: with-cuda, cmake_args: "-DNANOARROW_DEVICE_WITH_CUDA=ON"}
 
 
     steps:
@@ -57,13 +58,30 @@ jobs:
         run: |
           sudo apt-get update && sudo apt-get install -y valgrind
 
+      # The self-hosted runner for CUDA does not have cmake preinstalled.
+      # We need at least CMake 3.17 for FindCUDAToolkit.
+      - name: Ensure CMake
+        if: matrix.config.label == 'with-cuda'
+        run: |
+          mkdir tmp_cmake && cd tmp_cmake
+          CMAKE_VERSION="3.22.1"
+          curl -L https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz |
+            tar -zxf -
+          CMAKE_PATH=$(find $(pwd) -name "bin")
+          echo "PATH=${CMAKE_PATH}:${PATH}" >> $GITHUB_ENV
+          # Debug install location of cuda toolkit
+          ldconfig -p | grep libcuda
+
       - name: Cache Arrow C++ Build
         id: cache-arrow-build
         uses: actions/cache@v4
         with:
           path: arrow
           # Bump the number at the end of this line to force a new Arrow C++ build
-          key: arrow-${{ runner.os }}-${{ runner.arch }}-1
+          # The self-hosted runner needs its own Arrow build since it is running
+          # a much older linux distribution. When the Arrow C++ requirement for tests is
+          # dropped, we don't have to use this at all as part of the CI configuration.
+          key: arrow-device-${{ runner.os }}-${{ runner.arch }}-${{ matrix.config.label }}-1
 
       - name: Build Arrow C++
         if: steps.cache-arrow-build.outputs.cache-hit != 'true'
@@ -74,8 +92,13 @@ jobs:
       - name: Build
         run: |
           ARROW_PATH="$(pwd)/arrow"
+
+          # Debug arrow includes
+          find "${ARROW_PATH}"
+
           mkdir build
           cd build
+          export VERBOSE=1
           cmake .. -DCMAKE_BUILD_TYPE=Debug -DNANOARROW_DEVICE=ON \
             -DNANOARROW_BUILD_TESTS=ON -DCMAKE_PREFIX_PATH="${ARROW_PATH}" \
             ${{ matrix.config.cmake_args }}
diff --git a/src/nanoarrow/common/inline_buffer.h b/src/nanoarrow/common/inline_buffer.h
index 261cc865..caa6be4a 100644
--- a/src/nanoarrow/common/inline_buffer.h
+++ b/src/nanoarrow/common/inline_buffer.h
@@ -91,7 +91,7 @@ static inline uint16_t ArrowFloatToHalfFloat(float value) {
 
   uint16_t sn = (uint16_t)((u.b >> 31) & 0x1);
   uint16_t exp = (u.b >> 23) & 0xff;
-  int16_t res = (int16_t)exp - 127 + 15;
+  int16_t res = (int16_t)(exp - 127 + 15);
   uint16_t fc = (uint16_t)(u.b >> 13) & 0x3ff;
 
   if (exp == 0) {
diff --git a/src/nanoarrow/common/inline_types.h b/src/nanoarrow/common/inline_types.h
index 68a505fd..015cc541 100644
--- a/src/nanoarrow/common/inline_types.h
+++ b/src/nanoarrow/common/inline_types.h
@@ -882,7 +882,7 @@ static inline void ArrowDecimalInit(struct ArrowDecimal* decimal, int32_t bitwid
   memset(decimal->words, 0, sizeof(decimal->words));
   decimal->precision = precision;
   decimal->scale = scale;
-  decimal->n_words = bitwidth / 8 / sizeof(uint64_t);
+  decimal->n_words = (int)(bitwidth / 8 / sizeof(uint64_t));
 
   if (_ArrowIsLittleEndian()) {
     decimal->low_word_index = 0;
diff --git a/src/nanoarrow/device/cuda_test.cc b/src/nanoarrow/device/cuda_test.cc
index 5ee06396..ee89fa05 100644
--- a/src/nanoarrow/device/cuda_test.cc
+++ b/src/nanoarrow/device/cuda_test.cc
@@ -20,8 +20,7 @@
 #include <gtest/gtest.h>
 #include <tuple>
 
-#include "nanoarrow/nanoarrow_device.h"
-#include "nanoarrow/nanoarrow_device_cuda.h"
+#include "nanoarrow/nanoarrow_device.hpp"
 
 class CudaTemporaryContext {
  public: