diff options
author | Joshua Bakita <jbakita@cs.unc.edu> | 2024-02-19 15:37:10 -0500 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2024-02-19 15:37:46 -0500 |
commit | 5029151978a20831558480ae052c98b7e528af95 (patch) | |
tree | d2dc7b01cf7aa6ae462d809689b769cf4b68f67a | |
parent | b5281f5fc01fc925898c9323edab41b817df8661 (diff) |
Also allow building with an alternate version of g++ for backwards
compatibility.
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | README.md | 56 |
2 files changed, 62 insertions, 7 deletions
@@ -1,4 +1,5 @@ | |||
1 | CC = gcc | 1 | CC = gcc |
2 | CXX = g++ | ||
2 | NVCC ?= nvcc | 3 | NVCC ?= nvcc |
3 | # -fPIC is needed in all cases, as we may be linked into another shared library | 4 | # -fPIC is needed in all cases, as we may be linked into another shared library |
4 | CFLAGS = -fPIC | 5 | CFLAGS = -fPIC |
@@ -18,22 +19,22 @@ libsmctrl_test_gpc_info: libsmctrl_test_gpc_info.c libsmctrl.a testbench.h | |||
18 | $(CC) $< -o $@ -g -L. -l:libsmctrl.a $(LDFLAGS) | 19 | $(CC) $< -o $@ -g -L. -l:libsmctrl.a $(LDFLAGS) |
19 | 20 | ||
20 | libsmctrl_test_mask_shared.o: libsmctrl_test_mask_shared.cu testbench.h | 21 | libsmctrl_test_mask_shared.o: libsmctrl_test_mask_shared.cu testbench.h |
21 | $(NVCC) $< -c -g | 22 | $(NVCC) -ccbin $(CXX) $< -c -g |
22 | 23 | ||
23 | libsmctrl_test_global_mask: libsmctrl_test_global_mask.c libsmctrl.a libsmctrl_test_mask_shared.o | 24 | libsmctrl_test_global_mask: libsmctrl_test_global_mask.c libsmctrl.a libsmctrl_test_mask_shared.o |
24 | $(NVCC) $@.c -o $@ libsmctrl_test_mask_shared.o -g -L. -l:libsmctrl.a $(LDFLAGS) | 25 | $(NVCC) -ccbin $(CXX) $@.c -o $@ libsmctrl_test_mask_shared.o -g -L. -l:libsmctrl.a $(LDFLAGS) |
25 | 26 | ||
26 | libsmctrl_test_stream_mask: libsmctrl_test_stream_mask.c libsmctrl.a libsmctrl_test_mask_shared.o | 27 | libsmctrl_test_stream_mask: libsmctrl_test_stream_mask.c libsmctrl.a libsmctrl_test_mask_shared.o |
27 | $(NVCC) $@.c -o $@ libsmctrl_test_mask_shared.o -g -L. -l:libsmctrl.a $(LDFLAGS) | 28 | $(NVCC) -ccbin $(CXX) $@.c -o $@ libsmctrl_test_mask_shared.o -g -L. -l:libsmctrl.a $(LDFLAGS) |
28 | 29 | ||
29 | libsmctrl_test_stream_mask_override: libsmctrl_test_stream_mask_override.c libsmctrl.a libsmctrl_test_mask_shared.o | 30 | libsmctrl_test_stream_mask_override: libsmctrl_test_stream_mask_override.c libsmctrl.a libsmctrl_test_mask_shared.o |
30 | $(NVCC) $@.c -o $@ libsmctrl_test_mask_shared.o -g -L. -l:libsmctrl.a $(LDFLAGS) | 31 | $(NVCC) -ccbin $(CXX) $@.c -o $@ libsmctrl_test_mask_shared.o -g -L. -l:libsmctrl.a $(LDFLAGS) |
31 | 32 | ||
32 | libsmctrl_test_next_mask: libsmctrl_test_next_mask.c libsmctrl.a libsmctrl_test_mask_shared.o | 33 | libsmctrl_test_next_mask: libsmctrl_test_next_mask.c libsmctrl.a libsmctrl_test_mask_shared.o |
33 | $(NVCC) $@.c -o $@ libsmctrl_test_mask_shared.o -g -L. -l:libsmctrl.a $(LDFLAGS) | 34 | $(NVCC) -ccbin $(CXX) $@.c -o $@ libsmctrl_test_mask_shared.o -g -L. -l:libsmctrl.a $(LDFLAGS) |
34 | 35 | ||
35 | libsmctrl_test_next_mask_override: libsmctrl_test_next_mask_override.c libsmctrl.a libsmctrl_test_mask_shared.o | 36 | libsmctrl_test_next_mask_override: libsmctrl_test_next_mask_override.c libsmctrl.a libsmctrl_test_mask_shared.o |
36 | $(NVCC) $@.c -o $@ libsmctrl_test_mask_shared.o -g -L. -l:libsmctrl.a $(LDFLAGS) | 37 | $(NVCC) -ccbin $(CXX) $@.c -o $@ libsmctrl_test_mask_shared.o -g -L. -l:libsmctrl.a $(LDFLAGS) |
37 | 38 | ||
38 | tests: libsmctrl_test_gpc_info libsmctrl_test_global_mask libsmctrl_test_stream_mask libsmctrl_test_stream_mask_override libsmctrl_test_next_mask libsmctrl_test_next_mask_override | 39 | tests: libsmctrl_test_gpc_info libsmctrl_test_global_mask libsmctrl_test_stream_mask libsmctrl_test_stream_mask_override libsmctrl_test_next_mask libsmctrl_test_next_mask_override |
39 | 40 | ||
@@ -20,6 +20,52 @@ Please cite this paper in any work which leverages our library. Here's the BibTe | |||
20 | Please see [the paper](https://www.cs.unc.edu/~jbakita/rtas23.pdf) and libsmctrl.h for details and examples of how to use this library. | 20 | Please see [the paper](https://www.cs.unc.edu/~jbakita/rtas23.pdf) and libsmctrl.h for details and examples of how to use this library. |
21 | We strongly encourage consulting those resources first; the below comments serve merely as an appendum. | 21 | We strongly encourage consulting those resources first; the below comments serve merely as an appendum. |
22 | 22 | ||
23 | ## Run-time Dependencies | ||
24 | `libcuda.so`, which is automatically installed by the NVIDIA GPU driver. | ||
25 | |||
26 | ## Building | ||
27 | To build, ensure that you have `gcc` installed and access to the CUDA SDK including `nvcc`. Then run: | ||
28 | ``` | ||
29 | make libsmctrl.a | ||
30 | ``` | ||
31 | |||
32 | If you see an error that the command `nvcc` was not found, `nvcc` is not available on your `PATH`. | ||
33 | Correct this error by explictly specifying the location of `nvcc` to `make`, e.g.: | ||
34 | ``` | ||
35 | make NVCC=/playpen/jbakita/CUDA/cuda-archive/cuda-10.2/bin/nvcc libsmctrl.a | ||
36 | ``` | ||
37 | |||
38 | For binary backwards-compatibility to old versions of the NVIDIA GPU driver, we recommend building with an old version of the CUDA SDK. | ||
39 | For example, by building against CUDA 10.2, the binary will be compatible with any version of the NVIDIA GPU driver newer than 440.36 (Nov 2019), but by building against CUDA 8.0, the binary will be compatible with any version of the NVIDIA GPU driver newer that 375.26 (Dec 2016). | ||
40 | |||
41 | Older versions of `nvcc` may require you to use an older version of `g++`. | ||
42 | This can be explictly specified via the `CXX` variable, e.g.: | ||
43 | ``` | ||
44 | make NVCC=/playpen/jbakita/CUDA/cuda-archive/cuda-8.0/bin/nvcc CXX=g++-5 libsmctrl.a | ||
45 | ``` | ||
46 | |||
47 | `libsmctrl` supports being built as a shared library. | ||
48 | This will require you to distribute `libsmctrl.so` with your compiled program. | ||
49 | If you do not know what a shared library is, or why you would need to specify the path to `libsmctrl.so` in `LD_LIBRARY_PATH`, do not do this. | ||
50 | To build as a shared library, replace `libsmctrl.a` with `libsmctrl.so` in the above commands. | ||
51 | |||
52 | ## Linking in Your Application | ||
53 | If you have cloned and built `libsmctrl` in the folder `/playpen/libsmctrl` (replace this with the location you use): | ||
54 | |||
55 | 1. Add `-I/playpen/libsmctrl` to your compiler command (this allows `#include <libsmctrl.h>` in your C/C++ files). | ||
56 | 2. Add `-lsmctrl` to your linker command (this allows the linker to resolve the `libsmctrl` functions you use to the implementations in `libsmctrl.a` or `libsmctrl.so`). | ||
57 | 3. Add `-L/playpen/libsmctrl` to your linker command (this allows the linker to find `libsmctrl.a` or `libsmctrl.so`). | ||
58 | 4. (If not already included) add `-lcuda` to your linker command (this links against the CUDA driver library). | ||
59 | |||
60 | Note that if you have compiled both `libsmctrl.a` (the static library) and `libsmctrl.so` (the shared library), most compilers will prefer the shared library. | ||
61 | To statically link against `libsmctrl.a`, delete `libsmctrl.so`. | ||
62 | |||
63 | For example, if you have a CUDA program written in `benchmark.cu` and have built `libsmctrl`, you can compile and link against `libsmctrl` via the following command: | ||
64 | ``` | ||
65 | nvcc benchmark.cu -o benchmark -I/playpen/libsmctl -lsmctrl -lcuda -L/playpen/libsmctrl | ||
66 | ``` | ||
67 | The resultant `benchmark` binary should be portable to any system with an equivalent or newer version of the NVIDIA GPU driver installed. | ||
68 | |||
23 | ## Run Tests | 69 | ## Run Tests |
24 | To test partitioning: | 70 | To test partitioning: |
25 | ``` | 71 | ``` |
@@ -29,9 +75,17 @@ make tests | |||
29 | ./libsmctrl_test_next_mask | 75 | ./libsmctrl_test_next_mask |
30 | ``` | 76 | ``` |
31 | 77 | ||
78 | To test that high-granularity masks override low-granularity ones: | ||
79 | ``` | ||
80 | make tests | ||
81 | ./libsmctrl_test_stream_mask_override | ||
82 | ./libsmctrl_test_next_mask_override | ||
83 | ``` | ||
84 | |||
32 | And if `nvdebug` has been installed: | 85 | And if `nvdebug` has been installed: |
33 | ``` | 86 | ``` |
34 | ./libsmctrl_test_gpu_info | 87 | make tests |
88 | ./libsmctrl_test_gpc_info | ||
35 | ``` | 89 | ``` |
36 | 90 | ||
37 | ## Supported GPUs | 91 | ## Supported GPUs |