mic-configure 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 [ $compiler = "icc" -a "$arch" = "mic" ] ; then
  72. export CC="icc -mmic"
  73. export CXX="icc -mmic"
  74. export LD="icc -mmic"
  75. export CXXLD="icc -mmic"
  76. export F77="ifort -mmic"
  77. export FC="ifort -mmic"
  78. fi
  79. params="--prefix=$prefix/$arch"
  80. if [ "$native_mic" -eq "0" ]
  81. then
  82. params="$params --enable-mic --with-coi-dir=$coi_dir --with-scif-dir=$scif_dir"
  83. fi
  84. if test x$arch = xmic ; then
  85. params="$params --disable-build-doc --host=$mic_host"
  86. if [ "$native_mic" -eq "1" ]
  87. then
  88. params="$params --enable-maxcpus=250"
  89. else
  90. params="$params --with-coi-lib-dir=$coi_dir/device-linux-release/lib --with-scif-lib-dir=$scif_dir/device-linux-release/lib"
  91. fi
  92. else
  93. params="$params --with-coi-lib-dir=$coi_dir/host-linux-release/lib --with-scif-lib-dir=$scif_dir/host-linux-release/lib"
  94. fi
  95. # If the build directory doesn't exist yet, create it
  96. if [ ! -d "build_${arch}" ] ; then
  97. mkdir "build_${arch}"
  98. fi
  99. cd "build_${arch}"
  100. if test x$arch = xmic ; then
  101. LIBRARY_PATH=$SINK_LIBRARY_PATH \
  102. INCLUDE=$SINK_INCLUDE \
  103. C_INCLUDE_PATH=$SINK_C_INCLUDE_PATH \
  104. CPLUS_INCLUDE_PATH=$SINK_CPLUS_INCLUDE_PATH \
  105. PKG_CONFIG_PATH=$SINK_PKG_CONFIG_PATH \
  106. $command "$@" $params $mic_params
  107. else
  108. $command "$@" $params $host_params
  109. fi
  110. if [ "$?" != 0 ]
  111. then
  112. exit $?
  113. fi
  114. cd ..
  115. done
  116. if [ "$native_mic" -eq "1" ]
  117. then
  118. cat > Makefile << EOF
  119. all:
  120. \$(MAKE) -C build_mic
  121. clean:
  122. \$(MAKE) -C build_mic clean
  123. distclean: clean
  124. rm -f Makefile
  125. check:
  126. \$(MAKE) -C build_mic check
  127. showcheck:
  128. \$(MAKE) -C build_mic showcheck
  129. install:
  130. \$(MAKE) -C build_mic install
  131. ln -sf "${prefix}/mic/lib/pkgconfig/starpu-1.3.pc" "${prefix}/mic/lib/pkgconfig/starpu-1.3-mic.pc"
  132. EOF
  133. else
  134. cat > Makefile << EOF
  135. all:
  136. \$(MAKE) -C build_host
  137. \$(MAKE) -C build_mic
  138. clean:
  139. \$(MAKE) -C build_host clean
  140. \$(MAKE) -C build_mic clean
  141. distclean: clean
  142. rm -f Makefile
  143. check:
  144. \$(MAKE) -C build_host check
  145. \$(MAKE) -C build_mic check ; \
  146. RET=\$\$? ; \
  147. STARPU_NCPUS=0 \$(MAKE) -C build_mic check && [ \$\$RET == 0 ]
  148. showcheck:
  149. \$(MAKE) -C build_host showcheck
  150. \$(MAKE) -C build_mic showcheck
  151. install:
  152. \$(MAKE) -C build_host install
  153. \$(MAKE) -C build_mic install
  154. ln -sf "${prefix}/mic/lib/pkgconfig/starpu-1.3.pc" "${prefix}/mic/lib/pkgconfig/starpu-1.3-mic.pc"
  155. EOF
  156. fi