support for turning on/off detecting conflict optimizations
[IRC.git] / Robust / src / buildscript
index f052798d4992414a9e331818a0c469c84709f2d7..2a016acdba145a031273ab95dcf201e845e66b77 100755 (executable)
@@ -1,11 +1,45 @@
 #!/bin/bash
 
 printhelp() {
+echo -robustroot set up the ROBUSTROOT to directory other than default one
+echo -dsm distributed shared memory
+echo -singleTM single machine committing transactions
+echo -abortreaders abort readers immediately
+echo -trueprob double - probabiltiy of true branch
+echo -dsmcaching -enable caching in dsm runtime
+echo -mac distributed shared memory mac support
 echo -check generate check code
 echo -dmalloc link in dmalloc
+echo -64bit compile for 64 bit machine
+echo -joptimize java compiler optimizations
+echo -dcopts conflict optimizations for transactional memory
 echo -recover compile task code
+echo -fastcheck fast checkpointing for Bristlecone
 echo -specdir directory
+echo -printflat print out flat representation
+echo -selfloop task - this task cannot self loop forever
+echo "-excprefetch methoddescriptor - exclude prefetches for this method (specified as class.method)"
+echo -taskstate do task state analysis
+echo -tagstate do tag state analysis
+echo -scheduling do task scheduling
+echo -multicore generate multi-core version binary
+echo "-numcore set the number of cores (should be used together with -multicore), defaultly set as 1"
+echo "-raw generate raw version binary (should be used together with -multicore)"
+echo "-rawcacheflush enable cache flush in raw version binary (should be used togethere with -raw)"
+echo "-interrupt generate raw version binary with interruption (should be used togethere with -raw)"
+echo "-rawconfig config raw simulator as 4xn (should be used together with -raw)"
+echo "-rawpath print out execute path information for raw version (should be used together with -raw)"
+echo "-useprofile use profiling data for scheduling (should be used together with -raw)"
+echo -threadsimulate generate multi-thread simulate version binary
+echo -printscheduling print out scheduling graphs
+echo -printschedulesim print out scheduling simulator result graphs
+echo -abcclose close the array boundary check
+echo -optional enable optional
 echo -debug generate debug symbols
+echo -prefetch do prefetch analysis
+echo -transstats generates transaction stats on commits and aborts
+echo -garbagestats Print garbage collection statistics
+echo -webinterface enable web interface
 echo -runtimedebug printout runtime debug messages
 echo "-thread use support for multiple threads"
 echo "-optimize call gcc with -O9 (optimize)"
@@ -13,22 +47,48 @@ echo "-nooptimize call gcc with -O0 (do not optimize)"
 echo -curdir directory 
 echo -mainclass class with main method
 echo -o binary
+echo -nojava do not run bristlecone compiler
 echo -instructionfailures inject code for instructionfailures
+echo -profile build with profile options
+echo "-rawuseio use standard io to output profiling data (should be used together with -raw and -profile), it only works with single core version"
+echo "-enable-assertions execute assert statements during compilation"
+echo -justanalyze exit after compiler analyses complete
 echo -help help
 }
 
+ABORTREADERS=false;
 ROBUSTROOT=~/research/Robust/src
+DSMRUNTIME=$ROBUSTROOT/Runtime/DSTM/interface/
 REPAIRROOT=~/research/Repair/RepairCompiler/
 CURDIR=`pwd`
+DSMFLAG=false
+SINGLETM=false
+NOJAVA=false
 CHECKFLAG=false
 RECOVERFLAG=false
+MLPFLAG=false
+MLPDEBUG=false
+MULTICOREFLAG=false
+RAWFLAG=false
+RAWCACHEFLUSHFLAG=false
+RAWCONFIG=''
+RAWDEBUGFLAG=false
+RAWPATHFLAG=false
+RAWPROFILEFLAG=false
+RAWUSEIOFLAG=false
+INTERRUPTFLAG=false
+THREADSIMULATEFLAG=false;
 USEDMALLOC=false
 THREADFLAG=false
+FASTCHECK=false
 SPECDIR=`pwd`
 SRCFILES=''
 EXTRAOPTIONS=''
 MAINFILE='a'
+JAVAFORWARDOPTS=''
 JAVAOPTS=''
