Skip to content

Commit 3fd43d2

Browse files
committed
created Enzyme differentiation test file for the Nonbond term
1 parent da111ba commit 3fd43d2

File tree

6 files changed

+15
-27
lines changed

6 files changed

+15
-27
lines changed

Diff for: tlm1_simple/makefile

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1+
CC = g++
2+
CFLAGS = -march=native -mavx
13

2-
ENZYME_so=../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-15.so
3-
4-
all-simple: cmp-simple ad-simple opt-simple lower-simple
5-
echo done
6-
7-
cmp-simple:
8-
clang-15 simple.c -S -emit-llvm -o simple-cmp.ll -O2 -fno-vectorize -fno-slp-vectorize -fno-unroll-loops
9-
10-
ad-simple:
11-
opt-15 simple-cmp.ll -enable-new-pm=0 -load=$(ENZYME_so) --enzyme -o simple-ad.ll -S
12-
13-
opt-simple:
14-
opt-15 simple-ad.ll -O2 -o simple-opt.ll -S
15-
16-
lower-simple:
17-
clang-15 -o simple simple-opt.ll
4+
vector_demo: vector_demo.cc
5+
$(CC) $(CFLAGS) -o vector_demo vector_demo.cc
186

197
clean:
20-
rm -f simple *.ll *~
8+
rm -f vector_demo

Diff for: tlm2_stretch/makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
ENZYME_so=../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-15.so
3-
2+
#ENZYME_so=/home/bike/src/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-15.so
43
all-stretch: cmp-stretch ad-stretch opt-stretch lower-stretch
54
echo done
65

Diff for: tlm2_stretch/stretch.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <cstdio>
33
#include <string>
44
#include <cmath>
5-
5+
#include <immintrin.h> // Include SIMD intrinsics header
66
int enzyme_dup;
77
int enzyme_out;
88
int enzyme_const;
@@ -79,7 +79,7 @@ float old_stretch_energy(Stretch* stretch_begin, Stretch* stretch_end, float* po
7979
bool calcForce = true;
8080
#define STRETCH_CALC_FORCE 1
8181
for ( auto stretch = stretch_begin; stretch<stretch_end; stretch++ ) {
82-
#include "_Stretch_termCode.cc"
82+
#include "_Stretch_termCode .cc"
8383
}
8484
#undef DECLARE_FLOAT
8585
#undef STRETCH_SET_PARAMETER
@@ -94,11 +94,10 @@ void zeroVec(float* deriv, size_t num) {
9494
}
9595
}
9696
int main( int argc, const char* argv[] ) {
97-
float pos[12] = {0.0, 19.0, 3.0, 10.0, 7.0, 80.0,
98-
20.0, 15.0, 17.0, 25.0, 44.0, 23.0 };
97+
float pos[12] = {0.0, 19.0,3.0, 10.0, 7.0, 80.0,
98+
20.0, 15.0,17.0, 25.0, 44.0, 23.0 };
9999
float deriv[12];
100100
Stretch stretch[] = { {10.0, 2.0, 0, 3}, {20.0, 3.0, 6, 9} };
101-
102101
dump_vec("pos", pos, 12);
103102
float energy = 0.0;
104103
std::string arg1(argv[1]);
@@ -122,3 +121,4 @@ int main( int argc, const char* argv[] ) {
122121
dump_vec("deriv", deriv, 12);
123122

124123
}
124+

Diff for: tlm3_dihedral/makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
ENZYME_so=../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-15.so
2+
#ENZYME_so=../../Enzyme/enzyme/build/Enzyme/LLVMEnzyme-15.so
3+
ENZYME_so=/home/bike/src/Enzyme/enzyme/build/Enzyme/LLVMEnzyme-15.so
34

45
all-Dihed: cmp-Dihed ad-Dihed opt-Dihed lower-Dihed
56
echo done

Diff for: tlm4_nonbond/_NonbondEnergy_termCode.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
tx22 = power2(tx19); /* rule 22 */
2424
tx23 = power2(tx20); /* rule 23 */
2525
DistanceSquared = tx21 + tx22 + tx23; /* rule 24 */
26-
BAIL_OUT_IF_CUTOFF(DistanceSquared)
26+
BAIL_OUT_IF_CUTOFF(DistanceSquared);
2727
tx35 = reciprocal(DistanceSquared); /* rule 26 */
2828
tx33 = power2(tx35); /* rule 27 */
2929
tx34 = tx35; /* rule 28 */

Diff for: tlm4_nonbond/_Nonbond_termCode.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
tx88 = power2(tx85); /* rule 22 */
2424
tx89 = power2(tx86); /* rule 23 */
2525
DistanceSquared = tx87 + tx88 + tx89; /* rule 24 */
26-
BAIL_OUT_IF_CUTOFF(DistanceSquared)
26+
BAIL_OUT_IF_CUTOFF(DistanceSquared);
2727
tx192 = reciprocal(DistanceSquared); /* rule 26 */
2828
tx171 = power2(tx192); /* rule 27 */
2929
tx172 = tx192; /* rule 28 */

0 commit comments

Comments
 (0)