Skip to content

Commit

Permalink
fixed up linn a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
wantonsolutions committed Feb 21, 2017
1 parent 7bf606b commit b89a7dd
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 481 deletions.
1 change: 1 addition & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ TestPrograms/t3/*.txt

examples/ricartagrawala/gonadoresults/*
examples/chainkv/results/*
examples/sum/failed
userstudy/*
419 changes: 7 additions & 412 deletions examples/linear/Shiviz.log

Large diffs are not rendered by default.

27 changes: 15 additions & 12 deletions examples/linear/client/client.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package main

import (
"fmt"
"github.com/arcaneiceman/GoVector/capture"
"bitbucket.org/bestchai/dinv/dinvRT"
"math/rand"
"net"
"os"

"bitbucket.org/bestchai/dinv/dinvRT"
"github.com/arcaneiceman/GoVector/capture"
)

const (
ADDITION_ARGS = 2
LARGEST_TERM = 100
RUNS = 50
ADDITION_ARGS = 2
LARGEST_TERM = 100
RUNS = 50
)

var debug = false
Expand All @@ -26,26 +27,28 @@ func main() {
PrintErr(errDial)

var (
buf [1024]byte
term1, term2, sum int
buf [1024]byte
term1, term2, sum int
)
fmt.Println()
for t := 0; t <= RUNS; t++ {
dinvRT.Track("main_client_32_", "main_client_32_LARGEST_TERM,main_client_32_RUNS,main_client_32_SIZEOFINT,main_client_32_ADDITION_ARGS,main_client_32_debug,main_client_32_rAddr,main_client_32_errR,main_client_32_lAddr,main_client_32_errL,main_client_32_conn,main_client_32_errDial,main_client_32_buf", LARGEST_TERM, RUNS, SIZEOFINT, ADDITION_ARGS, debug, rAddr, errR, lAddr, errL, conn, errDial, buf)
//@track
fmt.Printf("\rExecuting[%2.0f]", float32(t)/float32(RUNS)*100)
term1, term2 = rand.Int()%LARGEST_TERM, rand.Int()%LARGEST_TERM

msg := MarshallInts([]int{term1, term2})
// sending UDP packet to specified address and port
_, errWrite := capture.Write(conn.Write,msg)
_, errWrite := capture.Write(conn.Write, msg)

PrintErr(errWrite)

dinvRT.Track("main_client_42_", "main_client_42_LARGEST_TERM,main_client_42_RUNS,main_client_42_SIZEOFINT,main_client_42_ADDITION_ARGS,main_client_42_debug,main_client_42_rAddr,main_client_42_errR,main_client_42_lAddr,main_client_42_errL,main_client_42_conn,main_client_42_errDial,main_client_42_buf", LARGEST_TERM, RUNS, SIZEOFINT, ADDITION_ARGS, debug, rAddr, errR, lAddr, errL, conn, errDial, buf)
//@track
dinvRT.Track("C-pre", "term1,term2,sum", term1, term2, sum)
// Reading the response message

_, errRead := capture.Read(conn.Read,buf[0:])
dinvRT.Track("main_client_46_", "main_client_46_LARGEST_TERM,main_client_46_RUNS,main_client_46_SIZEOFINT,main_client_46_ADDITION_ARGS,main_client_46_debug,main_client_46_rAddr,main_client_46_errR,main_client_46_lAddr,main_client_46_errL,main_client_46_conn,main_client_46_errDial,main_client_46_buf", LARGEST_TERM, RUNS, SIZEOFINT, ADDITION_ARGS, debug, rAddr, errR, lAddr, errL, conn, errDial, buf)
_, errRead := capture.Read(conn.Read, buf[0:])
dinvRT.Track("C-post", "term1,term2,sum", term1, term2, sum)
//@track
PrintErr(errRead)

uret := UnmarshallInts(buf)
Expand Down
26 changes: 15 additions & 11 deletions examples/linear/coeff/coeff.go
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package main

import (
"fmt"
"math/rand"
"github.com/arcaneiceman/GoVector/capture"
"bitbucket.org/bestchai/dinv/dinvRT"
"net"
"fmt"
"os"

"bitbucket.org/bestchai/dinv/dinvRT"
"github.com/arcaneiceman/GoVector/capture"
)

const (
Expand Down Expand Up @@ -45,8 +46,8 @@ func handleConn(conn net.PacketConn, conn2 *net.UDPConn) {
var term1, term2, coeff int

//read from client
_, addr, err := capture.ReadFrom(conn.ReadFrom,buf[0:])
dinvRT.Track("main_coeff_48_", "main_coeff_48_LARGEST_COEFF,main_coeff_48_SIZEOFINT,main_coeff_48_conn,main_coeff_48_conn2,main_coeff_48_buf,main_coeff_48_term1,main_coeff_48_term2,main_coeff_48_coeff,main_coeff_48_addr,main_coeff_48_err", LARGEST_COEFF, SIZEOFINT, conn, conn2, buf, term1, term2, coeff, addr, err)
_, addr, err := capture.ReadFrom(conn.ReadFrom, buf[0:])
//@track
PrintErr(err)
//unmarshall client arguments
uArgs := UnmarshallInts(buf)
Expand All @@ -57,22 +58,25 @@ func handleConn(conn net.PacketConn, conn2 *net.UDPConn) {
// fmt.Printf("Coeff: T1:%d\tT2:%d\tCoeff:%d\n", term1, term2, coeff)
//}
msg := MarshallInts([]int{term1, term2, coeff})
_, errWrite := capture.Write(conn2.Write,msg)
_, errWrite := capture.Write(conn2.Write, msg)
PrintErr(errWrite)
dinvRT.Track("main_coeff_61_", "main_coeff_61_LARGEST_COEFF,main_coeff_61_SIZEOFINT,main_coeff_61_conn,main_coeff_61_conn2,main_coeff_61_buf,main_coeff_61_term1,main_coeff_61_term2,main_coeff_61_coeff,main_coeff_61_addr,main_coeff_61_err", LARGEST_COEFF, SIZEOFINT, conn, conn2, buf, term1, term2, coeff, addr, err)
//@track
dinvRT.Track("Coe-pre", "term1,term2,coeff", term1, term2, coeff)

//read response from linn server
_, errRead := capture.Read(conn2.Read,buf[0:])
dinvRT.Track("main_coeff_65_", "main_coeff_65_LARGEST_COEFF,main_coeff_65_SIZEOFINT,main_coeff_65_conn,main_coeff_65_conn2,main_coeff_65_buf,main_coeff_65_term1,main_coeff_65_term2,main_coeff_65_coeff,main_coeff_65_addr,main_coeff_65_err", LARGEST_COEFF, SIZEOFINT, conn, conn2, buf, term1, term2, coeff, addr, err)
_, errRead := capture.Read(conn2.Read, buf[0:])
//@track
PrintErr(errRead)
//unmarshall response from linn server
uret := UnmarshallInts(buf)
lin := uret[0]
dinvRT.Track("Coe-mid", "term1,term2,lin", term1, term2, lin)
//fmt.Printf("C: %d*%d + %d = %d\n", coeff, term1, term2, lin)
//marshall response and send back to client
msg2 := MarshallInts([]int{lin})
capture.WriteTo(conn.WriteTo,msg2,addr)
dinvRT.Track("main_coeff_75_", "main_coeff_75_LARGEST_COEFF,main_coeff_75_SIZEOFINT,main_coeff_75_conn,main_coeff_75_conn2,main_coeff_75_buf,main_coeff_75_term1,main_coeff_75_term2,main_coeff_75_coeff,main_coeff_75_addr,main_coeff_75_err", LARGEST_COEFF, SIZEOFINT, conn, conn2, buf, term1, term2, coeff, addr, err)
capture.WriteTo(conn.WriteTo, msg2, addr)
//@track
dinvRT.Track("Coe-post", "term1,term2,lin", term1, term2, lin)
}

const (
Expand Down
16 changes: 9 additions & 7 deletions examples/linear/linn/linn.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"fmt"
"github.com/arcaneiceman/GoVector/capture"
"bitbucket.org/bestchai/dinv/dinvRT"
"net"
"os"

"bitbucket.org/bestchai/dinv/dinvRT"
"github.com/arcaneiceman/GoVector/capture"
)

//var debug = false
Expand Down Expand Up @@ -35,9 +36,10 @@ func handleConn(conn net.PacketConn) {
var buf [1024]byte
var term1, term2, coeff, lin int

_, addr, err := capture.ReadFrom(conn.ReadFrom,buf[0:])
_, addr, err := capture.ReadFrom(conn.ReadFrom, buf[0:])

dinvRT.Track("main_linn_39_", "main_linn_39_SIZEOFINT,main_linn_39_conn,main_linn_39_buf,main_linn_39_term1,main_linn_39_term2,main_linn_39_coeff,main_linn_39_lin,main_linn_39_addr,main_linn_39_err", SIZEOFINT, conn, buf, term1, term2, coeff, lin, addr, err)
//@track
dinvRT.Track("linn-pore", "term1,term2,coeff,lin", term1, term2, coeff, lin)
PrintErr(err)

uArgs := UnmarshallInts(buf)
Expand All @@ -47,9 +49,9 @@ func handleConn(conn net.PacketConn) {
// fmt.Printf("C: %d*%d + %d = %d\n", coeff, term1, term2, lin)
//}
msg := MarshallInts([]int{lin})

dinvRT.Track("main_linn_50_", "main_linn_50_SIZEOFINT,main_linn_50_conn,main_linn_50_buf,main_linn_50_term1,main_linn_50_term2,main_linn_50_coeff,main_linn_50_lin,main_linn_50_addr,main_linn_50_err", SIZEOFINT, conn, buf, term1, term2, coeff, lin, addr, err)
capture.WriteTo(conn.WriteTo,msg,addr)
capture.WriteTo( //@track
conn.WriteTo, msg, addr)
dinvRT.Track("linn-pore", "term1,term2,coeff,lin", term1, term2, coeff, lin)
}

const (
Expand Down
16 changes: 8 additions & 8 deletions examples/linear/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function installDinv {
}

function instrument {
dinv -i -v -dir=$testDir/$1
dinv -i -dir=$testDir/$1
GoVector -v -dir=$testDir/$1
}

Expand Down Expand Up @@ -69,7 +69,7 @@ function runTestPrograms {

function runLogMerger {
cd $testDir
dinv -v -l -name="fruits" -plan="SCM" -shiviz -json *Encoded.txt *Log.txt
dinv -l -name="fruits" -plan="SCM" -shiviz -json *Encoded.txt *Log.txt
}

function runDaikon {
Expand Down Expand Up @@ -97,9 +97,9 @@ function cleanUp {
rm ./*.gz
rm ./*.txt
rm ./*.json
fixModDir $P1
fixModDir $P2
fixModDir $P3
#fixModDir $P1
#fixModDir $P2
#fixModDir $P3

}

Expand All @@ -111,9 +111,9 @@ then
exit
fi
installDinv
instrument $P1
instrument $P2
instrument $P3
#instrument $P1
#instrument $P2
#instrument $P3
runTestPrograms
runLogMerger
shivizMerge
Expand Down
14 changes: 3 additions & 11 deletions examples/sum/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@ import (

const (
LARGEST_TERM = 100
RUNS = 500
RUNS = 5
)

func main() {

a := 1
if a > 0 {
b := 2
b = a
print(a)
}

localAddr, err := net.ResolveUDPAddr("udp4", ":18585")
printErrAndExit(err)
remoteAddr, err := net.ResolveUDPAddr("udp4", ":9090")
Expand All @@ -49,12 +42,11 @@ func reqSum(conn *net.UDPConn, n, m int) (sum int64, err error) {
msg := make([]byte, 256)
binary.PutVarint(msg[:8], int64(n))
binary.PutVarint(msg[8:], int64(m))

fmt.Println(msg)

// after instrumentation
_, err = capture.Write(conn.Write, msg[:])
// _, err = conn.Write(msg)
_, err = conn.Write(msg)
if err != nil {
return
}
Expand All @@ -71,7 +63,7 @@ func reqSum(conn *net.UDPConn, n, m int) (sum int64, err error) {

sum, _ = binary.Varint(buf[0:])

fmt.Println(sum, buf)
//fmt.Println(sum, buf)

dinvRT.Dump("main_client_66_", "main_client_66_LARGEST_TERM,main_client_66_RUNS,main_client_66_conn,main_client_66_n,main_client_66_m,main_client_66_msg", LARGEST_TERM, RUNS, conn, n, m, msg)

Expand Down
2 changes: 1 addition & 1 deletion examples/sum/last_run
24 changes: 14 additions & 10 deletions examples/sum/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ package main
import (
"encoding/binary"
"fmt"
"github.com/arcaneiceman/GoVector/capture"
"net"
"os"

"bitbucket.org/bestchai/dinv/dinvRT"

"github.com/arcaneiceman/GoVector/capture"
)

const addr = ":9090"
Expand Down Expand Up @@ -42,27 +45,28 @@ func listenAndRespond(conn net.PacketConn) (err error) {

//@dump

a, readA := binary.Varint(buf[:8])
b, readB := binary.Varint(buf[8:])
a, _ := binary.Varint(buf[:8])
b, _ := binary.Varint(buf[8:])

sum := a + b

fmt.Println(buf)
fmt.Println(buf[:8], a, readA)
fmt.Println(buf[8:], b, readB)
/*
fmt.Println(buf)
fmt.Println(buf[:8], a, readA)
fmt.Println(buf[8:], b, readB)
*/

