Commit 9d73c35
committed
[ROCm] Add AMD GPU support via ROCm/HIP
This adds an optional AMD GPU build to cuPDLPx through ROCm/HIP, alongside
the existing CUDA path. The CUDA build is unchanged when USE_HIP is off.
To review: start with internal/cuda_to_hip.h, which routes the CUDA runtime,
cuBLAS, cuSPARSE, and CUB symbols used by the solver to their hipRT, hipBLAS,
hipSPARSE, and hipCUB equivalents on a HIP build, and includes the standard
CUDA headers otherwise. The device sources keep their CUDA spelling and are
compiled as HIP. internal/cusparse_compat.h selects the standard hipsparseSpMV
path on ROCm, since hipSPARSE does not provide the cusparseSpMVOp variant.
CMakeLists.txt gains a USE_HIP option (off by default). When enabled the
project is configured with the HIP language, the .cu sources are compiled as
HIP, and the targets link hipBLAS, hipSPARSE, and hipCUB instead of the CUDA
libraries. GPU architectures are chosen with CMAKE_HIP_ARCHITECTURES,
defaulting to gfx90a. On Windows the CLI-only mps_parser.c is excluded from
the core library because it relies on strtok_r. The interface test gains a
case that runs the GPU solver path with presolve disabled, exercising the
hipBLAS and hipSPARSE execution path end to end.
Test Plan:
Built and ran on an AMD Instinct MI200 (gfx90a) with ROCm 7.2.1:
```
cmake -B build -DUSE_HIP=ON -DCMAKE_HIP_ARCHITECTURES=gfx90a -DCMAKE_PREFIX_PATH=/opt/rocm \
-DCUPDLPX_BUILD_CLI=ON -DCUPDLPX_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
./build/tests/test_interface
```
The interface suite passes, including the GPU solver case (Status: OPTIMAL).
The same configuration builds cleanly for gfx1100 (RDNA3) and gfx1201
(RDNA4); the device code objects are identical across the documentation and
formatting commits that followed validation. The CUDA build path is
unaffected by these changes.
This work was authored with the assistance of Claude, an AI assistant by
Anthropic.1 parent 931c94c commit 9d73c35
10 files changed
Lines changed: 361 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
35 | | - | |
36 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
37 | 52 | | |
38 | 53 | | |
39 | 54 | | |
| |||
61 | 76 | | |
62 | 77 | | |
63 | 78 | | |
64 | | - | |
65 | | - | |
66 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
67 | 87 | | |
68 | 88 | | |
69 | 89 | | |
| |||
85 | 105 | | |
86 | 106 | | |
87 | 107 | | |
88 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
89 | 118 | | |
90 | 119 | | |
91 | 120 | | |
| |||
152 | 181 | | |
153 | 182 | | |
154 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
155 | 188 | | |
156 | 189 | | |
157 | 190 | | |
158 | 191 | | |
159 | 192 | | |
160 | 193 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
169 | 218 | | |
170 | 219 | | |
171 | 220 | | |
| |||
174 | 223 | | |
175 | 224 | | |
176 | 225 | | |
177 | | - | |
178 | | - | |
179 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
180 | 237 | | |
181 | 238 | | |
182 | 239 | | |
| |||
187 | 244 | | |
188 | 245 | | |
189 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
190 | 254 | | |
191 | 255 | | |
192 | | - | |
| 256 | + | |
| 257 | + | |
193 | 258 | | |
194 | 259 | | |
195 | 260 | | |
| |||
204 | 269 | | |
205 | 270 | | |
206 | 271 | | |
207 | | - | |
208 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
209 | 278 | | |
210 | 279 | | |
211 | 280 | | |
| |||
217 | 286 | | |
218 | 287 | | |
219 | 288 | | |
220 | | - | |
| 289 | + | |
221 | 290 | | |
222 | 291 | | |
223 | 292 | | |
224 | 293 | | |
225 | 294 | | |
226 | | - | |
227 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
228 | 301 | | |
229 | 302 | | |
230 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
46 | 63 | | |
47 | 64 | | |
48 | 65 | | |
| |||
0 commit comments