Skip to content

Commit

Permalink
added an example that uses Proto
Browse files Browse the repository at this point in the history
  • Loading branch information
dtgraves committed Mar 23, 2020
1 parent c00e7b6 commit 88fb333
Show file tree
Hide file tree
Showing 15 changed files with 1,258 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/mk/Make.defs.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- Mode: Makefile; -*-

## Set the configuration string used in filenames.
## `Make.rules' is the only Chombo makefile that uses this file, but
Expand Down Expand Up @@ -71,14 +70,15 @@ _md := $(subst FALSE,,$(subst TRUE,md,$(MULTIDIM)))
_pic := $(subst FALSE,,$(subst TRUE,.pic,$(PIC)))
_openmpcc := $(subst FALSE,,$(subst TRUE,.OPENMPCC,$(OPENMPCC)))
_openmpfc := $(subst FALSE,,$(subst TRUE,.OPENMPFC,$(OPENMPFC)))
_proto := $(subst FALSE,,$(subst TRUE,.PROTO,$(USE_PROTO)))

# configuration string for multidim executable builds -- also use as a base
# for the other config strings

newconfig := $(shell echo $(system)$(_obj64).$(_cxxname).$(_fname)$(_precision)$(_debug)$(_opt)$(_profile)$(_mpi)$(_openmpcc)$(_openmpfc)$(_petsc)$(_rose)$(_gpu)$(_pic)$(XTRACONFIG) | sed -e 's/ //g' -e 's/ //g')
newconfig := $(shell echo $(system)$(_obj64).$(_cxxname).$(_fname)$(_precision)$(_debug)$(_opt)$(_profile)$(_mpi)$(_openmpcc)$(_openmpfc)$(_proto)$(_petsc)$(_rose)$(_gpu)$(_pic)$(XTRACONFIG) | sed -e 's/ //g' -e 's/ //g')

# create a base for all of the other config strings
baseconfig := $(shell echo d$(_ch)$(_md).$(system)$(_obj64).$(_cxxname).$(_fname)$(_precision)$(_debug)$(_opt)$(_profile)$(_mpi)$(_openmpcc)$(_openmpfc)$(_petsc)$(_rose)$(_gpu)$(_pic)$(XTRACONFIG) | sed -e 's/ //g' -e 's/ //g')
baseconfig := $(shell echo d$(_ch)$(_md).$(system)$(_obj64).$(_cxxname).$(_fname)$(_precision)$(_debug)$(_opt)$(_profile)$(_mpi)$(_openmpcc)$(_openmpfc)$(_proto)$(_petsc)$(_rose)$(_gpu)$(_pic)$(XTRACONFIG) | sed -e 's/ //g' -e 's/ //g')

#these are config strings needed by multidim builds
1dconfig := 1$(baseconfig)
Expand Down
3 changes: 3 additions & 0 deletions lib/mk/Make.defs.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
## CXXFLAGS options for compiling C++ code
## FFLAGS options for compiling Fortran code
## LDFLAGS options for linking
## CXXSTD chombo default is C++11. Set to 14 for C++14, etc.
## USE_64 if TRUE, use 64bit pointers on systems where 32bits is the default
## USE_COMPLEX if TRUE, enable the 'Complex' type
## (default is TRUE, disable only if compiler doesn't allow it)
Expand Down Expand Up @@ -99,8 +100,10 @@ CXXFLAGS?=
CHFFLAGS?=
FFLAGS?=
LDFLAGS?=
OUTPUT?=EXEC

# Chombo optional features
CXXSTD?=11# # C++ 11 standard
USE_64?=TRUE# #64bit pointers
USE_MT?=TRUE# #memory tracking
# USE_SETVAL?=TRUE# #initialize FAB data
Expand Down
2 changes: 1 addition & 1 deletion lib/mk/local/Make.defs.ANAG
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,6 @@ ifneq ($(ANAG_OPENMPI_DIR),)
endif

ifeq ($(USE_PROTO),TRUE)
XTRACPPFLAGS += -I$(PROTO_HOME)/include -DDIM=$(DIM) -DUSE_PROTO=1
XTRACPPFLAGS += -I$(PROTO_HOME)/include -DDIM=$(DIM) -DUSE_PROTO=1 -DPR_TURN_OFF_TIMERS=1
endif

