mic-configure 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. for arg in $*
  12. do
  13. case $arg in
  14. --prefix=*)
  15. prefix="${arg#--prefix=}"
  16. ;;
  17. --with-coi-dir=*)
  18. coi_dir="${arg#--with-coi-dir=}"
  19. ;;
  20. --with-scif-dir=*)
  21. scif_dir="${arg#--with-scif-dir=}"
  22. ;;
  23. --mic-host=*)
  24. mic_host="${arg#--mic-host=}"
  25. ;;
  26. esac
  27. done
  28. # Test gcc compiler
  29. x=$(type -t ${mic_host}-gcc)
  30. if [ -z "$x" ]
  31. then
  32. # Test icc compiler
  33. echo "int main(int argc, char **argv) { return 0; }" > /tmp/icc_$USER_$$.c
  34. icc -mmic /tmp/icc_$USER_$$.c > /dev/null 2>/tmp/icc_$USER_$$.err
  35. l=$(grep -c "invalid argument" /tmp/icc_$USER_$$.err)
  36. if [ "$l" != "0" ]
  37. then
  38. echo "[error] no compiler found. please add path to either ${mic_host}-gcc or to an enabled mic icc compiler in your PATH"
  39. exit 1
  40. else
  41. compiler="icc"
  42. fi
  43. else
  44. compiler="gcc"
  45. fi
  46. for arch in host mic
  47. do
  48. # We call the configure script from a build directory further in the
  49. # arborescence
  50. case $ROOT_DIR in
  51. /*) command="${ROOT_DIR}/configure";;
  52. *) command="../${ROOT_DIR}/configure";;
  53. esac
  54. if [ $compiler = "icc" -a "$arch" = "mic" ] ; then
  55. export CC="icc -mmic"
  56. export CXX="icc -mmic"
  57. fi
  58. params="--enable-mic --with-coi-dir=$coi_dir --with-scif-dir=$scif_dir --prefix=$prefix/$arch"
  59. if test x$arch = xmic ; then
  60. # TODO: fix hwloc detection to look for another pkg-config place, and not just believe in the host version of hwloc.pc...
  61. params="$params --without-hwloc --with-coi-lib-dir=$coi_dir/device-linux-release/lib --with-scif-lib-dir=$scif_dir/device-linux-release/lib --host=$mic_host"
  62. else
  63. params="$params --with-coi-lib-dir=$coi_dir/host-linux-release/lib --with-scif-lib-dir=$scif_dir/host-linux-release/lib"
  64. fi
  65. # If the build directory doesn't exist yet, create it
  66. if [ ! -d "build_${arch}" ] ; then
  67. mkdir "build_${arch}"
  68. fi
  69. cd "build_${arch}"
  70. if test x$arch = xmic ; then
  71. LDFLAGS=-export-dynamic $command $* $params
  72. else
  73. $command $* $params
  74. fi
  75. if [ "$?" != 0 ]
  76. then
  77. exit $?
  78. fi
  79. cd ..
  80. done
  81. cat > Makefile << EOF
  82. all:
  83. \$(MAKE) -C build_host
  84. \$(MAKE) -C build_mic
  85. clean:
  86. \$(MAKE) -C build_host clean
  87. \$(MAKE) -C build_mic clean
  88. distclean: clean
  89. rm -f Makefile
  90. check:
  91. \$(MAKE) -C build_host check
  92. \$(MAKE) -C build_mic check
  93. showcheck:
  94. \$(MAKE) -C build_host showcheck
  95. \$(MAKE) -C build_mic showcheck
  96. install:
  97. \$(MAKE) -C build_host install
  98. \$(MAKE) -C build_mic install
  99. ln -sf "${prefix}/mic/lib/pkgconfig/starpu-1.2.pc" "${prefix}/mic/lib/pkgconfig/starpu-1.2-mic.pc"
  100. EOF