mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
Runs the unmodified upstream Linux amdgpu and amdkfd drivers on Apple Silicon Macs inside a DriverKit system extension, for AMD GPUs attached over Thunderbolt. The Linux sources come from a pinned submodule and are compiled against linuxu, a userspace implementation of the Linux kernel APIs they use. Includes the HSA runtime, the host installer app, the setup and firmware fetch scripts, and the offline test suite.
26 lines
729 B
C
26 lines
729 B
C
#include <assert.h>
|
|
#include <time.h>
|
|
#include <linux/ktime.h>
|
|
|
|
extern u64 ktime_get_mono_fast_ns(void);
|
|
|
|
int main(void)
|
|
{
|
|
ktime_t start = ktime_get();
|
|
struct timespec pause = { .tv_sec = 0, .tv_nsec = 12000000 };
|
|
assert(nanosleep(&pause, NULL) == 0);
|
|
ktime_t end = ktime_get();
|
|
assert(end > start);
|
|
assert(ktime_ms_delta(end, start) >= 10);
|
|
assert(ktime_ms_delta(start, end) <= -10);
|
|
assert(ktime_get_mono_fast_ns() > 0);
|
|
assert(ktime_get_raw_ns() > 0);
|
|
assert(ktime_get_boottime_ns() > 0);
|
|
assert(ktime_get_real_seconds() > 1577836800);
|
|
struct timespec64 timestamp = {0};
|
|
ktime_get_ts64(×tamp);
|
|
assert(timestamp.tv_sec > 0 && timestamp.tv_nsec >= 0 &&
|
|
timestamp.tv_nsec < NSEC_PER_SEC);
|
|
return 0;
|
|
}
|