/* Copyright 2025 Joshua Bakita * Simple kernel that uses measure_launch_oh to measure how long CUDA * initialization takes. * Prints status to stderr and nothing to stdout. */ #include // clock_gettime() #include // fprintf(), perror() #include // putenv() #include // strcmp() #include // execve() extern char **environ; #include "testbench.h" #define measure_launch_oh "./measure_launch_oh" int main(int argc, char **argv) { int *__unused, i; struct timespec start; if (argc == 2 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h"))) { fprintf(stderr, "Usage: %s [environment var to apply to child (optional)]\n", argv[0]); return 1; } static char* child_argv[3]; child_argv[0] = measure_launch_oh; child_argv[1] = "1"; child_argv[2] = NULL; // Use this to apply LD_PRELOAD to the child only if (argv[1]) putenv(argv[1]); clock_gettime(CLOCK_MONOTONIC_RAW, &start); fprintf(stderr, "(%d) Starting '"measure_launch_oh"' at CLOCK_MONOTONIC_RAW = %ld ns\n", getpid(), time2ns(start)); if (execve(measure_launch_oh, child_argv, environ)) { perror("Unable to start '"measure_launch_oh"'"); return 1; } return 0; }