+OPTIONALFLAG=false
+EXITAFTERANALYSIS=false
 
 if [[ -z $1 ]]
 then
@@ -42,6 +102,32 @@ if [[ $1 = '-help' ]]
 then
 printhelp
 exit
+elif [[ $1 = '-justanalyze' ]]
+then
+EXITAFTERANALYSIS=true
+elif [[ $1 = '-abortreaders' ]]
+then
+ABORTREADERS=true
+EXTRAOPTIONS="$EXTRAOPTIONS -DABORTREADERS"
+JAVAOPTS="$JAVAOPTS -abortreaders"
+elif [[ $1 = '-robustroot' ]]
+then
+ROBUSTROOT="$2"
+shift
+elif [[ $1 = '-nojava' ]]
+then
+NOJAVA=true
+elif [[ $1 = '-garbagestats' ]]
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DGARBAGESTATS"
+elif [[ $1 = '-64bit' ]]
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DBIT64"
+elif [[ $1 = '-fastcheck' ]]
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DFASTCHECK"
+JAVAOPTS="$JAVAOPTS -fastcheck"
+FASTCHECK=true
 elif [[ $1 = '-o' ]]
 then
 MAINFILE="$2"
@@ -50,6 +136,87 @@ elif [[ $1 = '-mainclass' ]]
 then
 JAVAOPTS="$JAVAOPTS -mainclass $2"
 shift
+elif [[ $1 = '-selfloop' ]]
+then
+JAVAOPTS="$JAVAOPTS -selfloop $2"
+shift
+elif [[ $1 = '-excprefetch' ]]
+then
+JAVAOPTS="$JAVAOPTS -excprefetch $2"
+shift
+elif [[ $1 = '-dsm' ]]
+then
+JAVAOPTS="$JAVAOPTS -dsm"
+DSMFLAG=true
+elif [[ $1 = '-singleTM' ]]
+then
+JAVAOPTS="$JAVAOPTS -singleTM"
+EXTRAOPTIONS="$EXTRAOPTIONS -DSTM"
+SINGLETM=true
+elif [[ $1 = '-prefetch' ]]
+then
+JAVAOPTS="$JAVAOPTS -prefetch"
+elif [[ $1 = '-transstats' ]]
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DTRANSSTATS"
+elif [[ $1 = '-printflat' ]]
+then
+JAVAOPTS="$JAVAOPTS -printflat"
+elif [[ $1 = '-trueprob' ]]
+then
+JAVAOPTS="$JAVAOPTS -trueprob $2"
+shift
+elif [[ $1 = '-mac' ]]
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DMAC"
+elif [[ $1 = '-profile' ]]
+then
+RAWPROFILEFLAG=true
+EXTRAOPTIONS="$EXTRAOPTIONS -pg"
+elif [[ $1 = '-rawuseio' ]]
+then
+RAWUSEIOFLAG=true
+elif [[ $1 = '-taskstate' ]]
+then
+JAVAOPTS="$JAVAOPTS -taskstate"
+elif [[ $1 = '-tagstate' ]]
+then
+JAVAOPTS="$JAVAOPTS -tagstate"
+elif [[ $1 = '-scheduling' ]]
+then
+JAVAOPTS="$JAVAOPTS -scheduling"
+elif [[ $1 = '-multicore' ]]
+then
+MULTICOREFLAG=true
+JAVAOPTS="$JAVAOPTS -multicore"
+elif [[ $1 = '-numcore' ]]
+then
+JAVAOPTS="$JAVAOPTS -numcore $2"
+shift
+elif [[ $1 = '-raw' ]]
+then
+RAWFLAG=true
+JAVAOPTS="$JAVAOPTS -raw"
+elif [[ $1 = '-rawcacheflush' ]]
+then
+RAWCACHEFLUSHFLAG=true
+elif [[ $1 = '-rawconfig' ]]
+then
+RAWCONFIG="$2"
+shift
+elif [[ $1 = '-interrupt' ]]
+then
+INTERRUPTFLAG=true
+elif [[ $1 = '-threadsimulate' ]]
+then
+THREADSIMULATEFLAG=true
+elif [[ $1 = '-abcclose' ]]
+then
+JAVAOPTS="$JAVAOPTS -abcclose"
+elif [[ $1 = '-optional' ]]
+then
+JAVAOPTS="$JAVAOPTS -optional"
+OPTIONALFLAG=true
 elif [[ $1 = '-dmalloc' ]]
 then
 USEDMALLOC=true