16 changes: 11 additions & 5 deletions lib/mk/local/Make.defs.igor
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#it is prounouced eye-gore
makefiles+=local/Make.defs.igor
USE_HDF=TRUE
PROTO_HOME=/home/dtgraves/_proto/proto
USE_PROTO=TRUE
OPENMPCC=TRUE
USE_HDF=FALSE
USE_MF=TRUE
USE_EB=TRUE
USE_64=TRUE
CXX=g++
CPP=cpp
FC=gfortran
HDFINCFLAGS = -I/home/graves/_hdf5/include
HDFLIBFLAGS = -L/home/graves/_hdf5/lib -lhdf5 -lhdf5_hl -ldl -lz
HDFMPIINCFLAGS= -I/home/graves/_hdf5/include
HDFMPILIBFLAGS= -L/home/graves/_hdf5/lib -lhdf5 -lhdf5_hl -ldl -lz
HDFINCFLAGS = -I/home/dtgraves/_hdf5/include
HDFLIBFLAGS = -L/home/dtgraves/_hdf5/lib -lhdf5 -lhdf5_hl -ldl
HDFMPIINCFLAGS= -I/home/dtgraves/_hdf5/include
HDFMPILIBFLAGS= -L/home/dtgraves/_hdf5/lib -lhdf5 -lhdf5_hl -ldl


ifeq ($(USE_PROTO),TRUE)
XTRACPPFLAGS += -I$(PROTO_HOME)/include -DDIM=$(DIM) -DUSE_PROTO=1 -DPR_TURN_OFF_TIMERS=1
endif
60 changes: 60 additions & 0 deletions lib/src/BoxTools/ProtoInterface.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifdef CH_LANG_CC
/*
* _______ __
* / ___/ / ___ __ _ / / ___
* / /__/ _ \/ _ \/ V \/ _ \/ _ \
* \___/_//_/\___/_/_/_/_.__/\___/
* Please refer to Copyright.txt, in Chombo's root directory.
*/
#endif

#ifndef _PROTOINTERFACE_H_
#define _PROTOINTERFACE_H_

#ifdef USE_PROTO
#include "Proto.H"
#endif
#include "IntVect.H"
#include "Box.H"
#include "BaseFab.H"



#ifdef USE_PROTO


using Proto::Point;
using Proto::BoxData;
using Proto::Var;
///these functions are meant to interface with the Proto language.
namespace ProtoCh
{


///get point from intvect
extern Point getPoint( const IntVect& a_iv);

/// gets proto box from chombo box
extern Proto::Box getProtoBox( const Box& a_box);

///get intvect from point
extern IntVect getIntVect(const Point & a_pt);

///get chombo box from proto box
extern Box getBox(const Proto::Box & a_bx);

///
template <typename T, int ncomp>
void aliasBoxData(BoxData<T, ncomp> & a_boxdata, const BaseFab<T>& a_bfr, const int a_startcomp = 0)
{
CH_assert( a_bfr.nComp() == (ncomp + a_startcomp));
Proto::Box region = getProtoBox(a_bfr.box());
a_boxdata.define(a_bfr.dataPtr(a_startcomp), region, ncomp);
}


}

#endif

#endif
64 changes: 64 additions & 0 deletions lib/src/BoxTools/ProtoInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifdef CH_LANG_CC
/*
* _______ __
* / ___/ / ___ __ _ / / ___
* / /__/ _ \/ _ \/ V \/ _ \/ _ \
* \___/_//_/\___/_/_/_/_.__/\___/
* Please refer to Copyright.txt, in Chombo's root directory.
*/
#endif

#include "ProtoInterface.H"
#include "SPACE.H"
#include "UsingNamespace.H"

#ifdef USE_PROTO

///get point from intvect
Point
ProtoCh::getPoint( const IntVect& a_iv)
{
Point retval;
for(int idir = 0; idir < SpaceDim; idir++)
{
retval[idir] = a_iv[idir];
}
return retval;

}

/// gets proto box from chombo box
Proto::Box
ProtoCh::getProtoBox( const Box& a_box)
{
Point ptlo = getPoint(a_box.smallEnd());
Point pthi = getPoint(a_box.bigEnd());
return Proto::Box(ptlo, pthi);
}

///get intvect from point
IntVect
ProtoCh::getIntVect(const Point & a_pt)
{
IntVect retval;
for(int idir = 0; idir < SpaceDim; idir++)
{
retval[idir] = a_pt[idir];
}
return retval;
}

