mic-configure 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2014,2016 Inria
  5. # Copyright (C) 2013-2017 CNRS
  6. # Copyright (C) 2013-2017,2020 Université de Bordeaux
  7. # Copyright (C) 2013 Thibaut Lambert
  8. #
  9. # StarPU is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU Lesser General Public License as published by
  11. # the Free Software Foundation; either version 2.1 of the License, or (at
  12. # your option) any later version.
  13. #
  14. # StarPU is distributed in the hope that it will be useful, but
  15. # WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. #
  18. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  19. #
  20. ROOT_DIR=$(dirname $0)
  21. cat > ./mic-config.log << EOF
  22. This file was created by StarPU mic-configure
  23. $ $0 $*
  24. EOF
  25. prefix="/usr/local"
  26. coi_dir="/opt/intel/mic/coi"
  27. scif_dir="/opt/intel/mic/scif"
  28. mic_host="x86_64-k1om-linux"
  29. declare -a host_params
  30. declare -a mic_params
  31. unset host_params
  32. unset mic_params
  33. native_mic=0
  34. mpi=0
  35. for arg in "$@"
  36. do
  37. case $arg in
  38. --prefix=*)
  39. prefix="${arg#--prefix=}"
  40. ;;
  41. --with-coi-dir=*)
  42. coi_dir="${arg#--with-coi-dir=}"
  43. ;;
  44. --with-scif-dir=*)
  45. scif_dir="${arg#--with-scif-dir=}"
  46. ;;
  47. --mic-host=*)
  48. mic_host="${arg#--mic-host=}"
  49. ;;
  50. --enable-native-mic)
  51. native_mic=1
  52. ;;
  53. --with-compiler=*)
  54. compiler="${arg#--with-compiler=}"
  55. ;;
  56. --with-mic-param=*)
  57. mic_params+=("${arg#--with-mic-param=}")
  58. ;;
  59. --with-host-param=*)
  60. host_params+=("${arg#--with-host-param=}")
  61. ;;
  62. --with-mpi*)
  63. mpi=1
  64. ;;
  65. --help)
  66. cat << EOF
  67. mic-configure specific options:
  68. --with-coi-dir=DIR Specify directory that contains
  69. device-linux-release/lib/libcoi_device and
  70. host-linux-release/lib/libcoi_host and
  71. --with-scif-dir=DIR Specify directory that contains
  72. device-linux-release/lib/libscif_device and
  73. host-linux-release/lib/libscif_host and
  74. --mic-host=HOST Specify the precise Phi host to build for
  75. (default: k1om)
  76. --with-compiler=[icc|gcc]
  77. Specify whether to build with icc or with gcc
  78. --enable-native-mic Only build the Phi binaries
  79. --with-mic-param=--OPTION
  80. Pass --OPTION to the Phi configure script
  81. --with-host-param=--OPTION
  82. Pass --OPTION to the host configure script
  83. EOF
  84. ;;
  85. esac
  86. done
  87. if [ -z "$compiler" ]
  88. then
  89. # Test gcc compiler
  90. x=$(type -t ${mic_host}-gcc)
  91. if [ -z "$x" ]
  92. then
  93. # Test icc compiler
  94. echo "int main(int argc, char **argv) { return 0; }" > /tmp/icc_$USER_$$.c
  95. icc -mmic /tmp/icc_$USER_$$.c > /dev/null 2>/tmp/icc_$USER_$$.err
  96. l=$(grep -c "invalid argument" /tmp/icc_$USER_$$.err)
  97. if [ "$l" != "0" ]
  98. then
  99. echo "[error] no compiler found. please add path to either ${mic_host}-gcc or to an enabled mic icc compiler in your PATH"
  100. exit 1
  101. else
  102. compiler="icc"
  103. fi
  104. else
  105. compiler="gcc"
  106. fi
  107. fi
  108. dev_list="host mic"
  109. if [ "$native_mic" -eq "1" ]
  110. then
  111. dev_list="mic"
  112. fi
  113. # prepend mic_params with "--with-mpicc=mpicc -mmic", to allow possible override by the user
  114. if [ $mpi = 1 ]
  115. then
  116. mic_params=("--with-mpicc=mpicc -mmic" "${mic_params[@]}")
  117. mic_params=("--with-mpifort=mpifort -mmic" "${mic_params[@]}")
  118. fi
  119. for arch in $dev_list #host mic
  120. do
  121. # We call the configure script from a build directory further in the
  122. # arborescence
  123. case $ROOT_DIR in
  124. /*) command="${ROOT_DIR}/configure";;
  125. *) command="../${ROOT_DIR}/configure";;
  126. esac
  127. declare -a params
  128. params=("--prefix=$prefix/$arch" "--disable-fstack-protector-all")
  129. if [ "$arch" = mic ] ; then
  130. if [ $compiler = "icc" ] ; then
  131. export CC="icc -mmic"
  132. export CXX="icc -mmic"
  133. export LD="icc -mmic"
  134. export CXXLD="icc -mmic"
  135. export F77="ifort -mmic"
  136. export FC="ifort -mmic"
  137. else
  138. # let configure auto-detect GNU cross-building tools
  139. unset CC
  140. unset CXX
  141. unset LD
  142. unset CXXLD
  143. unset F77
  144. unset FC
  145. params+=(--disable-fortran)
  146. fi
  147. fi
  148. if [ "$native_mic" -eq "0" ]
  149. then
  150. params+=(--enable-mic "--with-coi-dir=$coi_dir" "--with-scif-dir=$scif_dir")
  151. fi
  152. if test x$arch = xmic ; then
  153. params+=(--host=$mic_host --disable-build-doc)
  154. if [ "$native_mic" -eq "1" ]
  155. then
  156. params+=(--enable-maxcpus=250)
  157. else
  158. params+=("--with-coi-lib-dir=$coi_dir/device-linux-release/lib" "--with-scif-lib-dir=$scif_dir/device-linux-release/lib")
  159. fi
  160. else
  161. params+=("--with-coi-lib-dir=$coi_dir/host-linux-release/lib" "--with-scif-lib-dir=$scif_dir/host-linux-release/lib")
  162. fi
  163. # If the build directory doesn't exist yet, create it
  164. if [ ! -d "build_${arch}" ] ; then
  165. mkdir "build_${arch}"
  166. fi
  167. cd "build_${arch}"
  168. if test x$arch = xmic ; then
  169. LIBRARY_PATH=$SINK_LIBRARY_PATH:$MIC_LIBRARY_PATH \
  170. INCLUDE=$SINK_INCLUDE \
  171. C_INCLUDE_PATH=$SINK_C_INCLUDE_PATH \
  172. CPLUS_INCLUDE_PATH=$SINK_CPLUS_INCLUDE_PATH \
  173. PKG_CONFIG_PATH=$SINK_PKG_CONFIG_PATH \
  174. $command "$@" "${params[@]}" "${mic_params[@]}"
  175. MIC_BUILD_ENV="\
  176. LIBRARY_PATH=$SINK_LIBRARY_PATH:$MIC_LIBRARY_PATH \\
  177. INCLUDE=$SINK_INCLUDE \\
  178. C_INCLUDE_PATH=$SINK_C_INCLUDE_PATH \\
  179. CPLUS_INCLUDE_PATH=$SINK_CPLUS_INCLUDE_PATH \\
  180. PKG_CONFIG_PATH=$SINK_PKG_CONFIG_PATH \\\
  181. "
  182. else
  183. $command "$@" "${params[@]}""${host_params[@]}"
  184. fi
  185. if [ "$?" != 0 ]
  186. then
  187. exit $?
  188. fi
  189. cd ..
  190. done
  191. if [ "$native_mic" -eq "1" ]
  192. then
  193. cat > Makefile << EOF
  194. all:
  195. $MIC_BUILD_ENV
  196. \$(MAKE) \$(MFLAGS) -C build_mic
  197. clean:
  198. \$(MAKE) \$(MFLAGS) -C build_mic clean
  199. distclean: clean
  200. rm -f Makefile
  201. check:
  202. $MIC_BUILD_ENV
  203. \$(MAKE) \$(MFLAGS) -C build_mic check
  204. showfailed:
  205. @\$(MAKE) \$(MFLAGS) -C build_mic showfailed
  206. showcheck:
  207. \$(MAKE) \$(MFLAGS) -C build_mic showcheck
  208. install:
  209. $MIC_BUILD_ENV
  210. \$(MAKE) \$(MFLAGS) -C build_mic install
  211. ln -sf "${prefix}/mic/lib/pkgconfig/starpu-1.3.pc" "${prefix}/mic/lib/pkgconfig/starpu-1.3-mic.pc"
  212. EOF
  213. else
  214. cat > Makefile << EOF
  215. all:
  216. \$(MAKE) \$(MFLAGS) -C build_host
  217. $MIC_BUILD_ENV
  218. \$(MAKE) \$(MFLAGS) -C build_mic
  219. clean:
  220. \$(MAKE) \$(MFLAGS) -C build_host clean
  221. \$(MAKE) \$(MFLAGS) -C build_mic clean
  222. distclean: clean
  223. rm -f Makefile
  224. check:
  225. \$(MAKE) \$(MFLAGS) -C build_host check
  226. $MIC_BUILD_ENV
  227. \$(MAKE) \$(MFLAGS) -C build_mic check ; \
  228. RET=\$\$? ; \
  229. STARPU_NCPUS=0 \$(MAKE) \$(MFLAGS) -C build_mic check && [ \$\$RET == 0 ]
  230. showfailed:
  231. @\$(MAKE) \$(MFLAGS) -C build_host showfailed
  232. @\$(MAKE) \$(MFLAGS) -C build_mic showfailed
  233. showcheck:
  234. \$(MAKE) \$(MFLAGS) -C build_host showcheck
  235. \$(MAKE) \$(MFLAGS) -C build_mic showcheck
  236. install:
  237. \$(MAKE) \$(MFLAGS) -C build_host install
  238. $MIC_BUILD_ENV
  239. \$(MAKE) \$(MFLAGS) -C build_mic install
  240. ln -sf "${prefix}/mic/lib/pkgconfig/starpu-1.3.pc" "${prefix}/mic/lib/pkgconfig/starpu-1.3-mic.pc"
  241. EOF
  242. fi