@@ -57,13 +224,34 @@ elif [[ $1 = '-recover' ]]
 then
 RECOVERFLAG=true
 JAVAOPTS="$JAVAOPTS -task"
+elif [[ $1 = '-useprofile' ]]
+then
+JAVAOPTS="$JAVAOPTS -useprofile"
+elif [[ $1 = '-webinterface' ]]
+then
+JAVAOPTS="$JAVAOPTS -webinterface"
 elif [[ $1 = '-instructionfailures' ]]
 then
 JAVAOPTS="$JAVAOPTS -instructionfailures"
+elif [[ $1 = '-joptimize' ]]
+then
+JAVAOPTS="$JAVAOPTS -optimize"
+elif [[ $1 = '-dcopts' ]]
+then
+JAVAOPTS="$JAVAOPTS -dcopts"
+elif [[ $1 = '-mlp' ]]
+then
+JAVAOPTS="$JAVAOPTS -mlp"
+elif [[ $1 = '-mlpdebug' ]]
+then
+JAVAOPTS="$JAVAOPTS -mlpdebug"
 elif [[ $1 = '-check' ]]
 then
 CHECKFLAG=true
 JAVAOPTS="$JAVAOPTS -conscheck"
+elif [[ $1 = '-enable-assertions' ]]
+then
+JAVAFORWARDOPTS="$JAVAFORWARDOPTS -ea"
 elif [[ $1 = '-specdir' ]]
 then
 cd $2
@@ -72,10 +260,20 @@ cd $CURDIR
 shift
 elif [[ $1 = '-debug' ]]
 then
+RAWDEBUGFLAG=true
 EXTRAOPTIONS="$EXTRAOPTIONS -g"
+elif [[ $1 = '-rawpath' ]]
+then
+RAWPATHFLAG=true
 elif [[ $1 = '-runtimedebug' ]]
 then
 EXTRAOPTIONS="$EXTRAOPTIONS -DDEBUG"
+elif [[ $1 = '-dsmcaching' ]]
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DCACHE"
+elif [[ $1 = '-rangeprefetch' ]]
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DRANGEPREFETCH"
 elif [[ $1 = '-nooptimize' ]]
 then
 EXTRAOPTIONS="$EXTRAOPTIONS -O0"
@@ -87,10 +285,17 @@ then
 JAVAOPTS="$JAVAOPTS -thread"
 EXTRAOPTIONS="$EXTRAOPTIONS -DTHREADS -lpthread"
 THREADFLAG=true
+elif [[ $1 = '-distributioninfo' ]]
+then
+JAVAOPTS="$JAVAOPTS -distributioninfo"
 elif [[ $1 = '-curdir' ]]
 then
 CURDIR=$2
 shift
+elif [[ $1 = '-outputdir' ]]
+then
+JAVAOPTS="$JAVAOPTS -outputdir $2"
+shift
 else
 SRCFILES="$SRCFILES $1"
 fi
@@ -110,11 +315,60 @@ then
 JAVAOPTS="$JAVAOPTS -struct structfile"
 fi
 
+# Setup class path
+
+if $RECOVERFLAG
+then
+if $FASTCHECK
+then
+#fast transactions
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/FastCheck"
+else
+#base bristlecone files
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/Bristlecone"
+fi
+else
+if $DSMFLAG
+then
+#dsm stuff
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/JavaDSM"
+elif $SINGLETM
+then
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/JavaSTM"
+elif $THREADFLAG
+then
+#threading java stuff
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/JavaThread"
+fi
+#base java stuff
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/Java"
+fi
+
 # Build bristlecone/java sources
 
