-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathsetopts
More file actions
executable file
·159 lines (155 loc) · 5.89 KB
/
setopts
File metadata and controls
executable file
·159 lines (155 loc) · 5.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
#-----------------------------------------------------------------------
# Name: setopts
#
# Purpose: Globally change compile-time options.
#
# This script should be called after calling the configure script to set
# up the build system but prior to compiling in order to enable or disable
# particular compile time features. This version of the script must be
# called from the pscfpp/ root directory, and applies all changes to
# config.mk files used for code compiled in either the bld/ directory (for
# out-of-source compilation) or in the src/ directory (for in-source
# compilation). To instead apply changes only to code compiled in one
# build directory (i.e., only in bld/ or src/), one must change directory
# (cd) to that build directory and invoke the local setopts script located
# there.
#
# This "global" version of the setopts script works by simply recursively
# invoking the local setopts scripts in the bld/ and src/ directories to
# apply changes in both build directories. It accepts all of the same
# options as those accepted by the setopts scripts in the src/ and bld/
# directories.
#
# Synopsis:
# --------
#
# setopts [options]
#
# Command Line Options:
# ---------------------
#
# The -q and -h command line options take no arguments, and both provide
# information:
#
# -q query: prints report of options that are enabled / disabled.
# -h help: prints a list of available options
#
# The -d and -c options each enable or disable a feature. Each such option
# takes a 0 or 1 as a required argument, using 1 to enable the feature or
# 0 to disable it:
#
# -d (0|1) debugging (defines/undefines UTIL_DEBUG)
# -c (0|1) CUDA code (defines/undefines PSCF_CUDA)
#
# This -a option sets an identifier for the NVIDIA GPU architecture to be
# targeted by the NVIDIA CUDA compiler. The argument of this command line
# option is passed as the argument of the "-arch" option of the NVIDIA
# C++ / CUDA compiler. Allowed values are string of the form sm_NN, where
# NN is a number that gives the major and minor version number for the CUDA
# "compute capability" for the target GPU. For example, the V100 GPU has a
# compute capability 7.0, and requires an architecture code sm_70.
#
# -a (architecture code) (defines NVARCH)
#
# Examples:
# ---------
#
# To enable debugging
#
# > ./setopts -d1
#
# To disable debugging
#
# > ./setopts -d0
#
# To enable conditional compilation of CUDA code (disabled by default)
# and set the GPU architecture option to sm_70 (compute capability 7.0,
# appropriate for a V100 chip) one could enter
#
# > ./setopts -c1 -a sm_70
#
#-----------------------------------------------------------------------
ROOT=$PWD
opt=""
OPTARG=""
while getopts "a:c:d:m:qh" opt; do
if [[ "$opt" != "?" ]]; then
if [[ "$opt" != "h" ]]; then
echo ""
cd $ROOT
cd bld/;
echo "In build directory $PWD":
./setopts -"$opt" "$OPTARG"
echo ""
cd $ROOT
cd src/;
echo "In build directory $PWD":
./setopts -"$opt" "$OPTARG"
opt=""
OPTARG=""
else
echo " "
echo " Purpose and usage:"
echo " ------------------"
echo " "
echo " The setopts script may be called prior to compiling to enable"
echo " or disable compile time features, set compiler options, "
echo " and/or query which features are currently set to be enabled."
echo " This script must be called from the directory that contains"
echo " the script file. The global setopts script in the pscfpp/"
echo " root directory applies all queries and changes to"
echo " configuration files that control compilation in both the"
echo " bld/ and src/ directories."
echo " "
echo " Command Line Options:"
echo " ----------------------"
echo " "
echo " The -q and -h command line options both provide information,"
echo " and take no arguments:"
echo " "
echo " -q query: print list of options that are enabled/disabled"
echo " -h help: print a list of available options"
echo " "
echo " The -d and -c options each enable or disable a feature. Each"
echo " such option takes 0 or 1 as a required argument, using 1 to"
echo " enable and 0 to disable the feature. "
echo " "
echo " -d (0|1) debugging (defines/undefines UTIL_DEBUG)"
echo " -c (0|1) CUDA code (defines/undefines PSCF_CUDA)"
echo " "
echo " The -a option sets a string identifier for the NVIDIA GPU"
echo " architecture to be targeted by the NVIDIA CUDA compiler. The"
echo " parameter of this command line option is passed as the"
echo " parameter of the -arch option of the C++ / CUDA compiler."
echo " Allowed values are strings of the form sm_MN, where MN is a"
echo " number that gives the major (M) and minor (N) version number"
echo " for the CUDA compute capability of the target architecture."
echo " For example, the V100 GPU has a compute capability 7.0, and"
echo " and thus requires an architecture identifier sm_70."
echo " "
echo " -a [architecture id] (defines NVARCH)"
echo " "
echo " See web page https://developer.nvidia.com/cuda-gpus#compute"
echo " for a list of compute capabibilities for different NVIDIA GPUs."
echo " "
echo " Examples:"
echo " ---------"
echo " "
echo " To enable debugging"
echo " "
echo " > ./setopts -d1"
echo " "
echo " To disable debugging"
echo " "
echo " > ./setopts -d0"
echo " "
echo " To enable conditional compilation of CUDA code (disabled by"
echo " default) and set the GPU architecture option to sm_70 (compute"
echo " capability 7.0, appropriate for a V100 chip) one could enter"
echo " "
echo " > ./setopts -c1 -a sm_70"
echo " "
fi
fi
done