Skip to content

Commit dc5081c

Browse files
committed
GH-46165: [C++] Add cuda option to Meson configuration
1 parent 417df28 commit dc5081c

6 files changed

Lines changed: 98 additions & 1 deletion

File tree

ci/docker/conda-cpp.dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ RUN mamba install -q -y \
3838
doxygen \
3939
libnuma \
4040
mold \
41+
nvidia::cuda \
42+
nvidia::cuda-toolkit \
4143
python=${python} \
4244
valgrind && \
4345
mamba clean --all --yes

ci/scripts/cpp_build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ if [ "${ARROW_USE_MESON:-OFF}" = "ON" ]; then
139139
fi
140140
fi
141141
fi
142+
143+
export CUDA_PATH="${CONDA_PREFIX}"
144+
env
142145
meson setup \
143146
--prefix=${MESON_PREFIX:-${ARROW_HOME}} \
144147
--buildtype=${ARROW_BUILD_TYPE:-debug} \

cpp/meson.build

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,15 @@ needs_filesystem = get_option('filesystem').enabled() or needs_azure or needs_gc
6262
needs_integration = get_option('integration').enabled()
6363
needs_tests = get_option('tests').enabled()
6464
needs_acero = get_option('acero').enabled()
65+
needs_cuda = get_option('cuda').enabled()
6566
needs_flight = get_option('flight').enabled()
66-
needs_ipc = get_option('ipc').enabled() or needs_tests or needs_acero or needs_benchmarks or needs_flight
67+
needs_ipc = (get_option('ipc').enabled()
68+
or needs_tests
69+
or needs_acero
70+
or needs_benchmarks
71+
or needs_cuda
72+
or needs_flight
73+
)
6774
needs_fuzzing = get_option('fuzzing').enabled()
6875
needs_testing = (get_option('testing').enabled()
6976
or needs_tests

cpp/meson.options

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ option(
3939
description: 'Build all Arrow Compute kernels',
4040
)
4141
option('csv', type: 'feature', description: 'Build the Arrow CSV Parser Module')
42+
option(
43+
'cuda',
44+
type: 'feature',
45+
description: 'Build the Arrow CUDA extensions (requires CUDA toolkit)',
46+
)
4247
option(
4348
'filesystem',
4449
type: 'feature',

cpp/src/arrow/gpu/meson.build

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
cuda_dep = dependency('cuda', modules: ['cuda'])
19+
20+
arrow_cuda_srcs = [
21+
'cuda_arrow_ipc.cc',
22+
'cuda_context.cc',
23+
'cuda_internal.cc',
24+
'cuda_memory.cc',
25+
]
26+
27+
arrow_cuda_lib = library(
28+
'arrow-cuda',
29+
sources: [arrow_cuda_srcs],
30+
dependencies: [arrow_dep, cuda_dep, flatbuffers_dep],
31+
cpp_args: ['-DARROW_CUDA_EXPORTING'],
32+
)
33+
34+
arrow_cuda_dep = declare_dependency(
35+
link_with: [arrow_cuda_lib],
36+
dependencies: [cuda_dep],
37+
)
38+
39+
cuda_version = cuda_dep.version()
40+
cuda_split_version = cuda_version.split('.')
41+
cuda_conf_data = configuration_data()
42+
cuda_conf_data.set('CUDA_VERSION_MAJOR', cuda_split_version[0])
43+
cuda_conf_data.set('CUDA_VERSION_MINOR', cuda_split_version[1])
44+
45+
configure_file(
46+
input: 'cuda_version.h.in',
47+
output: 'cuda_version.h',
48+
configuration: cuda_conf_data,
49+
install_dir: 'arrow/gpu',
50+
)
51+
52+
install_headers(
53+
[
54+
'cuda_api.h',
55+
'cuda_arrow_ipc.h',
56+
'cuda_context.h',
57+
'cuda_internal.h',
58+
'cuda_memory.h',
59+
'visibility.h',
60+
],
61+
subdir: 'arrow/gpu',
62+
)
63+
64+
exc = executable(
65+
'arrow-cuda-test',
66+
sources: ['cuda_test.cc'],
67+
dependencies: [arrow_test_dep, arrow_cuda_dep],
68+
)
69+
test('arrow-cuda-test', exc)
70+
71+
exc = executable(
72+
'arrow-cuda-benchmark',
73+
sources: ['cuda_benchmark.cc'],
74+
dependencies: [arrow_benchmark_dep, arrow_cuda_dep],
75+
)
76+
benchmark('arrow-gpu-cuda-benchmark', exc)

cpp/src/arrow/meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,10 @@ if needs_acero
769769
subdir('acero')
770770
endif
771771

772+
if needs_cuda
773+
subdir('gpu')
774+
endif
775+
772776
if needs_filesystem
773777
subdir('filesystem')
774778
endif

0 commit comments

Comments
 (0)