mic-configure 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. native_mic=0
  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. --enable-native-mic)
  28. native_mic=1
  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. dev_list="host mic"
  51. if [ "$native_mic" -eq "1" ]
  52. then
  53. dev_list="mic"
  54. fi
  55. for arch in $dev_list #host mic
  56. do
  57. # We call the configure script from a build directory further in the
  58. # arborescence
  59. case $ROOT_DIR in
  60. /*) command="${ROOT_DIR}/configure";;
  61. *) command="../${ROOT_DIR}/configure";;
  62. esac
  63. if [ $compiler = "icc" -a "$arch" = "mic" ] ; then
  64. export CC="icc -mmic"
  65. export CXX="icc -mmic"
  66. export LD="icc -mmic"
  67. export CXXLD="icc -mmic"
  68. fi
  69. params="--enable-mic --with-coi-dir=$coi_dir --with-scif-dir=$scif_dir --prefix=$prefix/$arch"
  70. if test x$arch = xmic ; then
  71. if [ "$native_mic" -eq "1" ]
  72. then
  73. 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"
  74. else
  75. # TODO: fix hwloc detection to look for another pkg-config place, and not just believe in the host version of hwloc.pc...
  76. params="$params --disable-build-doc -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"
  77. fi
  78. else
  79. params="$params --with-coi-lib-dir=$coi_dir/host-linux-release/lib --with-scif-lib-dir=$scif_dir/host-linux-release/lib"
  80. fi
  81. # If the build directory doesn't exist yet, create it
  82. if [ ! -d "build_${arch}" ] ; then
  83. mkdir "build_${arch}"
  84. fi
  85. cd "build_${arch}"
  86. if test x$arch = xmic ; then
  87. LDFLAGS=-export-dynamic $command $* $params
  88. else
  89. $command $* $params
  90. fi
  91. if [ "$?" != 0 ]
  92. then
  93. exit $?
  94. fi
  95. cd ..
  96. done
  97. if [ "$native_mic" -eq "1" ]
  98. then
  99. cat > Makefile << EOF
  100. all:
  101. \$(MAKE) -C build_mic
  102. clean:
  103. \$(MAKE) -C build_mic clean
  104. distclean: clean
  105. rm -f Makefile
  106. check:
  107. \$(MAKE) -C build_mic check
  108. showcheck:
  109. \$(MAKE) -C build_mic showcheck
  110. install:
  111. \$(MAKE) -C build_mic install
  112. ln -sf "${prefix}/mic/lib/pkgconfig/starpu-1.3.pc" "${prefix}/mic/lib/pkgconfig/starpu-1.3-mic.pc"
  113. EOF
  114. else
  115. cat > Makefile << EOF
  116. all:
  117. \$(MAKE) -C build_host
  118. \$(MAKE) -C build_mic
  119. clean:
  120. \$(MAKE) -C build_host clean
  121. \$(MAKE) -C build_mic clean
  122. distclean: clean
  123. rm -f Makefile
  124. check:
  125. \$(MAKE) -C build_host check
  126. \$(MAKE) -C build_mic check
  127. showcheck:
  128. \$(MAKE) -C build_host showcheck
  129. \$(MAKE) -C build_mic showcheck
  130. install:
  131. \$(MAKE) -C build_host install
  132. \$(MAKE) -C build_mic install
  133. ln -sf "${prefix}/mic/lib/pkgconfig/starpu-1.3.pc" "${prefix}/mic/lib/pkgconfig/starpu-1.3-mic.pc"
  134. EOF
  135. fi