mic-configure 6.3 KB

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