Skip to content

Commit 3f7cdf1

Browse files
committed
Upd
1 parent 29b44a6 commit 3f7cdf1

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

module5/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CXXFLAGS := $(INCLUDE) $(OPT) -Wall -march=native -g -std=c++17
2222
ACC := -acc=multicore -Minfo=acc
2323

2424
# use on GPU for benchmarking and real tests of code
25-
#ACC := -acc -gpu=cuda11.6 -Minfo=acc
25+
#ACC := -acc -gpu=cuda12.6 -Minfo=acc
2626

2727
.PHONY: clean all
2828

module5/run_sw.sh

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
# make sure stack size is unlimited
4+
ulimit -s unlimited
5+
6+
# Startup CUDA Multi-Process Service
7+
mkdir -p /home/jovyan/mps
8+
export CUDA_MPS_LOG_DIRECTORY=/home/jovyan/mps
9+
nvidia-cuda-mps-control -d
10+
11+
# Set current device to the correct value for MPS
12+
export CUDA_VISIBLE_DEVICES=0
13+
14+
if [ "$#" -gt 2 ] || [ "$#" -eq 0 ]; then
15+
echo "Usage: $0 <SM> <fill>"
16+
echo "SM: number of streaming multiprocessors to run on. Has tp be 2, 4, 6, 8, 10, 12, or 14"
17+
echo "fill: 0 - just launch one copy, 1 - launch as many copies of sw_parallel as can fit on the GPU (floor(14/SMs))"
18+
# shutdown MPS service
19+
echo quit | nvidia-cuda-mps-control
20+
exit 1
21+
fi
22+
export SM=$1
23+
export FILL=0
24+
if [ "$#" -eq 2 ]; then
25+
export FILL=$2
26+
fi
27+
28+
case $SM in
29+
30+
2)
31+
export CUDA_MPS_ACTIVE_THREAD_PERCENTAGE=15 # 2 SMs
32+
if [ "$FILL" -eq 0 ]; then
33+
./sw_parallel
34+
else
35+
./sw_parallel &
36+
./sw_parallel &
37+
./sw_parallel &
38+
./sw_parallel &
39+
./sw_parallel &
40+
./sw_parallel &
41+
./sw_parallel &
42+
wait
43+
fi;;
44+
45+
4)
46+
export CUDA_MPS_ACTIVE_THREAD_PERCENTAGE=29 # 4 SMs
47+
if [ "$FILL" -eq 0 ]; then
48+
./sw_parallel
49+
else
50+
./sw_parallel &
51+
./sw_parallel &
52+
./sw_parallel &
53+
wait
54+
fi;;
55+
56+
6)
57+
export CUDA_MPS_ACTIVE_THREAD_PERCENTAGE=43 # 6 SMs
58+
if [ "$FILL" -eq 0 ]; then
59+
./sw_parallel
60+
else
61+
./sw_parallel &
62+
./sw_parallel &
63+
wait
64+
fi;;
65+
66+
8)
67+
export CUDA_MPS_ACTIVE_THREAD_PERCENTAGE=58 # 8 SMs
68+
./sw_parallel;;
69+
70+
10)
71+
export CUDA_MPS_ACTIVE_THREAD_PERCENTAGE=72 # 10 SMs
72+
./sw_parallel;;
73+
74+
12)
75+
export CUDA_MPS_ACTIVE_THREAD_PERCENTAGE=86 # 12 SMs
76+
./sw_parallel;;
77+
78+
14)
79+
export CUDA_MPS_ACTIVE_THREAD_PERCENTAGE=100 # 14 SMs
80+
./sw_parallel;;
81+
82+
*)
83+
echo "Unknown value for SM = $SM"
84+
echo "Valid values are 2, 4, 6, 8, 10, 12 or 14";;
85+
86+
esac
87+
88+
# shutdown MPS service
89+
echo quit | nvidia-cuda-mps-control

0 commit comments

Comments
 (0)