mic-configure 3.8 KB

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