fmt.Printf("[SERVER] %d + %d = %d\n", a, b, sum)

msg := make([]byte, 256)
putN := binary.PutVarint(msg, sum)
binary.PutVarint(msg, sum)

fmt.Println(putN, msg)
//fmt.Println(putN, msg)

// after instrumentation:
capture.WriteTo(conn.WriteTo, msg, addr)
// conn.WriteTo(msg, addr)

//@dump
dinvRT.Dump("s64", "sum,a,b", sum, a, b)

return nil
}
3 changes: 1 addition & 2 deletions logmerger/logmerger.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ func statesFromCuts2(cuts []Cut, clocks [][]vclock.VClock, logs [][]Point) []Sta
}
}
state.TotalOrdering = totalOrderFromCut(cut, clocks) //TODO SPEED UP
logger.Printf("%s\n", state.String())
fmt.Printf("\rExtracting states %3.0f%% \t[%d] found", 100*float32(cutIndex)/float32(len(cuts)), len(states))
states = append(states, *state)
}
Expand Down Expand Up @@ -408,7 +407,7 @@ func totalOrderLineNumberMerge(states []State) [][]Point {
points = append(points, state.Points[state.TotalOrdering[j][k]])
}
mergedPoints[i][j] = mergePoints(points)
logger.Printf("Merged points id :%s\n\n===========\n", mergedPoints[i][j].Id)
//logger.Printf("Merged points id :%s\n\n===========\n", mergedPoints[i][j].Id)
}
}
fmt.Println()
Expand Down
16 changes: 9 additions & 7 deletions programslicer/programBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import (
"fmt"
"go/ast"
"go/parser"
"go/printer"
"go/token"
"log"
"os"

"go/printer"
"go/types"

"bitbucket.org/bestchai/dinv/programslicer/cfg"
"bitbucket.org/bestchai/dinv/programslicer/dataflow"
"go/types"
"golang.org/x/tools/go/loader"
)

