Skip to content

Commit 9cae171

Browse files
committed
Push down the numbering of the batch example.
1 parent 1a23326 commit 9cae171

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Diff for: 8_batch/Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
all: batch.o
2+
3+
clean:
4+
rm -f *.o *.ll
5+
6+
%.o: %.c
7+
../dockerscript.sh clang-12 /host/$^ -O3 -Xclang -load -Xclang /Enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so -ffast-math -o /host/$@
8+
9+
run-%: %.o
10+
../dockerscript.sh /host/$^ 3.14

Diff for: 8_batch/batch.c

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <stdio.h>
2+
3+
struct Vector {
4+
double x1, x2, x3, x4;
5+
};
6+
7+
extern Vector __enzyme_batch(...);
8+
9+
extern int enzyme_width;
10+
extern int enzyme_vector;
11+
extern int enzyme_scalar;
12+
13+
double square(double x) { return x * x; }
14+
15+
Vector vecsquare(double x1, double x2, double x3, double x4) {
16+
return __enzyme_batch(square, enzyme_width, 4, enzyme_vector, x1, x2, x3, x4);
17+
}
18+
int main() {
19+
double vals[] = {23.1, 10.0, 100.0, 3.14};
20+
double expected[] = {square(vals[0]), square(vals[1]), square(vals[2]),
21+
square(vals[3])};
22+
Vector result = vecsquare(vals[0], vals[1], vals[2], vals[3]);
23+
}

0 commit comments

Comments
 (0)