Skip to content

Commit 6396e23

Browse files
committed
ENH: Try to setup the GPU variant
1 parent 986840a commit 6396e23

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

meson.build

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ if get_option('use_lapack')
9090
common_c_args += '-DUSE_LAPACK=1'
9191
endif
9292

93-
if get_option('use_long')
94-
common_c_args += '-DDLONG=1'
95-
endif
96-
9793
if get_option('use_singleprec')
9894
common_c_args += '-DSFLOAT=1'
9995
endif
@@ -105,6 +101,46 @@ endif
105101
if get_option('use_extraverbose')
106102
common_c_args += '-DVERBOSITY=999'
107103
endif
104+
105+
is_gpu_build = get_option('use_gpu')
106+
use_32bit_ints = get_option('int32')
107+
108+
if is_gpu_build and not use_32bit_ints
109+
error('GPU builds require 32-bit integers. Please re-run Meson with -Dint32=true')
110+
endif
111+
112+
if not use_32bit_ints
113+
common_c_args += '-DDLONG=1'
114+
endif
115+
116+
cuda_dep = dependency('cuda', required: is_gpu_build)
117+
if is_gpu_build and not cuda_dep.found()
118+
error('GPU build requested but CUDA toolkit was not found.')
119+
endif
120+
121+
if is_gpu_build
122+
gpu_c_args = c_args + ['-DPY_GPU=1', '-DINDIRECT=1']
123+
deps +=
124+
if get_option('gpu_atrans')
125+
gpu_c_args += '-DGPU_TRANSPOSE_MAT=1'
126+
endif
127+
ext_modules += py.extension_module(
128+
'_scs_gpu',
129+
common_sources,
130+
# In Meson, sources with a `.cu` extension are compiled with nvcc by default.
131+
# To compile `.c` files with nvcc, they must be explicitly targeted.
132+
# It is strongly recommended to rename CUDA-C files to `.cu`.
133+
fs.glob('scs_source/linsys/gpu/*.c'),
134+
fs.glob('scs_source/linsys/gpu/indirect/*.c'),
135+
c_args: gpu_c_args,
136+
dependencies: [blas_dep, cuda_dep],
137+
include_directories: [
138+
common_includes, 'scs_source/linsys/gpu/', 'scs_source/linsys/gpu/indirect'
139+
],
140+
install: true,
141+
)
142+
endif
143+
108144
# Sources
109145
scs_core_sources = files(
110146
'scs_source/src/aa.c',

meson.options

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ option('use_lapack', type: 'boolean',
1313
value: true, description: 'use LAPACK')
1414
option('use_singleprec', type: 'boolean',
1515
value: false, description: 'use single precision floating point')
16-
option('use_long', type: 'boolean',
17-
value: true, description: 'use long over int')
1816
option('use_extraverbose', type: 'boolean',
1917
value: false, description: 'Enable extra verbose SCS (for debugging).')
18+
option('use_gpu', type: 'boolean',
19+
value: false, description: 'setup the GPU variant')
20+
option('int32', type: 'boolean',
21+
value: false, description: 'Use 32-bit integers (required for GPU).')
22+
option('gpu_atrans', type: 'boolean',
23+
value: false, description: 'transpose matrices for the GPU')
24+
option('use_blas64', type: 'boolean',
25+
value: false, description: 'Use 64-bit convention for BLAS')

0 commit comments

Comments
 (0)