Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrantq committed Oct 4, 2024
1 parent e3aa2bc commit f9823f6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
11 changes: 7 additions & 4 deletions example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ FPOPTFLAGS += -mllvm --enzyme-enable-fpopt \
-mllvm --enzyme-print-herbie \
-mllvm --enzyme-print-fpopt \
-mllvm --fpopt-log-path=example.txt \
-mllvm --fpopt-target-func-regex=Pendulum \
-mllvm --fpopt-target-func-regex=example \
-mllvm --fpopt-enable-solver \
-mllvm --fpopt-comp-cost-budget=1000
-mllvm --fpopt-enable-pt \
-mllvm --fpopt-comp-cost-budget=0 \
-mllvm --fpopt-num-samples=1000 \
-mllvm --fpopt-cost-model-path=microbm/cm.csv

SRC ?= example.c
LOGGER ?= fp-logger.cpp
Expand All @@ -29,10 +32,10 @@ EXE ?= example.exe example-logged.exe example-fpopt.exe
all: $(EXE)

example.cpp: $(SRC)
python3 fpopt-original-driver-generator.py $(SRC) "Pendulum"
python3 fpopt-original-driver-generator.py $(SRC) example

example-logged.cpp: $(SRC)
python3 fpopt-logged-driver-generator.py $(SRC) "Pendulum"
python3 fpopt-logged-driver-generator.py $(SRC) example

example.exe: example.cpp
$(CXX) -Wall -O3 example.cpp $(CXXFLAGS) -o $@
Expand Down
40 changes: 15 additions & 25 deletions example/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,19 @@
#define TRUE 1
#define FALSE 0

// ## PRE t0: -2, 2
// ## PRE w0: -5, 5
// ## PRE N: 1000, 1000
double Pendulum(double t0, double w0, double N) {
double h = 0.01;
double L = 2.0;
double m = 1.5;
double g = 9.80665;
double t = t0;
double w = w0;
double n = 0.0;
int tmp = n < N;
while (tmp) {
double k1w = (-g / L) * sin(t);
double k2t = w + ((h / 2.0) * k1w);
double t_1 = t + (h * k2t);
double k2w = (-g / L) * sin((t + ((h / 2.0) * w)));
double w_2 = w + (h * k2w);
double n_3 = n + 1.0;
t = t_1;
w = w_2;
n = n_3;
tmp = n < N;
}
return t;
// ## PRE c: 1, 9
// ## PRE a: 1, 9
// ## PRE b: 1, 9
double example(double a, double b, double c) {
double tmp;
if (a < b) {
tmp = sqrt(((((c + (b + a)) * (a - (c - b))) * (a + (c - b))) *
(c + (b - a)))) /
4.0;
} else {
tmp = sqrt(((((c + (a + b)) * (b - (c - a))) * (b + (c - a))) *
(c + (a - b)))) /
4.0;
}
return tmp;
}
File renamed without changes.

0 comments on commit f9823f6

Please sign in to comment.