You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.4 KiB

  1. #!/bin/sh
  2. #
  3. # Copyright 2005-2013 Intel Corporation. All Rights Reserved.
  4. #
  5. # This file is part of Threading Building Blocks.
  6. #
  7. # Threading Building Blocks is free software; you can redistribute it
  8. # and/or modify it under the terms of the GNU General Public License
  9. # version 2 as published by the Free Software Foundation.
  10. #
  11. # Threading Building Blocks is distributed in the hope that it will be
  12. # useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  13. # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Threading Building Blocks; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. #
  20. # As a special exception, you may use this file as part of a free software
  21. # library without restriction. Specifically, if other files instantiate
  22. # templates or use macros or inline functions from this file, or you compile
  23. # this file and link it with other files to produce an executable, this
  24. # file does not by itself cause the resulting executable to be covered by
  25. # the GNU General Public License. This exception does not however
  26. # invalidate any other reasons why the executable file might be covered by
  27. # the GNU General Public License.
  28. while getopts "ul:" flag #
  29. do case $flag in #
  30. l ) if [ `uname` != 'Linux' ] ; then #
  31. echo 'skip' #
  32. exit #
  33. fi #
  34. LD_PRELOAD=$OPTARG ;; #
  35. u ) # Set stack limit
  36. ulimit -s 10240 ;; #
  37. esac done #
  38. shift `expr $OPTIND - 1` #
  39. if [ $OFFLOAD_EXECUTION ] ; then #
  40. if [ -z $MIC_CARD ] ; then #
  41. MIC_CARD=mic0 #
  42. fi #
  43. TMPDIR_HOST=$(mktemp -d /tmp/libtbbmallocXXXXXX) #
  44. TMPDIR_MIC=$(sudo ssh $MIC_CARD mktemp -d /tmp/libtbbmallocXXXXXX) #
  45. sudo ssh $MIC_CARD "chmod +x $TMPDIR_MIC" #
  46. cp "./mic/libtbbmalloc"* "$TMPDIR_HOST" >/dev/null 2>/dev/null #
  47. sudo scp "$TMPDIR_HOST"/* $MIC_CARD:"$TMPDIR_MIC" >/dev/null 2>/dev/null #
  48. LD_LIBRARY_PATH=$TMPDIR_MIC:$LD_LIBRARY_PATH #
  49. export LD_LIBRARY_PATH #
  50. fi #
  51. # Run the command line passed via parameters
  52. export LD_PRELOAD #
  53. ./$* #
  54. exitcode=$? #
  55. if [ $OFFLOAD_EXECUTION ] ; then #
  56. sudo ssh $MIC_CARD rm -fr "$TMPDIR_MIC" >/dev/null 2>/dev/null #
  57. rm -fr "$TMPDIR_HOST" >/dev/null 2>/dev/null #
  58. fi #
  59. exit ${exitcode} #