mic-configure 4.9 KB

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