interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / om / platform-linux / plat_wait.om

40 lines · 905 bytes Raw Blame History
1om2
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note Marker poll through mapget. The caller owns the mapping. A foreign handle traps.
4note WolframLanguageEvaluator: {2^31, 2^32-1, 1000000/50000, 2000*(1000000/50000)} -> {2147483648, 4294967295, 20, 40000}.
5export fn plat_wait_budget ms ulong to ulong
6if eq ms 0
7ret ulong 0
8end
9n = mul ms 20
10if lt n 40000
11ret n
12end
13ret ulong 40000
14end
15export fn plat_wait_hold addr ulong n ulong to long
16ret maphold addr n
17end
18export fn plat_wait_bind handle long fd long to long
19ret mapbind handle int fd 0 1
20end
21export fn plat_wait_drop handle long to long
22ret mapdrop handle
23end
24export fn plat_wait_ge handle long off ulong want ulong polls ulong to long
25n = polls
26if eq n 0
27n = ulong 1
28end
29i = ulong 0
30while lt i n
31g = mapget handle off 4
32d = and (sub g want) 4294967295
33if lt d 2147483648
34ret long 0
35end
36cpurelax
37i = add i 1
38end
39ret neg long 1
40end