mic-configure 3.6 KB

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