From 0084607788a196132a1cbd9df930851e38aeba7a Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Tue, 13 May 2025 01:17:45 -0400 Subject: Add measure_startup_oh benchmark Supports ECRTS'25 partitioning paper. To nicely parse the resultant output, one could use the following shell pipeline: ./measure_startup_oh 2>&1 | cut -d "=" -s -f 2 | cut -d " " -f 2 \ | tr "\n" " " | sed 's/$/r - p/' | dc --- Makefile | 3 +++ measure_startup_oh.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 measure_startup_oh.c diff --git a/Makefile b/Makefile index 1956d72..61e7bef 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,9 @@ preemption_logger: task_host_utilities.cu preemption_logger.cu testbench.h measure_launch_oh: measure_launch_oh.cu testbench.h $(NVCC) measure_launch_oh.cu -o measure_launch_oh +measure_startup_oh: measure_startup_oh.c testbench.h + $(NVCC) measure_startup_oh.c -o measure_startup_oh + copy_experiments: $(MAKE) -C $@ diff --git a/measure_startup_oh.c b/measure_startup_oh.c new file mode 100644 index 0000000..56f9ea7 --- /dev/null +++ b/measure_startup_oh.c @@ -0,0 +1,44 @@ +/* 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; +} -- cgit v1.2.2