Expand Down Expand Up @@ -59,9 +60,9 @@ type CFGWrapper struct {
ObjNames map[*types.Var]string
}

func LoadProgram(SourceFiles []*ast.File, config loader.Config) (*loader.Program, error) {
func LoadProgram(path string, SourceFiles []*ast.File, config loader.Config) (*loader.Program, error) {
//fmt.Println("Loading Packages")
config.CreateFromFiles("testing", SourceFiles...)
config.CreateFromFiles(path, SourceFiles...)
Prog, err := config.Load()
if err != nil {
return nil, err
Expand All @@ -86,7 +87,7 @@ func GetWrapperFromString(SourceString string) (*ProgramWrapper, error) {
Filename := Comments.Name.String()
//make the single files the head of a list
Sources := append(make([]*ast.File, 0), Source)
Prog, err := LoadProgram(Sources, config)
Prog, err := LoadProgram("string", Sources, config)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -137,7 +138,8 @@ func GetProgramWrapperDirectory(dir string) (*ProgramWrapper, error) {
for i := range SourceFiles {
aggergateSources = append(aggergateSources, SourceFiles[i]...)
}
Prog, err := LoadProgram(aggergateSources, config)
log.Printf("Instrumenting %d sources", len(aggergateSources))
Prog, err := LoadProgram(dir, aggergateSources, config)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -184,7 +186,7 @@ func (p *ProgramWrapper) Refresh() error {
for i := range sourceFiles {
aggergateSources = append(aggergateSources, sourceFiles[i]...)
}
prog, err := LoadProgram(aggergateSources, config)
prog, err := LoadProgram("", aggergateSources, config)
if err != nil {
return err
}
Expand Down

0 comments on commit b89a7dd

Please sign in to comment.