mic-configure 3.8 KB

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