@@ -69,13 +69,29 @@ profiled:
6969 rm -f * .a * .o timing
7070 make CFLAGS=" $( CFLAGS) -fbranch-probabilities"
7171
72+ # run tune first, than optimize branching
73+ profiled_tuned : tune
74+ make CFLAGS=" $( CFLAGS) -fprofile-arcs" timing
75+ ./timing
76+ rm -f * .a * .o timing
77+ make CFLAGS=" $( CFLAGS) -fbranch-probabilities"
78+
79+ # run tune first, optimize branching, run tune again
80+ # (running it in a loop until the timings stabilize is indeed tempting)
81+ profiled_tuned_tuned : tune
82+ make CFLAGS=" $( CFLAGS) -fprofile-arcs" timing
83+ ./timing
84+ rm -f * .a * .o timing
85+ make CFLAGS=" $( CFLAGS) -fbranch-probabilities"
86+ ./etc/tune_it.sh
87+
7288# make a single object profiled library
7389amalgamated_timing : pre_gen
7490 $(CC ) $(LTM_CFLAGS ) -fprofile-arcs -c pre_gen/tommath_amalgam.c -o tommath_amalgam.o
7591 $(CC ) $(LTM_CFLAGS ) -DMP_VERSION=\" before\" demo/timing.c tommath_amalgam.o -lgcov -o timing
7692
7793
78- amalgamated_timingtuned : tune pre_gen
94+ amalgamated_timing_tuned : tune pre_gen
7995 $(CC ) $(LTM_CFLAGS ) -fprofile-arcs -c pre_gen/tommath_amalgam.c -o tommath_amalgam.o
8096 $(CC ) $(LTM_CFLAGS ) -DMP_VERSION=\" before\" demo/timing.c tommath_amalgam.o -lgcov -o timing
8197
@@ -85,6 +101,30 @@ profiled_single: amalgamated_timing
85101 $(CC ) $(LTM_CFLAGS ) -fbranch-probabilities -c pre_gen/tommath_amalgam.c -o tommath_amalgam.o
86102 $(AR ) $(ARFLAGS ) $(LIBNAME ) tommath_amalgam.o
87103
104+ # run tune first, than optimize branching
105+ profiled_single_tuned : amalgamated_timing_tuned
106+ ./timing
107+ rm -f * .a * .o timing
108+ $(CC ) $(LTM_CFLAGS ) -fbranch-probabilities -c pre_gen/tommath_amalgam.c -o tommath_amalgam.o
109+ $(AR ) $(ARFLAGS ) $(LIBNAME ) tommath_amalgam.o
110+
111+ # run tune first, optimize branching, run tune again
112+ # (running it in a loop until the timings stabilize is indeed tempting)
113+ profiled_single_tuned_tuned : amalgamated_timing_tuned
114+ ./timing
115+ rm -f * .o timing
116+ $(CC ) $(LTM_CFLAGS ) -fbranch-probabilities -c pre_gen/tommath_amalgam.c -o tommath_amalgam.o
117+ $(AR ) $(ARFLAGS ) $(LIBNAME ) tommath_amalgam.o
118+ rm -f etc/tune.o
119+ $(CC ) $(LTM_CFLAGS ) -c etc/tune.c -o etc/tune.o
120+ $(CC ) $(LTM_CFLAGS ) tommath_amalgam.o etc/tune.o -o etc/tune
121+ ./etc/tune_it.sh
122+ rm -f * .a * .o
123+ $(CC ) $(LTM_CFLAGS ) -fprofile-arcs -c pre_gen/tommath_amalgam.c -o tommath_amalgam.o
124+ $(CC ) $(LTM_CFLAGS ) -fbranch-probabilities -c pre_gen/tommath_amalgam.c -o tommath_amalgam.o
125+ $(AR ) $(ARFLAGS ) $(LIBNAME ) tommath_amalgam.o
126+
127+
88128install : $(LIBNAME ) .install_common
89129 install -m 644 $(LIBNAME ) $(DESTDIR )$(LIBPATH )
90130 install -m 644 $(HEADERS_PUB ) $(DESTDIR )$(INCPATH )
@@ -136,7 +176,12 @@ cmp: profiled_single
136176 ./timing
137177 $(MAKE ) -C logs/ cmp
138178
139- cmptuned : profiled_single tune
179+ cmp_tuned : profiled_single_tuned
180+ $(CC ) $(LTM_CFLAGS ) -DMP_VERSION=\" after\" demo/timing.c $(LIBNAME ) -lgcov -o timing
181+ ./timing
182+ $(MAKE ) -C logs/ cmp
183+
184+ cmp_tuned_tuned : profiled_single_tuned_tuned
140185 $(CC ) $(LTM_CFLAGS ) -DMP_VERSION=\" after\" demo/timing.c $(LIBNAME ) -lgcov -o timing
141186 ./timing
142187 $(MAKE ) -C logs/ cmp
0 commit comments