mic-configure 4.0 KB

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