CFLAGS=-O

bench: test
	papiex -q -e PAPI_TOT_CYC -e PAPI_TOT_INS -e PAPI_BR_MSP -e PAPI_FP_OPS shortest-path <input-bench-littleendian >/dev/null

test: shortest-path
	shortest-path <input-ref-littleendian|diff -u - output-ref
	shortest-path <input-bench-littleendian|diff -u - output-bench

shortest-path: shortest-path.c
	gcc ${CFLAGS} shortest-path.c -o shortest-path

clean:
	rm shortest-path

# du brauchst: valgrind kcachegrind und ev. callgrind (sollte bei valgrind dabei sein)
# make profile erstellt solche files: callgrind.out.$$
# die kann man mit kcachegrind oeffnen
profile: 
	gcc ${CFLAGS} shortest-path.c -o shortest-path-debug -g
	valgrind --dump-instr=yes --trace-jump=yes   --tool=callgrind  ./shortest-path-debug < input-bench-littleendian > /dev/null

# target for profiling functions. in order to do this, inlining must be disabled
profile-uninlined:
	# NOTE: some static functions are inlined anyway, prevent by using: static __attribute__ ((noinline)) void function() 
	gcc ${CFLAGS} -finline-limit=0 shortest-path.c -o shortest-path-uninlined -g
	valgrind --dump-instr=yes --trace-jump=yes   --tool=callgrind  ./shortest-path-uninlined < input-bench-littleendian > /dev/null

profile-shark:
	gcc ${CFLAGS} shortest-path.c -o shortest-path-sdbg -g
	shark -i ./shortest-path <input-ref-littleendian > /dev/null

coverage:
	gcc ${CFLAGS} --coverage -lm shortest-path.c -o shortest-path-coverage
	./shortest-path-coverage < input-bench-littleendian > /dev/null
	gcov shortest-path
	less shortest-path.c.gcov


