Skip to content

Commit

Permalink
Add building script and enable OpenMP in AMR example
Browse files Browse the repository at this point in the history
  • Loading branch information
ouankou committed Jul 23, 2020
1 parent d499805 commit 33cfe33
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ charmrun
ampirun
pgm
*.swp
jacobi.out
8 changes: 8 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Build Charm++ and its AMR library.

./build charm++ multicore-linux-x86_64

cd src/libs/ck-libs/amr/
make
cd -
9 changes: 5 additions & 4 deletions examples/amr/jacobi2D/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
CHARMDIR=../../..
CHARMC=$(CHARMDIR)/bin/charmc $(OPTS)
AMRLIB=$(CHARMDIR)/lib/libamr.a
FLAGS=-fopenmp

DEST=jacobi
OBJS = jacobi2DAMR.o
DEST=jacobi.out
OBJS=jacobi2DAMR.o

all: $(DEST)

$(DEST): $(OBJS)
$(CHARMC) -lm -language charm++ -o $(DEST) $(OBJS) $(AMRLIB)
$(CHARMC) $(FLAGS) -lm -language charm++ -o $(DEST) $(OBJS) $(AMRLIB)
chmod 755 $(DEST)

jacobi2DAMR.o: jacobi2DAMR.C jacobi2DAMR.decl.h jacobi2DAMR.def.h
$(CHARMC) -g -c jacobi2DAMR.C
$(CHARMC) $(FLAGS) -g -c jacobi2DAMR.C

jacobi2DAMR.decl.h jacobi2DAMR.def.h: jacobi2DAMR.ci
$(CHARMC) jacobi2DAMR.ci
Expand Down
8 changes: 4 additions & 4 deletions examples/amr/jacobi2D/jacobi2DAMR.C
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ void AmrUserData :: deleteChildData(void* data)

void Jacobi2DAMR :: doComputation(void)
{
for(int i=1; i <= cellSize ;i++)
for(int j=1; j<=cellSize;j++)
newDataGrid[i][j] = 0.2 * (dataGrid[i][j-1] + dataGrid[i][j+1]
+dataGrid[i][j] +dataGrid[i-1][j] +dataGrid[i+1][j]);
#pragma omp parallel for
for(int i=1; i<=cellSize; i++)
for(int j=1; j<=cellSize; j++)
newDataGrid[i][j] = 0.2 * (dataGrid[i][j-1] + dataGrid[i][j+1] +dataGrid[i][j] + dataGrid[i-1][j] + dataGrid[i+1][j]);
copyGrid();

}
Expand Down
2 changes: 1 addition & 1 deletion examples/amr/jacobi2D/jacobi2DAMR.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Jacobi2DAMR:public AmrUserData {

public:
Jacobi2DAMR() {
cellSize = 64;
cellSize = 512;
dataGrid = new double* [cellSize+2];
newDataGrid = new double* [cellSize+2];
for(int i=0;i< cellSize+2;i++) {
Expand Down

0 comments on commit 33cfe33

Please sign in to comment.