Skip to content

Commit 0d9d15e

Browse files
authored
Merge pull request #10155 from cms-sw/toolconf-buildtime
Reduce built time for tool-conf by process tools files in parallel
2 parents 84d57ab + 784bc3b commit 0d9d15e

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

scram/tool-conf-src.file

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
%define auto_dependencies no
88
%define uctool %(echo %{n} | tr '[a-z-]' '[A-Z_]')
99
BuildRequires: SCRAMV1
10+
AutoReqProv: no
1011
Source99: scram-tools
1112
Source: none
1213

@@ -39,9 +40,11 @@ for tool in %requiredtools %{?use_system_gcc:gcc}; do
3940
uctool=`echo $tool | tr '[a-z-]' '[A-Z_]'`
4041
toolbase=`eval echo \\$${uctool}_ROOT`
4142
toolver=`eval echo \\$${uctool}_VERSION`
42-
%{_sourcedir}/scram-tools/bin/get_tools "$toolbase" "$toolver" %i "${tool}"
43+
while [ $(jobs -r -p | wc -l) -gt %compiling_processes ] ; do sleep 0.05; done
44+
%{_sourcedir}/scram-tools/bin/get_tools "$toolbase" "$toolver" %i "${tool}" &
4345
done
4446
%{_sourcedir}/scram-tools/bin/get_tools "" "system" %i "systemtools"
47+
wait
4548

4649
%if "%{package_vectorization}"
4750
%if "%{vectorized_packages}"
@@ -52,8 +55,10 @@ for vec in %{package_vectorization}; do \
5255
uctool=`echo $tool | tr '[a-z-]' '[A-Z_]'`
5356
toolbase=`eval echo \\$${uctool}_${ucvec}_ROOT`
5457
toolver=`eval echo \\$${uctool}_${ucvec}_VERSION`
55-
%{_sourcedir}/scram-tools/bin/get_vectorized_tools "$toolbase" "$toolver" %i "${tool}" "${vec}"
58+
while [ $(jobs -r -p | wc -l) -gt %compiling_processes ] ; do sleep 0.05; done
59+
%{_sourcedir}/scram-tools/bin/get_vectorized_tools "$toolbase" "$toolver" %i "${tool}" "${vec}" &
5660
done
61+
wait
5762
if [ -f %i/tools/selected/gcc-cxxcompiler.xml ] ; then
5863
f=$(%{cmsdist_directory}/vectorization/cmsdist_packages.py $vec)
5964
sed -i -e "s# *</tool># <flags CXXFLAGS_TARGETS_${ucvec}=\"${f}\"/>\n <flags REM_CXXFLAGS_TARGETS_${ucvec}=\"%{default_microarch}\"/>\n </tool>#" %i/tools/selected/gcc-cxxcompiler.xml
@@ -130,19 +135,16 @@ for pkg in $(echo %{allpkgreqs} | tr ' ' '\n' | grep '/py[23]-') ; do
130135
pk_name=$(echo $pkg | cut -d/ -f2 | tr '[A-Z]' '[a-z]')
131136
if [ -f %{i}/tools/selected/${pk_name}.xml ] ; then continue ; fi
132137
pk_ver=$(echo $pkg | cut -d/ -f3)
133-
uctool=`echo ${pk_name} | tr '[a-z-]' '[A-Z_]'`
134-
echo "<tool name=\"$pk_name\" version=\"$pk_ver\" revision=\"1\">" > %{i}/tools/selected/${pk_name}.xml
138+
client_content=""
135139
if [ -e %{cmsroot}/%{cmsplatf}/$pkg/bin ] ; then
136140
for b in $(ls %{cmsroot}/%{cmsplatf}/$pkg/bin) ; do
137141
ALL_PY_BIN="${ALL_PY_BIN} ${b}"
138142
ALL_PY_BIN_PKGS="${ALL_PY_BIN_PKGS} ${b}:${pk_name}"
139143
done
140-
echo " <client>" >> %{i}/tools/selected/${pk_name}.xml
141-
echo " <environment name=\"${uctool}_BASE\" default=\"%{cmsroot}/%{cmsplatf}/$pkg\"/>" >> %{i}/tools/selected/${pk_name}.xml
142-
echo " </client>" >> %{i}/tools/selected/${pk_name}.xml
143-
echo " <runtime name=\"PATH\" value=\"\$${uctool}_BASE/bin\" type=\"path\"/>" >> %{i}/tools/selected/${pk_name}.xml
144+
uctool=`echo ${pk_name} | tr '[a-z-]' '[A-Z_]'`
145+
client_content=" <client>\n <environment name=\"${uctool}_BASE\" default=\"%{cmsroot}/%{cmsplatf}/$pkg\"/>\n </client>\n <runtime name=\"PATH\" value=\"\$${uctool}_BASE/bin\" type=\"path\"/>\n"
144146
fi
145-
echo "</tool>" >> %{i}/tools/selected/${pk_name}.xml
147+
echo -e "<tool name=\"$pk_name\" version=\"$pk_ver\" revision=\"1\">\n${client_content}</tool>" > %{i}/tools/selected/${pk_name}.xml
146148
done
147149
DUP_BIN=$(echo "${ALL_PY_BIN}" | tr ' ' '\n' | grep -v '__pycache__' | sort | uniq -c | sed 's|^\s*||' | grep -v '^1 ' | sed 's|^.* ||')
148150

