Skip to content
Snippets Groups Projects
Commit 310694e0 authored by Sander Mathijs van Veen's avatar Sander Mathijs van Veen
Browse files

Fixed 'float vs double' source file.

parent edff8604
No related branches found
No related tags found
No related merge requests found
...@@ -3,3 +3,4 @@ speed ...@@ -3,3 +3,4 @@ speed
fp fp
float_double float_double
report.pdf report.pdf
fd*
CC=clang
FLAGS=-Wall -Wextra -std=c99 -pedantic -O0 -lm FLAGS=-Wall -Wextra -std=c99 -pedantic -O0 -lm
TYPES=float double LD TYPES=float double LD
OPS=ADD DIV MULT SQRT OPS=ADD DIV MULT SQRT
all: fp speed report.pdf float_double all: fp speed report.pdf fd
%.pdf: %.tex %.pdf: %.tex
pdflatex $^ pdflatex $^
...@@ -12,23 +13,29 @@ speed: speed.c ...@@ -12,23 +13,29 @@ speed: speed.c
for t in $(TYPES); do \ for t in $(TYPES); do \
for o in $(OPS); do \ for o in $(OPS); do \
sed "s#{TYPE}#$$t#" $^ | sed "s#{OP}#$$o#" > speed.$$t.$$o.c; \ sed "s#{TYPE}#$$t#" $^ | sed "s#{OP}#$$o#" > speed.$$t.$$o.c; \
gcc $(FLAGS) -o speed.$$t.$$o speed.$$t.$$o.c; \ $(CC) $(FLAGS) -o speed.$$t.$$o speed.$$t.$$o.c; \
rm speed.$$t.$$o.c; \ rm speed.$$t.$$o.c; \
done; \ done; \
done; done;
touch $@ touch $@
fp: floating_point.o fp: floating_point.o
gcc $(FLAGS) -o $@ $^ $(CC) $(FLAGS) -o $@ $^
float_double: float_vs_double.o fd: float_vs_double.c
gcc $(FLAGS) -o $@ $^ for t in float double; do \
sed "s#{TYPE}#$$t#" $^ > fd.$$t.c; \
$(CC) $(FLAGS) -o fd.$$t fd.$$t.c; \
rm fd.$$t.c; \
done;
touch $@
%.o: %.c %.o: %.c
gcc $(FLAGS) -o $@ -c $^ $(CC) $(FLAGS) -o $@ -c $^
%.s: %.c %.s: %.c
gcc $(FLAGS) -o $* $^ $(CC) $(FLAGS) -o $* $^
clean: clean:
rm -vf *.o *.i *.s fp speed speed.*.* floating_point rm -vf *.o *.i *.s fp fd* speed speed.*.* floating_point \
report.pdf *.aux *.log *.toc
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
{TYPE} sum_forward(int N);
{TYPE} sum_backward(int N);
int main(void) { int main(void) {
puts("Using type {TYPE}."); puts("Using type {TYPE}.");
...@@ -32,3 +35,4 @@ int main(void) { ...@@ -32,3 +35,4 @@ int main(void) {
return sum; return sum;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment