@@ -90,10 +90,6 @@ if get_option('use_lapack')
9090 common_c_args += ' -DUSE_LAPACK=1'
9191endif
9292
93- if get_option (' use_long' )
94- common_c_args += ' -DDLONG=1'
95- endif
96-
9793if get_option (' use_singleprec' )
9894 common_c_args += ' -DSFLOAT=1'
9995endif
@@ -105,6 +101,46 @@ endif
105101if get_option (' use_extraverbose' )
106102 common_c_args += ' -DVERBOSITY=999'
107103endif
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
109145scs_core_sources = files (
110146 ' scs_source/src/aa.c' ,
0 commit comments