-java -cp $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
-$ROBUSTROOT/ClassLibrary/ -dir $BUILDDIR -precise \
+if $MULTICOREFLAG
+then
+if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx800m $JAVAFORWARDOPTS -classpath $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
+$ROBUSTROOT/ClassLibrary/ -classlibrary $ROBUSTROOT/ClassLibrary/gnu/ \
+-dir $BUILDDIR $JAVAOPTS $SRCFILES
+then exit $?
+fi
+else
+#if ! ${ROBUSTROOT}/ourjava -Xms5m -Xmx100m $JAVAFORWARDOPTS -classpath $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
+if ! $NOJAVA
+then
+if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx600m $JAVAFORWARDOPTS -classpath $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
+$ROBUSTROOT/ClassLibrary/ -classlibrary $ROBUSTROOT/ClassLibrary/gnu/ -dir $BUILDDIR -precise \
 $JAVAOPTS $SRCFILES
+then exit $?
+fi
+fi
+fi
+
+if $EXITAFTERANALYSIS
+then
+exit
+fi
 
 # Build all of the consistency specs
 
@@ -147,28 +401,143 @@ cd $BUILDDIR/specdir
 echo > $BUILDDIR/checkers.h
 for i in `cat $BUILDDIR/specs`
 do
-gcc -O0 -g -c $i\_aux.c
+gcc -O0 -g -fbounds-check -c $i\_aux.c
 echo \#include \"specdir\/$i\_aux.h\" >> $BUILDDIR/checkers.h
 done
 fi # CHECKFLAG
 
 #build and link everything
 
