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