mic-configure 5.7 KB

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