@@ -162,19 +164,26 @@ if [ -e %{i}/tools/selected/cuda-gcc-support.xml ] ; then
162164
fi
163165
fi
164166

167+
function tool_content() {
168+
tool=$(basename $xml)
169+
echo "cat << \\EOF_TOOLFILE >> %%{i}/tools/${type}/${tool}" > ${xml}.tmp
170+
cat $xml >> ${xml}.tmp
171+
echo -e "\nEOF_TOOLFILE\n" >> ${xml}.tmp
172+
grep -v '^\s*$' ${xml}.tmp > $xml
173+
rm -f ${xml}.tmp
174+
}
175+
165176
mkdir -p %{i}/tools
166177
for type in selected available ; do
167178
rm -f %{i}/tools/${type}.tmpl
168179
touch %{i}/tools/${type}.tmpl
169180
[ -d %{i}/tools/${type} ] || continue
170181
for xml in $(ls %{i}/tools/${type}/*.xml) ; do
171-
tool=$(basename $xml)
172-
echo "cat << \\EOF_TOOLFILE >> %%{i}/tools/${type}/${tool}" > tmp-tool.txt
173-
cat $xml >> tmp-tool.txt
174-
echo -e "\nEOF_TOOLFILE\n" >> tmp-tool.txt
175-
grep -v '^\s*$' tmp-tool.txt >> %{i}/tools/${type}.tmpl
176-
rm -f tmp-tool.txt
182+
while [ $(jobs -r -p | wc -l) -gt %compiling_processes ] ; do sleep 0.05; done
183+
tool_content $xml &
177184
done
185+
wait
186+
find %{i}/tools/${type} -name '*.xml' | xargs cat >> %{i}/tools/${type}.tmpl
178187
rm -rf %{i}/tools/${type}
179188
done
180189

scram/tool-conf.file

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## NOCOMPILER
22
## INCLUDE toolflags
3+
AutoReqProv: no
34
%define auto_dependencies no
45
%define uctool %(echo %{n} | tr '[a-z-]' '[A-Z_]')
56
%prep

scram/toolfile-src.file

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## NO_AUTO_RUNPATH
33
## NO_AUTO_DEPENDENCY
44
## INCLUDE toolflags
5-
5+
AutoReqProv: no
66
Source: scram-tools
77
%define tool %(echo %{n} | sed 's|-toolfile-src$||')
88
%define uctool %(echo %{tool} | tr '[a-z-]' '[A-Z_]')

scram/toolfile.file

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## NOCOMPILER
22
## INCLUDE toolflags
3+
AutoReqProv: no
34
%define auto_dependencies no
45
%define uctool %(echo %{n} | tr '[a-z-]' '[A-Z_]')
56
%prep

0 commit comments

Comments
 (0)