Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
a58f99c
Created the QIHandler class for handling QuadraticInterpolator data, …
ldowen Jul 25, 2025
86b7464
Created a QI base class, make the QI class the value class that inher…
ldowen Jul 28, 2025
23d8ba2
Switched QI to use managed arrays instead of calling Umpire directly
ldowen Jul 28, 2025
b6aa325
Removed the QIView class, GPUified the CubicHermitInterpolator and ad…
ldowen Jul 29, 2025
8ac532c
Added default constructors for QI and CHI, added the index operator f…
ldowen Jul 29, 2025
9f7ef88
Added move operation to QIBase and CHIBase
ldowen Jul 29, 2025
440e72b
Added copy and assignment constructors and tests for the QI and CHI c…
ldowen Jul 31, 2025
653bf65
Add explicit calls to base copy and assignment constructors in QI and…
ldowen Jul 31, 2025
891ef90
Updated RELEASE_NOTES to test new mirror
ldowen Aug 1, 2025
c5c9be6
Merge branch 'develop' into feature/gpu/interpolators
ldowen Aug 14, 2025
b427ef6
Changed QIBase and CHIBase to QIView and CHIView
ldowen Aug 14, 2025
3d3436e
Merge branch 'develop' into feature/gpu/interpolators
ldowen Aug 18, 2025
fc918f8
Merge branch 'develop' into feature/gpu/interpolators
ldowen Aug 25, 2025
b7191e3
Removed unused line in QI
ldowen Aug 27, 2025
7420d98
Removed chai submodule, added package recipes for chai, raja, umpire,…
ldowen Aug 27, 2025
f630226
Chagned getPointer to data
ldowen Aug 27, 2025
0f30958
Update release notes
ldowen Aug 28, 2025
0a88b0e
Merge branch 'develop' into update/remove_chai_submodule
ldowen Aug 28, 2025
e3d703b
Changed ENABLE_HIP to SPHERAL_ENABLE_HIP and added it to the export t…
ldowen Sep 4, 2025
a21597d
Removed umpire variant logic
ldowen Sep 4, 2025
afd2f58
Fix spack package typo
ldowen Sep 4, 2025
63c1770
Turn off mpi for axom when ~mpi
ldowen Sep 4, 2025
f5b71f2
Change back to using ENABLE_HIP, let that be a different PR
ldowen Sep 4, 2025
ed7355c
Removed non-mpi CI tests
ldowen Sep 4, 2025
a5d599d
Removed redundant axom variant added a few commits ago, added spheral…
ldowen Sep 4, 2025
68c45ca
Revert "Removed redundant axom variant added a few commits ago, added…
ldowen Sep 5, 2025
918a2ad
Revert "Removed non-mpi CI tests"
ldowen Sep 5, 2025
b6c136f
Revert "Change back to using ENABLE_HIP, let that be a different PR"
ldowen Sep 5, 2025
66c90f4
Revert "Turn off mpi for axom when ~mpi"
ldowen Sep 5, 2025
21d150e
Revert "Fix spack package typo"
ldowen Sep 5, 2025
7797465
Revert "Removed umpire variant logic"
ldowen Sep 5, 2025
ff6f203
Reverted SPHERAL_ENABLE_HIP back to just ENABLE_HIP, added leos flags…
ldowen Sep 5, 2025
295ff7e
Forgot about typo in spack package
ldowen Sep 5, 2025
25a8736
libleos_C.a does not exist for some reason
ldowen Sep 5, 2025
dca07de
Turn xml on for leos
ldowen Sep 6, 2025
7b711b5
Explicitly turn off xml for leos
ldowen Sep 8, 2025
0eeca88
Do not use +xml variant in spheral
ldowen Sep 8, 2025
84fd39a
Switched to using find_package on hdf5 and LIP libraries, added logic…
ldowen Sep 8, 2025
5ae2642
Try turning yaml off for leos and changing name of LIP package in cma…
ldowen Sep 8, 2025
3863907
Change lip to LIP
ldowen Sep 8, 2025
b771c6e
LIP is incorrectly exported so reverting back to importing it the mes…
ldowen Sep 8, 2025
2edf1ab
Fix hdf5 target names
ldowen Sep 8, 2025
f082082
Add correct hdf5 targets to lists
ldowen Sep 8, 2025
5ecc1ac
Remove duplicated hdf5_DIR in fp_dirs list
ldowen Sep 8, 2025
d6ebe4f
Build static cxx libraries if rocm is turned on, otherwise mysterious…
ldowen Sep 9, 2025
7ceae95
Changed umpire and raja versions based on feedback from Collette, rev…
ldowen Sep 10, 2025
dbfe845
Remove printf statement left in LEOS_bundle.cc
ldowen Sep 10, 2025
2b9243e
One other addition to the release notes
ldowen Sep 10, 2025
8ef5ced
Bring yaml back to leos because it is apparently needed for reading a…
ldowen Sep 11, 2025
08696b5
Make preferred leos package the older one for now
ldowen Sep 11, 2025
8b77867
Put link flags directly in blt call
ldowen Sep 12, 2025
0c5cb28
Add TPL dependencies and have leos get hip and cuda variants when nec…
ldowen Sep 15, 2025
444e36b
Change leos version back to 8.5.0 and ensure it is only a dependency …
ldowen Sep 15, 2025
009dc72
It seems leos 8.5.2 is more stable than 8.5.0 even if something is br…
ldowen Sep 15, 2025
63ffbbd
Reverting back to leos 8.4.2 without rocm versions but added note for…
ldowen Sep 16, 2025
1ab74df
Merge with update/remove_chai_submodule
ldowen Sep 16, 2025
a0799a0
Fixed copy and assignment constructors for QI and CHI to avoid copyin…
ldowen Sep 16, 2025
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
1 change: 0 additions & 1 deletion src/PYB11/Utilities/QuadraticInterpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,3 @@ def lowerBound(self,
xmin = PYB11property(doc="Minimum x coordinate for table")
xmax = PYB11property(doc="Maximum x coordinate for table")
xstep = PYB11property(doc="delta x between tabulated values")
coeffs = PYB11property(doc="the fitting coefficients")
78 changes: 36 additions & 42 deletions src/Utilities/QuadraticInterpolator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,20 @@
// Created by JMO, Fri Dec 4 14:28:08 PST 2020
//----------------------------------------------------------------------------//
#include "QuadraticInterpolator.hh"
#include "umpire/Umpire.hpp"
#include <algorithm>

namespace Spheral {
#include <Eigen/Dense>

//------------------------------------------------------------------------------
// Default constructor
//------------------------------------------------------------------------------
QuadraticInterpolator::QuadraticInterpolator():
mN1(),
mXmin(),
mXmax(),
mXstep(),
mcoeffs() {
}
namespace Spheral {

//------------------------------------------------------------------------------
// Constructor with sampled values
//------------------------------------------------------------------------------
QuadraticInterpolator::QuadraticInterpolator(double xmin,
double xmax,
const std::vector<double>& yvals):
mN1(),
mXmin(),
mXmax(),
mXstep(),
mcoeffs() {
this->initialize(xmin, xmax, yvals);
const std::vector<double>& yvals) {
initialize(xmin, xmax, yvals);
}

//------------------------------------------------------------------------------
Expand All @@ -47,11 +35,12 @@ QuadraticInterpolator::initialize(double xmin,
VERIFY2(n % 2 == 1, "QuadraticInterpolator::initialize requires an odd number of tabulated values");
VERIFY2(xmax > xmin, "QuadraticInterpolator::initialize requires a positive domain: [" << xmin << " " << xmax << "]");

mN1 = (n - 1u)/2u - 1u; // Maximum index into arrays
mXmin = xmin;
mXmax = xmax;
mXstep = (xmax - xmin)/(mN1 + 1u);
mcoeffs.resize(3*(mN1 + 1u));
double N1 = (n - 1u)/2u - 1u; // Maximum index into arrays
double xstep = (xmax - xmin)/(N1 + 1u);
size_t N = 3*(N1 + 1u);
auto& rm = umpire::ResourceManager::getInstance();
auto host_allocator = rm.getAllocator("HOST");
double* vals = static_cast<double*>(host_allocator.allocate(N*sizeof(double)));

typedef Eigen::Matrix<double, 3, 3, Eigen::RowMajor> EMatrix;
typedef Eigen::Matrix<double, 3, 1> EVector;
Expand All @@ -62,37 +51,42 @@ QuadraticInterpolator::initialize(double xmin,
double x0, x1, x2;
EMatrix A;
EVector X, B;
for (auto i0 = 0u; i0 <= mN1; ++i0) {
x0 = xmin + i0*mXstep;
x1 = x0 + 0.5*mXstep;
x2 = x0 + mXstep;
for (auto i0 = 0u; i0 <= N1; ++i0) {
x0 = xmin + i0*xstep;
x1 = x0 + 0.5*xstep;
x2 = x0 + xstep;
A << 1.0, x0, x0*x0,
1.0, x1, x1*x1,
1.0, x2, x2*x2;
B << yvals[2u*i0], yvals[2u*i0 + 1u], yvals[2u*i0 + 2u];
X = A.inverse()*B;
mcoeffs[3*i0 ] = X(0);
mcoeffs[3*i0 + 1u] = X(1);
mcoeffs[3*i0 + 2u] = X(2);
vals[3*i0 ] = X(0);
vals[3*i0 + 1u] = X(1);
vals[3*i0 + 2u] = X(2);
}
#ifdef SPHERAL_GPU_ENABLED
auto allocator = rm.getAllocator("DEVICE");
mDeviceCoeffs = static_cast<double*>(allocator.allocate(N*sizeof(double)));
rm.copy(mDeviceCoeffs, vals, N*sizeof(double));
#endif
mcoeffs = vals;
mN1 = N1;
mXmin = xmin;
mXmax = xmax;
mXstep = xstep;
}

//------------------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------------------
QuadraticInterpolator::~QuadraticInterpolator() {
}

//------------------------------------------------------------------------------
// Equivalence
//------------------------------------------------------------------------------
bool
QuadraticInterpolator::
operator==(const QuadraticInterpolator& rhs) const {
return ((mN1 == rhs.mN1) and
(mXmin == rhs.mXmin) and
(mXmax == rhs.mXmax) and
(mcoeffs == rhs.mcoeffs));
auto& rm = umpire::ResourceManager::getInstance();
#ifdef SPHERAL_GPU_ENABLED
auto allocator = rm.getAllocator("DEVICE");
allocator.deallocate(mDeviceCoeffs);
#endif
auto host_allocator = rm.getAllocator("HOST");
host_allocator.deallocate(mcoeffs);
}

}
94 changes: 65 additions & 29 deletions src/Utilities/QuadraticInterpolator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,93 @@
#ifndef __Spheral_QuadraticInterpolator__
#define __Spheral_QuadraticInterpolator__

#include "chai/ExecutionSpaces.hpp"
#include "config.hh"

#include <cstddef>
#include <vector>

namespace Spheral {

class QuadraticInterpolator {
class QuadraticInterpolatorBase {
public:
//--------------------------- Public Interface ---------------------------//
// Constructors, destructors
template<typename Func>
QuadraticInterpolator(double xmin, double xmax, size_t n, const Func& F);
QuadraticInterpolator(double xmin, double xmax, const std::vector<double>& yvals);
QuadraticInterpolator();
~QuadraticInterpolator();

// Initialize after construction, either with a function or tabulated values
template<typename Func>
void initialize(double xmin, double xmax, size_t n, const Func& f);
void initialize(double xmin, double xmax, const std::vector<double>& yvals);
SPHERAL_HOST_DEVICE QuadraticInterpolatorBase() = default;

// Comparisons
bool operator==(const QuadraticInterpolator& rhs) const;
SPHERAL_HOST_DEVICE bool operator==(const QuadraticInterpolatorBase& rhs) const;

// Interpolate for the y value
double operator()(const double x) const;
double prime(const double x) const; // First derivative
double prime2(const double x) const; // Second derivative
SPHERAL_HOST_DEVICE double operator()(const double x) const;
SPHERAL_HOST_DEVICE double prime(const double x) const; // First derivative
SPHERAL_HOST_DEVICE double prime2(const double x) const; // Second derivative

// Same as above, but use a pre-computed table position (from lowerBound)
double operator()(const double x, const size_t i0) const;
double prime(const double x, const size_t i0) const; // First derivative
double prime2(const double x, const size_t i0) const; // Second derivative
SPHERAL_HOST_DEVICE double operator()(const double x, const size_t i0) const;
SPHERAL_HOST_DEVICE double prime(const double x, const size_t i0) const; // First derivative
SPHERAL_HOST_DEVICE double prime2(const double x, const size_t i0) const; // Second derivative

// Return the lower bound index in the table for the given x coordinate
size_t lowerBound(const double x) const;
SPHERAL_HOST_DEVICE size_t lowerBound(const double x) const;

// Allow read access the internal data representation
size_t size() const; // The size of the tabulated coefficient arrays
double xmin() const; // Minimum x coordinate for table
double xmax() const; // Maximum x coordinate for table
double xstep() const; // delta x between tabulated values
const std::vector<double>& coeffs() const; // the fitting coefficients

private:
SPHERAL_HOST_DEVICE size_t size() const; // The size of the tabulated coefficient arrays
SPHERAL_HOST_DEVICE double xmin() const; // Minimum x coordinate for table
SPHERAL_HOST_DEVICE double xmax() const; // Maximum x coordinate for table
SPHERAL_HOST_DEVICE double xstep() const; // delta x between tabulated values

protected:
SPHERAL_HOST QuadraticInterpolatorBase(size_t N1,
double xmin,
double xmax,
double xstep,
double* vals) :
mN1(N1),
mXmin(xmin),
mXmax(xmax),
mXstep(xstep),
mcoeffs(vals) { }
//--------------------------- Private Interface --------------------------//
// Member data
size_t mN1;
double mXmin, mXmax, mXstep;
std::vector<double> mcoeffs;
size_t mN1 = 0u;
double mXmin = 0.;
double mXmax = 0.;
double mXstep = 0.;
double* mcoeffs = nullptr;
};

class QuadraticInterpolator : public QuadraticInterpolatorBase {
public:
template<typename Func>
QuadraticInterpolator(double xmin, double xmax, size_t n, const Func& F);
QuadraticInterpolator(double xmin, double xmax, const std::vector<double>& yvals);
~QuadraticInterpolator();

// Initialize after construction, either with a function or tabulated values
template<typename Func>
void initialize(double xmin, double xmax, size_t n, const Func& f);
void initialize(double xmin, double xmax, const std::vector<double>& yvals);

template<typename QIView>
QIView view(chai::ExecutionSpace space) {
if (space == chai::CPU) {
return QIView(mN1, mXmin, mXmax, mXstep, mcoeffs);
} else {
return QIView(mN1, mXmin, mXmax, mXstep, mDeviceCoeffs);
}
}
private:
double* mDeviceCoeffs = nullptr;
};

// For use on device
class QIView : public QuadraticInterpolatorBase {
public:
SPHERAL_HOST_DEVICE QIView() = default;
SPHERAL_HOST QIView(size_t N1, double xmin, double xmax, double xstep, double* vals);
SPHERAL_HOST_DEVICE ~QIView() { }
};
}

#include "QuadraticInterpolatorInline.hh"
Expand Down
Loading