mic-configure 6.6 KB

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