Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support single precision build with configure #1706

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,20 @@ jobs:
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE XTRA_CXXFLAGS=-fno-operator-names CXXSTD=c++17
make install

# Build 3D libamrex with single precision and tiny profiler
configure-3d-single-tprof:
name: GNU@7.5 Release [configure 3D]
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Dependencies
run: .github/workflows/dependencies/dependencies.sh
- name: Build & Install
run: |
./configure --dim 3 --enable-eb no --enable-xsdk-defaults no --single-precision yes --single-precision-particles yes --enable-tiny-profile yes
make -j2 WARN_ALL=TRUE WARN_ERROR=TRUE XTRA_CXXFLAGS=-fno-operator-names
make install

# Build 3D libamrex debug omp build with configure
configure-3d-omp-debug:
name: GNU@7.5 OMP Debug [configure 3D]
Expand Down
34 changes: 17 additions & 17 deletions Src/Amr/AMReX_Amr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ Amr::writeSmallPlotFile ()
void
Amr::writePlotFileDoit (std::string const& pltfile, bool regular)
{
Real dPlotFileTime0 = amrex::second();
auto dPlotFileTime0 = amrex::second();

VisMF::SetNOutFiles(plot_nfiles);
VisMF::Header::Version currentVersion(VisMF::GetHeaderVersion());
Expand Down Expand Up @@ -1009,7 +1009,7 @@ Amr::writePlotFileDoit (std::string const& pltfile, bool regular)

if (verbose > 0) {
const int IOProc = ParallelDescriptor::IOProcessorNumber();
Real dPlotFileTime = amrex::second() - dPlotFileTime0;
auto dPlotFileTime = amrex::second() - dPlotFileTime0;
ParallelDescriptor::ReduceRealMax(dPlotFileTime,IOProc);
if (regular) {
amrex::Print() << "Write plotfile time = " << dPlotFileTime << " seconds" << "\n\n";
Expand Down Expand Up @@ -1168,7 +1168,7 @@ Amr::readProbinFile (int& a_init)
const int NSets = (NProcs + (nAtOnce - 1)) / nAtOnce;
const int MySet = MyProc/nAtOnce;

Real piStart = 0, piEnd = 0, piStartAll = amrex::second();
double piStart = 0, piEnd = 0, piStartAll = amrex::second();

for (int iSet = 0; iSet < NSets; ++iSet)
{
Expand Down Expand Up @@ -1218,8 +1218,8 @@ Amr::readProbinFile (int& a_init)
if (verbose > 1)
{
const int IOProc = ParallelDescriptor::IOProcessorNumber();
Real piTotal = piEnd - piStart;
Real piTotalAll = amrex::second() - piStartAll;
auto piTotal = piEnd - piStart;
auto piTotalAll = amrex::second() - piStartAll;

ParallelDescriptor::ReduceRealMax(piTotal, IOProc);
ParallelDescriptor::ReduceRealMax(piTotalAll, IOProc);
Expand Down Expand Up @@ -1361,7 +1361,7 @@ Amr::restart (const std::string& filename)

which_level_being_advanced = -1;

Real dRestartTime0 = amrex::second();
auto dRestartTime0 = amrex::second();

VisMF::SetMFFileInStreams(mffile_nstreams);

Expand Down Expand Up @@ -1662,7 +1662,7 @@ Amr::restart (const std::string& filename)

if (verbose > 0)
{
Real dRestartTime = amrex::second() - dRestartTime0;
auto dRestartTime = amrex::second() - dRestartTime0;

ParallelDescriptor::ReduceRealMax(dRestartTime,ParallelDescriptor::IOProcessorNumber());

Expand Down Expand Up @@ -1692,7 +1692,7 @@ Amr::checkPoint ()
VisMF::Header::Version currentVersion(VisMF::GetHeaderVersion());
VisMF::SetHeaderVersion(checkpoint_headerversion);

Real dCheckPointTime0 = amrex::second();
auto dCheckPointTime0 = amrex::second();

const std::string& ckfile = amrex::Concatenate(check_file_root,level_steps[0],file_name_digits);

Expand Down Expand Up @@ -1824,7 +1824,7 @@ Amr::checkPoint ()

if (verbose > 0)
{
Real dCheckPointTime = amrex::second() - dCheckPointTime0;
auto dCheckPointTime = amrex::second() - dCheckPointTime0;

ParallelDescriptor::ReduceRealMax(dCheckPointTime,
ParallelDescriptor::IOProcessorNumber());
Expand Down Expand Up @@ -2048,8 +2048,8 @@ Amr::coarseTimeStepDt (Real stop_time)
void
Amr::coarseTimeStep (Real stop_time)
{
Real run_stop;
Real run_strt;
double run_stop;
double run_strt;
BL_PROFILE_REGION_START("Amr::coarseTimeStep()");
BL_PROFILE("Amr::coarseTimeStep()");
std::stringstream stepName;
Expand Down Expand Up @@ -2173,7 +2173,7 @@ Amr::coarseTimeStep (Real stop_time)
// the counter, because we have indeed reached the next check_per interval
// at this point.

const Real eps = std::numeric_limits<Real>::epsilon() * 10.0 * std::abs(cumtime);
const Real eps = std::numeric_limits<Real>::epsilon() * 10.0_rt * std::abs(cumtime);
const Real next_chk_time = (num_per_old + 1) * check_per;

if ((num_per_new == num_per_old) && std::abs(cumtime - next_chk_time) <= eps)
Expand Down Expand Up @@ -2317,7 +2317,7 @@ Amr::writePlotNow() noexcept
// the counter, because we have indeed reached the next plot_per interval
// at this point.

const Real eps = std::numeric_limits<Real>::epsilon() * 10.0 * std::abs(cumtime);
const Real eps = std::numeric_limits<Real>::epsilon() * 10.0_rt * std::abs(cumtime);
const Real next_plot_time = (num_per_old + 1) * plot_per;

if ((num_per_new == num_per_old) && std::abs(cumtime - next_plot_time) <= eps)
Expand Down Expand Up @@ -2390,7 +2390,7 @@ Amr::writeSmallPlotNow() noexcept
// the counter, because we have indeed reached the next small_plot_per interval
// at this point.

const Real eps = std::numeric_limits<Real>::epsilon() * 10.0 * std::abs(cumtime);
const Real eps = std::numeric_limits<Real>::epsilon() * 10.0_rt * std::abs(cumtime);
const Real next_plot_time = (num_per_old + 1) * small_plot_per;

if ((num_per_new == num_per_old) && std::abs(cumtime - next_plot_time) <= eps)
Expand Down Expand Up @@ -2816,7 +2816,7 @@ Amr::printGridInfo (std::ostream& os,
int numgrid = bs.size();
Long ncells = amr_level[lev]->countCells();
double ntot = Geom(lev).Domain().d_numPts();
Real frac = Real(100.0)*(Real(ncells) / ntot);
Real frac = Real(100.0 * double(ncells) / ntot);
const DistributionMapping& map = amr_level[lev]->get_new_data(0).DistributionMap();

os << " Level "
Expand Down Expand Up @@ -2856,7 +2856,7 @@ Amr::grid_places (int lbase,
{
BL_PROFILE("Amr::grid_places()");

const Real strttime = amrex::second();
const auto strttime = amrex::second();

if (lbase == 0)
{
Expand Down Expand Up @@ -2931,7 +2931,7 @@ Amr::grid_places (int lbase,

if (verbose > 0)
{
Real stoptime = amrex::second() - strttime;
auto stoptime = amrex::second() - strttime;

#ifdef BL_LAZY
Lazy::QueueReduction( [=] () mutable {
Expand Down
12 changes: 6 additions & 6 deletions Src/Amr/AMReX_AmrLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ AmrLevel::get_data (int state_indx, Real time) noexcept
{
const Real old_time = state[state_indx].prevTime();
const Real new_time = state[state_indx].curTime();
const Real eps = 0.001*(new_time - old_time);
const Real eps = Real(0.001)*(new_time - old_time);

if (time > old_time-eps && time < old_time+eps)
{
Expand Down Expand Up @@ -2098,10 +2098,10 @@ AmrLevel::which_time (int indx, Real time) const noexcept
{
const Real oldtime = state[indx].prevTime();
const Real newtime = state[indx].curTime();
const Real haftime = .5 * (oldtime + newtime);
const Real qtime = oldtime + 0.25*(newtime-oldtime);
const Real tqtime = oldtime + 0.75*(newtime-oldtime);
const Real epsilon = 0.001 * (newtime - oldtime);
const Real haftime = .5_rt * (oldtime + newtime);
const Real qtime = oldtime + 0.25_rt*(newtime-oldtime);
const Real tqtime = oldtime + 0.75_rt*(newtime-oldtime);
const Real epsilon = 0.001_rt * (newtime - oldtime);

BL_ASSERT(time >= oldtime-epsilon && time <= newtime+epsilon);

Expand Down Expand Up @@ -2131,7 +2131,7 @@ AmrLevel::which_time (int indx, Real time) const noexcept
Real
AmrLevel::estimateWork ()
{
return 1.0*countCells();
return static_cast<Real>(countCells());
}

bool
Expand Down
4 changes: 2 additions & 2 deletions Src/Amr/AMReX_AuxBoundaryData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ AuxBoundaryData::initialize (const BoxArray& ba,

const bool verbose = false;
const int NProcs = ParallelDescriptor::NProcs();
const Real strt_time = amrex::second();
const auto strt_time = amrex::second();

m_ngrow = n_grow;

Expand Down Expand Up @@ -108,7 +108,7 @@ AuxBoundaryData::initialize (const BoxArray& ba,
if (verbose)
{
const int IOProc = ParallelDescriptor::IOProcessorNumber();
Real run_time = amrex::second() - strt_time;
auto run_time = amrex::second() - strt_time;
const int sz = nba.size();

#ifdef BL_LAZY
Expand Down
4 changes: 2 additions & 2 deletions Src/Amr/AMReX_StateData.H
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ public:
*/
Real curTime () const noexcept {
return (desc->timeType() == StateDescriptor::Point) ?
new_time.stop : 0.5*(new_time.start + new_time.stop);
new_time.stop : 0.5_rt*(new_time.start + new_time.stop);
}

/**
* \brief Returns the previous time.
*/
Real prevTime () const noexcept {
return (desc->timeType() == StateDescriptor::Point) ?
old_time.stop : 0.5*(old_time.start + old_time.stop);
old_time.stop : 0.5_rt*(old_time.start + old_time.stop);
}

/**
Expand Down
18 changes: 9 additions & 9 deletions Src/Amr/AMReX_StateData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
namespace amrex {

#ifdef AMREX_USE_FLOAT
static constexpr Real INVALID_TIME = -1.0e30;
static constexpr Real INVALID_TIME = -1.0e30_rt;
#else
static constexpr Real INVALID_TIME = -1.0e200;
static constexpr Real INVALID_TIME = -1.0e200_rt;
#endif

static constexpr int MFNEWDATA = 0;
Expand Down Expand Up @@ -235,7 +235,7 @@ StateData::restartDoit (std::istream& is, const std::string& chkfile)
// We set it to zero in case a compiler complains about uninitialized data.
//
if (nsets == 0) {
new_data->setVal(0.0);
new_data->setVal(0.0_rt);
}

std::string mf_name;
Expand Down Expand Up @@ -293,7 +293,7 @@ StateData::restart (const StateDescriptor& d,
new_data.reset(new MultiFab(grids,dmap,desc->nComp(),desc->nExtra(),
MFInfo().SetTag("StateData").SetArena(arena),
*m_factory));
new_data->setVal(0.);
new_data->setVal(0._rt);
}

StateData::~StateData()
Expand Down Expand Up @@ -349,7 +349,7 @@ StateData::setNewTimeLevel (Real time)
void
StateData::syncNewTimeLevel (Real time)
{
Real teps = (new_time.stop - old_time.stop)*1.e-3;
Real teps = (new_time.stop - old_time.stop)*1.e-3_rt;
if (time > new_time.stop-teps && time < new_time.stop+teps)
{
if (desc->timeType() == StateDescriptor::Point)
Expand Down Expand Up @@ -624,7 +624,7 @@ StateData::InterpAddBox (MultiFabCopyDescriptor& multiFabCopyDesc,
}
else
{
const Real teps = (new_time.start - old_time.start)*1.e-3;
const Real teps = (new_time.start - old_time.start)*1.e-3_rt;

if (time > new_time.start-teps && time < new_time.stop+teps)
{
Expand Down Expand Up @@ -691,7 +691,7 @@ StateData::InterpFillFab (MultiFabCopyDescriptor& multiFabCopyDesc,
}
else
{
const Real teps = (new_time.start - old_time.start)*1.e-3;
const Real teps = (new_time.start - old_time.start)*1.e-3_rt;

if (time > new_time.start-teps && time < new_time.stop+teps)
{
Expand Down Expand Up @@ -728,7 +728,7 @@ StateData::getData (Vector<MultiFab*>& data,
}
else
{
const Real teps = (new_time.start - old_time.start)*1.e-3;
const Real teps = (new_time.start - old_time.start)*1.e-3_rt;
if (time > new_time.start-teps && time < new_time.start+teps) {
data.push_back(new_data.get());
datatime.push_back(new_time.start);
Expand All @@ -745,7 +745,7 @@ StateData::getData (Vector<MultiFab*>& data,
}
else
{
const Real teps = (new_time.start - old_time.start)*1.e-3;
const Real teps = (new_time.start - old_time.start)*1.e-3_rt;

if (time > new_time.start-teps && time < new_time.stop+teps)
{
Expand Down
Loading