aboutsummaryrefslogtreecommitdiffstats
path: root/libsmctrl_test_gpc_info.c
diff options
context:
space:
mode:
authorJoshua Bakita <jbakita@cs.unc.edu>2025-06-16 19:29:07 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2025-06-17 14:01:49 -0400
commit89177fce34edb5ad0059a41548888d05588cc1c5 (patch)
tree096dc302bb5e17e3987c45a59ef02c69ec73e9ed /libsmctrl_test_gpc_info.c
parent03ae77e35d35b2a82f5387d1903cfa954b696edd (diff)
Rewrite nvtaskset and implementation of partitioning for unmodified tasks
Rather than requiring libsmctrl.so to be preloaded, we now wrap libcuda.so.1. All CUDA-using applications will load libcuda.so.1, ensuring that our wrapper will always be dynamically loaded, no matter if LD_PRELOAD is enabled, or if a program has been staticly linked. All that needs to be done is that the location of our "fake" libcuda.so.1 need to be put within the loader search path. This can be done by setting LD_LIBRARY_PATH, or by installing our wrapper into /lib/x86_64-linux-gnu. The mask can still be set via the LIBSMCTRL_MASK environment variable, but the easier-to-use nvtaskset tool is now the recommended way to view or change the supreme TPC mask for any CUDA-using application. This allows launching a program on the first two GPCs via a command as simple as: ./nvtaskset -g 0-1 ./a_program a_program_args (Note that use of the -g option requires the nvdebug kernel module to first be loaded.) These changes support the final version of the ECRTS'25 paper. Note that nvtaskset does not yet fully support multi-GPU systems. Bugfixes: - Fix crash that would occur if both libsmctrl.so and libsmctrl.a were built into an application. - Correctly use GPU ID when initializing a context in `libsmctrl_test_gpc_info`. - Include `nvtaskset` as a prerequisite for `libsmctrl_test_supreme_mask`. - Fix malfunction of `libsmctrl_test_gpc_info` if CUDA_VISIBLE_DEVICES is set. Other minor changes: - Adds make target to run all the tests. - Fixes typos in comments. - Enables -Wall build option. - Upgrades supreme mask from 64 to 128 bits. - Removes `detect_parker_soc()` from the global namespace. - Adjusts test messages to be more succinct. - Updates README with overview of how to partition unmodified applications, more details on the tests, and information on the new ECRTS'25 paper.
Diffstat (limited to 'libsmctrl_test_gpc_info.c')
-rw-r--r--libsmctrl_test_gpc_info.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libsmctrl_test_gpc_info.c b/libsmctrl_test_gpc_info.c
index 558b80a..afa0876 100644
--- a/libsmctrl_test_gpc_info.c
+++ b/libsmctrl_test_gpc_info.c
@@ -38,6 +38,8 @@ int main(int argc, char** argv) {
38 gpu_id = 0; 38 gpu_id = 0;
39 // Tell CUDA to use PCI device id ordering (to match nvdebug) 39 // Tell CUDA to use PCI device id ordering (to match nvdebug)
40 putenv((char*)"CUDA_DEVICE_ORDER=PCI_BUS_ID"); 40 putenv((char*)"CUDA_DEVICE_ORDER=PCI_BUS_ID");
41 // Allow CUDA to see all devices (to better match nvdebug)
42 unsetenv("CUDA_VISIBLE_DEVICES");
41 // A CUDA context is required before reading the topology information 43 // A CUDA context is required before reading the topology information
42 if ((res = cuInit(0))) { 44 if ((res = cuInit(0))) {
43 const char* name; 45 const char* name;
@@ -45,7 +47,7 @@ int main(int argc, char** argv) {
45 fprintf(stderr, "%s: Unable to initialize CUDA, error %s\n", program_invocation_name, name); 47 fprintf(stderr, "%s: Unable to initialize CUDA, error %s\n", program_invocation_name, name);
46 return 1; 48 return 1;
47 } 49 }
48 if ((res = cuCtxCreate(&ctx, 0, 0))) { 50 if ((res = cuCtxCreate(&ctx, 0, gpu_id))) {
49 const char* name; 51 const char* name;
50 cuGetErrorName(res, &name); 52 cuGetErrorName(res, &name);
51 fprintf(stderr, "%s: Unable to create a CUDA context, error %s\n", program_invocation_name, name); 53 fprintf(stderr, "%s: Unable to create a CUDA context, error %s\n", program_invocation_name, name);