Skip to content

Commit e77af86

Browse files
committed
Move OpenMP examples into their own dedicated folder.
1 parent c4b47fa commit e77af86

File tree

7 files changed

+31
-14
lines changed

7 files changed

+31
-14
lines changed

openmp/parallel_for/Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CLANG = /home/lpaehler/Work/Dev-Tools/llvm-fortran/f18-llvm-project/build/bin/clang
2+
3+
LLVM_PATH = /home/lpaehler/Work/Dev-Tools/llvm-fortran/f18-llvm-project/build
4+
5+
ENZYME_PATH = /home/lpaehler/Work/AutomaticDifferentiation/Enzyme/build/Enzyme/LLVMEnzyme-13.so
6+
LLVM13_PATH = /home/lpaehler/Work/AutomaticDifferentiation/llvm-project/build
7+
8+
all: omp_parallel_simple.o
9+
10+
clean:
11+
rm -f *.o *.ll
12+
13+
%.o: %.c
14+
$(LLVM_PATH)/bin/clang++ -O3 -Xclang -load -Xclang $(ENZYME_PATH) -ffast-math -fopenmp -o /host/$@
15+
16+
run-%: %.o
17+
../dockerscript.sh /host/$^

P5_omp_parallel_for/Makefile renamed to openmp/parallel_for/OldMakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ clean:
44
rm -f *.o *.ll
55

66
%.o: %.c
7-
../dockerscript.sh clang-12 /host/$^ -O3 -Xclang -load -Xclang /Enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so -ffast-math -fopenmp -o /host/$@
7+
../dockerscript.sh clang-12 /host/$^ -O3 -Xclang -load -Xclang /Enzyme/enzyme/build/Enzyme/ClangEnzyme-12.so -ffast-math -fopenmp=libomp -o /host/$@
88

99
run-%: %.o
10-
../dockerscript.sh /host/$^
10+
../dockerscript.sh /host/$^

P5_omp_parallel_for/omp_parallel_for.c renamed to openmp/parallel_for/omp_parallel_for.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ int main() {
1717

1818
// Initialize array
1919
float array[1000];
20-
for(int i=0, i<1000; i++) {
20+
for(int i=0; i<1000; i++) {
2121
array[i] = i + 0.5;
2222
}
2323

2424
// Set up the array to host the gradients
2525
float d_array[1000];
26-
for(int i=0, i<1000; i++) {
26+
for(int i=0; i<1000; i++) {
2727
d_array[i] = 1.0f;
2828
}
2929

@@ -35,4 +35,4 @@ int main() {
3535
#endif
3636

3737
return 0;
38-
}
38+
}
File renamed without changes.

P4_omp_parallel_simple/omp_parallel.c renamed to openmp/parallel_simple/omp_parallel.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Change the array entries
44
void subdomain_change(float *x, int istart, int ipoints) {
55
int i;
6-
for (i = 0, i < ipoints; i++) {
6+
for (i = 0; i < ipoints; i++) {
77
x[istart+i] = x[i] + i;
88
}
99
}
@@ -31,28 +31,28 @@ void sub(float *x, int npoints) {
3131
}
3232

3333

34-
double __enzyme_autodiff(void*, ...);
34+
void __enzyme_autodiff(void*, ...);
3535

3636
int main() {
3737

3838
// Initialize array
3939
float array[1000];
40-
for(int i=0, i<1000; i++) {
40+
for(int i=0; i<1000; i++) {
4141
array[i] = 0.0;
4242
}
4343

4444
// Set up the array to host the gradients
4545
float d_array[1000];
46-
for(int i=0, i<1000; i++) {
46+
for(int i=0; i<1000; i++) {
4747
d_array[i] = 1.0f;
4848
}
4949

5050
// Alter the entries
51-
#ifdef FORWARD
51+
// #ifdef FORWARD
5252
sub(array, 1000);
53-
#else
54-
__enzyme_autodiff((void*)sub, array, d_array, 1000);
55-
#endif
53+
// #else
54+
// __enzyme_autodiff((void*)sub, array, d_array, 1000);
55+
// #endif
5656

5757
return 0;
58-
}
58+
}

0 commit comments

Comments
 (0)