///get chombo box from proto box
Box
ProtoCh::getBox(const Proto::Box & a_bx)
{
IntVect ivlo = getIntVect(a_bx.low());
IntVect ivhi = getIntVect(a_bx.high());
return Box(ivlo, ivhi);
}



#endif


Binary file not shown.
96 changes: 96 additions & 0 deletions releasedExamples/Proto/Poisson/doc/proto_poisson.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
\documentclass[12pt,a4paper]{article}
\title{Chombo/Proto Poisson example }
\date{}
\begin{document}
\maketitle

\begin{abstract}

Given a charge distribution $\rho$, and a field $\phi$
the spatial Helmoltz equation is given by
\begin{equation}
(\alpha I + \beta \nabla) \phi = \rho.
\end{equation}
where $\alpha$ and $\beta$ are constants.
The Chombo Proto example solves the spatial Helmholtz equation in two
or three dimensions using geometric multigrid with standard V-cycles.

We present the performance for a single level calculation on a single
node of a Cori Haswell node. The boundary conditions are periodic
and the charge distribution has compact support of $r = 0.2$.
Further parameters are as follows.
\begin{itemize}
\item Identity coefficient, $\alpha = 1$.
\item Laplacian coefficient, $\beta = -0.1$.
\item Number of smoothings per relaxation, $n_{s} = 4$.
\item Grid dimensions = $512^3$.
\item Domain size $L_x=L_y=L_z =1$.
\end{itemize}

All calculations are done with a varying number of threads, keeping
the number of computational units constant. If $N_t$ is the number
of OpenMP threads and $N_m$ is the number of MPI processes, for all
calculations, $N_t N_m = 32$. Floating point rates are calculated as
a post-processing step.

\end{abstract}


\begin{table}[h]
\begin{center}
\begin{tabular}{|c|c||c|c|} \hline
$N_t$ & $N_m$ & $T_{vcycle}$ & $F_{resid}$ \\
\hline
1 & 32 & 1.223 & 78.1 GFlop \\
2 & 16 & 2.450 & 39.0 GFlop \\
4 & 8 & 2.480 & 30.6 GFlop \\
8 & 4 & 2.334 & 18.4 GFlop \\
16 & 2 & 2.695 & 10.5 GFlop \\
32 & 1 & 2.361 & 6.5 MFlop \\
\hline
\end{tabular}
\end{center}
\caption{AMRPoisson performance. }
\label{fig::solut2dl0}
\end{table}


\begin{table}[h]
\begin{center}
\begin{tabular}{|c|c||c|c|} \hline
$N_t$ & $N_m$ & $T_{vcycle}$ & $F_{resid}$ \\
\hline
1 & 32 & 3.89 & 20.1 GFlop\\
2 & 16 & 6.53 & 12.7 GFlop\\
4 & 8 & 6.47 & 12.6 GFlop\\
8 & 4 & 6.27 & 12.6 GFlop\\
16 & 2 & 6.00 & 12.6 GFlop\\
32 & 1 & 5.85 & 12.7 GFlop\\
\hline
\end{tabular}
\end{center}
\caption{7 point stencil proto performance. Same stencil as AMRPoisson}
\label{fig::solut2dl0}
\end{table}


\begin{table}[h]
\begin{center}
\begin{tabular}{|c|c||c|c|} \hline
$N_t$ & $N_m$ & $T_{vcycle}$ & $F_{resid}$\\
\hline
1 & 32 & 12.4 & 22.9 GFlop\\
2 & 16 & 20.7 & 14.7 GFlop\\
4 & 8 & 20.7 & 14.4 GFlop\\
8 & 4 & 19.7 & 14.7 GFlop\\
16 & 2 & 18.8 & 14.9 GFlop\\
32 & 1 & 18.6 & 14.9 GFlop\\
\hline
\end{tabular}
\end{center}
\caption{27 point stencil proto performance. }
\label{fig::solut2dl0}
\end{table}


\end{document}
22 changes: 22 additions & 0 deletions releasedExamples/Proto/Poisson/exec/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

ebase = Multigrid

# the location of the Chombo "lib" directory
CHOMBO_HOME = ../../../../lib

# names of Chombo libraries needed by this program, in order of search.
LibNames = BoxTools

# the locations of the source code directories
base_dir = .
src_dirs = ../src


# input file for 'run' target
INPUT = regression.inputs
# shared code for building example programs
include $(CHOMBO_HOME)/mk/Make.example

# application-specific variables

# application-specific targets
Loading

0 comments on commit 88fb333

Please sign in to comment.