mic-configure 3.8 KB

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