pluto makefile, and polycc , source code analysis

1) how to print current screen in ubuntu

alt+ print screen

2) we can see the exe polycc and Makefile

3) the makefile has these code:

polycc: polycc.sh
	echo "#! " $(BASH) > polycc
	cat polycc.sh >> polycc
	chmod ugo+x polycc

so the polycc is a shell script.

4)the polycc script:

#!  /bin/bash
#!/bin/bash
#
# Top-level script that runs all components of the end-to-end
# system
#
# Just run 'polycc <C code>' when the program section to
# be parallelized/optimized around special comments as described
# in the `README'
#
# Copyright (C) 2007-2008 Uday Bondhugula
#
# This file is available under the MIT license. Please see LICENSE in the
# top-level directory for details.
#
pluto=/home/a/src/a1.pluto/pluto/tool/pluto
inscop=/home/a/src/a1.pluto/pluto/inscop

# Some additional setup here to ensure that variables are visible outside of the
# run function.
SOURCEFILE=""
OUTFILE=""
dirname=""
PLUTOOUT=""

# check for command-line options
for arg in $*; do
    if [ $arg == "--parallel" ]; then
        PARALLEL=1
    elif [ $arg == "--parallelize" ]; then
        PARALLEL=1
    elif [ $arg == "--unroll" ]; then
        UNROLL=1
    elif [ $arg == "--debug" ]; then
        DEBUG=1
    elif [ $arg == "--moredebug" ]; then
        DEBUG=1
    elif [ $arg == "-i" ]; then
        INDENT=1
    elif [ $arg == "--indent" ]; then
        INDENT=1
    elif [ $arg == "--silent" ]; then
        SILENT=1
    fi
done

# some special processing for linearized accesses
#if [ "$SOURCEFILE" != "" ]; then
#grep __SPECIAL $SOURCEFILE > .nonlinearized
#grep __SPECIAL $SOURCEFILE | sed -e "s/.*__SPECIAL//" > .linearized
#fi

run()
{
$pluto $* || exit 1

SOURCEFILE=`cat .srcfilename`
OUTFILE=`cat .outfilename`

dirname=`dirname  $SOURCEFILE`
basename=`basename $SOURCEFILE`
prefix=`basename $SOURCEFILE .c`

CLOOGFILE=`basename $OUTFILE`.pluto.cloog
PLUTOOUT=$OUTFILE

# put the original skeleton around the transformed code
$inscop $SOURCEFILE $OUTFILE $OUTFILE

if [ "$INDENT" == 1 ] && [ -x /usr/bin/clang-format ]; then
    clang-format --style=LLVM -i $OUTFILE
fi
}

run "$*"
WORK=1
TEMPFILE=""
while [ $WORK -eq 1 ]
do
  if grep -q "#pragma scop" "$PLUTOOUT"
  then
    # Move the original file into a temporary location
    TEMPFILE="$SOURCEFILE""_temp"
    mv $SOURCEFILE $TEMPFILE

    # Move the file that still has scope in it into
    # place of the original source file, so $* will pick the
    # correct file
    mv $PLUTOOUT $SOURCEFILE

    # Run pluto again
    run "$*"

    # Move the original back in place
    mv $TEMPFILE $SOURCEFILE
  else
    # No more scops
    WORK=0
  fi
done

cleanup() {
  # An attempt to move the original file back in place
  # in the event of an exception.
  if [ -f "$TEMPFILE" ]
  then
    mv $TEMPFILE $SOURCEFILE
  fi
  if [ "$DEBUG" != 1 ];
  then
    rm -f .regtile .vectorize .pragmas .params .orcc .linearized .nonlinearized \
      $CLOOGFILE .srcfilename .outfilename .distmem pi.cloog sigma.cloog \
      *.sysloog .appendfilename
  fi
}

trap cleanup SIGINT exit

not too long

4)the true compile command:

/home/a/src/a1.pluto/pluto/tool/pluto heat-2d.c --noparallel --pet -o heat-2d.tiled.c

5) we can see the exe pluto in the directory tool:

a@a:~/src/a1.pluto/pluto/tool$ ls
ast_transform.c        main.cpp     osl_pluto.c       pluto-ast_transform.o        pluto-main.o
ast_transform.h        Makefile     osl_pluto.h       pluto_codegen_if.c           pluto-osl_pluto.o
constraints_polylib.c  Makefile.am  pet_to_pluto.cpp  pluto_codegen_if.h           pluto-pet_to_pluto.o
constraints_polylib.h  Makefile.in  pluto             pluto-constraints_polylib.o  pluto-pluto_codegen_if.o

6)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值