CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / om / platform-linux / plat_wait.om
| 1 | om2 |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | note Marker poll through mapget. The caller owns the mapping. A foreign handle traps. |
| 4 | note WolframLanguageEvaluator: {2^31, 2^32-1, 1000000/50000, 2000*(1000000/50000)} -> {2147483648, 4294967295, 20, 40000}. |
| 5 | export fn plat_wait_budget ms ulong to ulong |
| 6 | if eq ms 0 |
| 7 | ret ulong 0 |
| 8 | end |
| 9 | n = mul ms 20 |
| 10 | if lt n 40000 |
| 11 | ret n |
| 12 | end |
| 13 | ret ulong 40000 |
| 14 | end |
| 15 | export fn plat_wait_hold addr ulong n ulong to long |
| 16 | ret maphold addr n |
| 17 | end |
| 18 | export fn plat_wait_bind handle long fd long to long |
| 19 | ret mapbind handle int fd 0 1 |
| 20 | end |
| 21 | export fn plat_wait_drop handle long to long |
| 22 | ret mapdrop handle |
| 23 | end |
| 24 | export fn plat_wait_ge handle long off ulong want ulong polls ulong to long |
| 25 | n = polls |
| 26 | if eq n 0 |
| 27 | n = ulong 1 |
| 28 | end |
| 29 | i = ulong 0 |
| 30 | while lt i n |
| 31 | g = mapget handle off 4 |
| 32 | d = and (sub g want) 4294967295 |
| 33 | if lt d 2147483648 |
| 34 | ret long 0 |
| 35 | end |
| 36 | cpurelax |
| 37 | i = add i 1 |
| 38 | end |
| 39 | ret neg long 1 |
| 40 | end |