Skip to content

Commit

Permalink
apacheGH-36449: [CI][Python] Fix GDB tests in test-cuda-python
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Jul 4, 2023
1 parent e7d5028 commit 573183c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 2 additions & 0 deletions ci/scripts/cpp_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ elif [ -x "$(command -v xcrun)" ]; then
export ARROW_GANDIVA_PC_CXX_FLAGS="-isysroot;$(xcrun --show-sdk-path)"
fi

# Reduce size of object files and libraries on CI platforms.
# ARROW_GDB=ON can be used to override this behaviour.
if [ "${GITHUB_ACTIONS:-false}" = "true" ]; then
case "$(uname)" in
Linux|Darwin|MINGW*)
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ services:
ARROW_FILESYSTEM: "ON"
ARROW_GANDIVA: "OFF"
ARROW_GCS: "OFF"
ARROW_GDB: "ON" # Override -g1 for test_gdb.py
ARROW_HDFS: "ON"
ARROW_JEMALLOC: "ON"
ARROW_JSON: "ON"
Expand Down
22 changes: 12 additions & 10 deletions python/pyarrow/tests/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,27 +349,29 @@ def test_HostBuffer(size):

@pytest.mark.parametrize("size", [0, 1, 1000])
def test_copy_from_to_host(size):

# Create a buffer in host containing range(size)
buf = pa.allocate_buffer(size, resizable=True) # in host
dt = np.dtype('uint16')
nbytes = size * dt.itemsize
buf = pa.allocate_buffer(nbytes, resizable=True) # in host
assert isinstance(buf, pa.Buffer)
assert not isinstance(buf, cuda.CudaBuffer)
arr = np.frombuffer(buf, dtype=np.uint8)
arr = np.frombuffer(buf, dtype=dt)
assert arr.size == size
arr[:] = range(size)
arr_ = np.frombuffer(buf, dtype=np.uint8)
arr_ = np.frombuffer(buf, dtype=dt)
np.testing.assert_equal(arr, arr_)

device_buffer = global_context.new_buffer(size)
# Create a device buffer of the same size and copy from host
device_buffer = global_context.new_buffer(nbytes)
assert isinstance(device_buffer, cuda.CudaBuffer)
assert isinstance(device_buffer, pa.Buffer)
assert device_buffer.size == size
assert device_buffer.size == nbytes
assert not device_buffer.is_cpu
device_buffer.copy_from_host(buf, position=0, nbytes=nbytes)

device_buffer.copy_from_host(buf, position=0, nbytes=size)

buf2 = device_buffer.copy_to_host(position=0, nbytes=size)
arr2 = np.frombuffer(buf2, dtype=np.uint8)
# Copy back to host and compare contents
buf2 = device_buffer.copy_to_host(position=0, nbytes=nbytes)
arr2 = np.frombuffer(buf2, dtype=dt)
np.testing.assert_equal(arr, arr2)


Expand Down

0 comments on commit 573183c

Please sign in to comment.