mic-configure 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. fi
  116. fi
  117. declare -a params
  118. params=("--prefix=$prefix/$arch")
  119. if [ "$native_mic" -eq "0" ]
  120. then
  121. params+=(--enable-mic "--with-coi-dir=$coi_dir" "--with-scif-dir=$scif_dir")
  122. fi
  123. if test x$arch = xmic ; then
  124. params+=(--disable-build-doc --host=$mic_host)
  125. if [ "$native_mic" -eq "1" ]
  126. then
  127. params+=(--enable-maxcpus=250)
  128. else
  129. params+=("--with-coi-lib-dir=$coi_dir/device-linux-release/lib" "--with-scif-lib-dir=$scif_dir/device-linux-release/lib")
  130. fi
  131. else
  132. params+=("--with-coi-lib-dir=$coi_dir/host-linux-release/lib" "--with-scif-lib-dir=$scif_dir/host-linux-release/lib")
  133. fi
  134. # If the build directory doesn't exist yet, create it
  135. if [ ! -d "build_${arch}" ] ; then
  136. mkdir "build_${arch}"
  137. fi
  138. cd "build_${arch}"
  139. if test x$arch = xmic ; then
  140. LIBRARY_PATH=$SINK_LIBRARY_PATH \
  141. INCLUDE=$SINK_INCLUDE \
  142. C_INCLUDE_PATH=$SINK_C_INCLUDE_PATH \
  143. CPLUS_INCLUDE_PATH=$SINK_CPLUS_INCLUDE_PATH \
  144. PKG_CONFIG_PATH=$SINK_PKG_CONFIG_PATH \
  145. $command "$@" "${params[@]}" "${mic_params[@]}"
  146. else
  147. $command "$@" "${params[@]}""${host_params[@]}"
  148. fi
  149. if [ "$?" != 0 ]
  150. then
  151. exit $?
  152. fi
  153. cd ..
  154. done
  155. if [ "$native_mic" -eq "1" ]
  156. then
  157. cat > Makefile << EOF
  158. all:
  159. \$(MAKE) -C build_mic
  160. clean:
  161. \$(MAKE) -C build_mic clean
  162. distclean: clean
  163. rm -f Makefile
  164. check:
  165. \$(MAKE) -C build_mic check
  166. showcheck:
  167. \$(MAKE) -C build_mic showcheck
  168. install:
  169. \$(MAKE) -C build_mic install
  170. ln -sf "${prefix}/mic/lib/pkgconfig/starpu-1.3.pc" "${prefix}/mic/lib/pkgconfig/starpu-1.3-mic.pc"
  171. EOF
  172. else
  173. cat > Makefile << EOF
  174. all:
  175. \$(MAKE) -C build_host
  176. \$(MAKE) -C build_mic
  177. clean:
  178. \$(MAKE) -C build_host clean
  179. \$(MAKE) -C build_mic clean
  180. distclean: clean
  181. rm -f Makefile
  182. check:
  183. \$(MAKE) -C build_host check
  184. \$(MAKE) -C build_mic check ; \
  185. RET=\$\$? ; \
  186. STARPU_NCPUS=0 \$(MAKE) -C build_mic check && [ \$\$RET == 0 ]
  187. showcheck:
  188. \$(MAKE) -C build_host showcheck
  189. \$(MAKE) -C build_mic showcheck
  190. install:
  191. \$(MAKE) -C build_host install
  192. \$(MAKE) -C build_mic install
  193. ln -sf "${prefix}/mic/lib/pkgconfig/starpu-1.3.pc" "${prefix}/mic/lib/pkgconfig/starpu-1.3-mic.pc"
  194. EOF
  195. fi