mic-configure 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. export LD="icc -mmic"
  58. fi
  59. params="--enable-mic --with-coi-dir=$coi_dir --with-scif-dir=$scif_dir --prefix=$prefix/$arch"
  60. if test x$arch = xmic ; then
  61. # TODO: fix hwloc detection to look for another pkg-config place, and not just believe in the host version of hwloc.pc...
  62. 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"
  63. else
  64. params="$params --with-coi-lib-dir=$coi_dir/host-linux-release/lib --with-scif-lib-dir=$scif_dir/host-linux-release/lib"
  65. fi
  66. # If the build directory doesn't exist yet, create it
  67. if [ ! -d "build_${arch}" ] ; then
  68. mkdir "build_${arch}"
  69. fi
  70. cd "build_${arch}"
  71. if test x$arch = xmic ; then
  72. LDFLAGS=-export-dynamic $command $* $params
  73. else
  74. $command $* $params
  75. fi
  76. if [ "$?" != 0 ]
  77. then
  78. exit $?
  79. fi
  80. cd ..
  81. done
  82. cat > Makefile << EOF
  83. all:
  84. \$(MAKE) -C build_host
  85. \$(MAKE) -C build_mic
  86. clean:
  87. \$(MAKE) -C build_host clean
  88. \$(MAKE) -C build_mic clean
  89. distclean: clean
  90. rm -f Makefile
  91. check:
  92. \$(MAKE) -C build_host check
  93. \$(MAKE) -C build_mic check
  94. install:
  95. \$(MAKE) -C build_host install
  96. \$(MAKE) -C build_mic install
  97. ln -sf "${prefix}/mic/lib/pkgconfig/starpu-1.2.pc" "${prefix}/mic/lib/pkgconfig/starpu-1.2-mic.pc"
  98. EOF