+if $RAWFLAG
+then # RAWFLAG
+RAWDIR="$CURDIR/raw"
+MAKEFILE="../Makefile.raw"
+mkdir $RAWDIR
+cd $RAWDIR
+make clean
+rm ./*
+
+export RAWRGCCFLAGS="-DTASK -DMULTICORE -DRAW"
+
+if $RAWCACHEFLUSHFLAG
+then # print path
+RAWRGCCFLAGS="${RAWRGCCFLAGS} -DRAWCACHEFLUSH"
+fi
+
+if $RAWPATHFLAG
+then # print path
+RAWRGCCFLAGS="${RAWRGCCFLAGS} -DRAWPATH"
+fi
+
+if $RAWDEBUGFLAG
+then #debug version
+RAWRGCCFLAGS="${RAWRGCCFLAGS} -DRAWDEBUG"
+fi
+
+if $RAWPROFILEFLAG
+then # profile version
+RAWRGCCFLAGS="${RAWRGCCFLAGS} -DRAWPROFILE"
+fi
+
+if $RAWUSEIOFLAG
+then # useio version
+RAWRGCCFLAGS="${RAWRGCCFLAGS} -DRAWUSEIO"
+fi
+
+if $INTERRUPTFLAG
+then #INTERRUPT version
+RAWRGCCFLAGS="${RAWRGCCFLAGS} -DINTERRUPT"
+fi #INTERRUPT version
+
+if $RAWUSEIOFLAG
+then # useio version
+MAKEFILE="$MAKEFILE.io"
+echo "+++++++++++use Makefile.raw.io++++++++++++++++"
+else
+MAKEFILE="$MAKEFILE.$RAWCONFIG"
+fi #useio version
+
+cp $MAKEFILE ./Makefile
+cp ../Runtime/*.c ./
+cp ../Runtime/*.h ./
+cp ../Runtime/*.S ./
+cp ../Runtime/*.s ./
+cp ../tmpbuilddirectory/*.c ./
+cp ../tmpbuilddirectory/*.h ./
+
+make
+
+else #!RAWFLAG
 cd $CURDIR 
 
 INCLUDES="$INCLUDES -I$ROBUSTROOT/Runtime -I. -IRuntime/include \
 -I$BUILDDIR"
 
-FILES="$ROBUSTROOT/Runtime/runtime.c $ROBUSTROOT/Runtime/file.c \
-$ROBUSTROOT/Runtime/Queue.c $ROBUSTROOT/Runtime/SimpleHash.c \
-$ROBUSTROOT/Runtime/option.c $ROBUSTROOT/Runtime/garbage.c \
-$ROBUSTROOT/Runtime/socket.c $ROBUSTROOT/Runtime/GenericHashtable.c \
-$ROBUSTROOT/Runtime/object.c"
+if $MULTICOREFLAG
+then
+RUNTIMEFILE="$ROBUSTROOT/Runtime/multicoreruntime.c $ROBUSTROOT/Runtime/multicoretask.c"
+else
+RUNTIMEFILE="$ROBUSTROOT/Runtime/runtime.c $ROBUSTROOT/Runtime/task.c"
+fi
+
+FILES="$RUNTIMEFILE \
+$ROBUSTROOT/Runtime/file.c $ROBUSTROOT/Runtime/Queue.c \
+$ROBUSTROOT/Runtime/SimpleHash.c $ROBUSTROOT/Runtime/option.c \
+$ROBUSTROOT/Runtime/ObjectHash.c \
+$ROBUSTROOT/Runtime/garbage.c $ROBUSTROOT/Runtime/socket.c \
+$ROBUSTROOT/Runtime/math.c \
+$ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c"
+
+if $DSMFLAG
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -DCOMPILER -DDSTM -I$DSMRUNTIME"
+FILES="$FILES $DSMRUNTIME/trans.c $DSMRUNTIME/mcpileq.c $DSMRUNTIME/objstr.c $DSMRUNTIME/dstm.c $DSMRUNTIME/mlookup.c $DSMRUNTIME/clookup.c $DSMRUNTIME/llookup.c $DSMRUNTIME/threadnotify.c $DSMRUNTIME/dstmserver.c $DSMRUNTIME/plookup.c $DSMRUNTIME/ip.c $DSMRUNTIME/queue.c $DSMRUNTIME/prelookup.c $DSMRUNTIME/machinepile.c $ROBUSTROOT/Runtime/localobjects.c $ROBUSTROOT/Runtime/thread.c $DSMRUNTIME/sockpool.c $DSMRUNTIME/addUdpEnhance.c $DSMRUNTIME/signal.c $DSMRUNTIME/gCollect.c $DSMRUNTIME/addPrefetchEnhance.c $DSMRUNTIME/dsmlock.c $DSMRUNTIME/prefetch.c"
+fi
+
+if $SINGLETM
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -DCOMPILER -I$DSMRUNTIME"
+FILES="$FILES $DSMRUNTIME/dsmlock.c $DSMRUNTIME/singleTMCommit.c $DSMRUNTIME/stmlookup.c $ROBUSTROOT/Runtime/thread.c"
+fi
+
+if $ABORTREADERS
+then
+FILES="$FILES $DSMRUNTIME/abortreaders.c"
+fi
+
+if $FASTCHECK
+then
+FILES="$FILES $ROBUSTROOT/Runtime/localobjects.c"
+fi
+
+if $MLP
+then
+FILES="$FILES $ROBUSTROOT/Runtime/mlp_runtime.c"
+fi
 
 if $RECOVERFLAG
 then
 EXTRAOPTIONS="$EXTRAOPTIONS -DTASK"
-FILES="$FILES tmpbuilddirectory/taskdefs.c $ROBUSTROOT/Runtime/checkpoint.c"
+if $MULTICOREFLAG
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DMULTICORE"
+fi
+FILES="$FILES tmpbuilddirectory/taskdefs.c $ROBUSTROOT/Runtime/checkpoint.c $ROBUSTROOT/Runtime/chash.c"
+if $RAWFLAG
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DRAW"
+fi
+if $THREADSIMULATEFLAG
+then
+# -lpthread for pthread functions, -lrt for message queue functions
+EXTRAOPTIONS="$EXTRAOPTIONS -DTHREADSIMULATE -lpthread -lrt"
+fi
+fi
+
+if $OPTIONALFLAG
+then
+EXTRAOPTIONS="$EXTRAOPTIONS -DOPTIONAL"
+FILES="$FILES tmpbuilddirectory/optionalarrays.c"
 fi
 
 if $THREADFLAG
@@ -187,7 +556,16 @@ then
 EXTRAOPTIONS="$EXTRAOPTIONS -ldmalloc -DDMALLOC"
 fi
 
+if $MULTICOREFLAG
+then
+gcc $INCLUDES $EXTRAOPTIONS \
+tmpbuilddirectory/methods.c $FILES -lm -o $MAINFILE.bin
+else
 gcc $INCLUDES $EXTRAOPTIONS -DPRECISE_GC \
-tmpbuilddirectory/methods.c $FILES -o $MAINFILE.bin
+tmpbuilddirectory/methods.c $FILES -lm -o $MAINFILE.bin
+fi
+
+fi #!RAWFLAG
 
 exit
+