Skip to content

Commit

Permalink
Sam's simd debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Llibert Areste Salo committed Feb 21, 2024
1 parent 446aae8 commit 2a36db1
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 24 deletions.
10 changes: 5 additions & 5 deletions Examples/Fluid_Kerr/PerfectFluidLevel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ class PerfectFluidLevel : public GRAMRLevel
typedef PerfectFluid<EoS> PerfectFluidEoS;

//! Things to do at the end of the advance step, after RK4 calculation
virtual void specificAdvance();
virtual void specificAdvance() override;

//! Initialize data for the field and metric variables
virtual void initialData();
virtual void initialData() override;

#ifdef CH_USE_HDF5
//! routines to do before outputting plot file
virtual void prePlotLevel();
virtual void prePlotLevel() override;
#endif

//! RHS routines used at each RK4 step
virtual void specificEvalRHS(GRLevelData &a_soln, GRLevelData &a_rhs,
const double a_time);
const double a_time) override;

//! Things to do in UpdateODE step, after soln + rhs update
virtual void specificUpdateODE(GRLevelData &a_soln,
const GRLevelData &a_rhs, Real a_dt);
const GRLevelData &a_rhs, Real a_dt) override;

/// Things to do before tagging cells (i.e. filling ghosts)
virtual void preTagCells() override;
Expand Down
4 changes: 2 additions & 2 deletions Examples/Fluid_Kerr/PositiveDensity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class PositiveDensity
vi[2] = current_cell.load_vars(c_vi3);

auto make_zero = simd_compare_lt(D, m_min_D);
D = simd_conditional(make_zero, D, m_min_D);
D = simd_conditional(make_zero, m_min_D, D);
// tau = simd_conditional(make_zero, tau, 1e-4);
FOR(i) vi[i] = simd_conditional(make_zero, vi[i], m_min_v);
FOR(i) vi[i] = simd_conditional(make_zero, m_min_v, vi[i]);

// current_cell.store_vars(D, c_D);
// current_cell.store_vars(rho, c_rho);
Expand Down
12 changes: 6 additions & 6 deletions Examples/Fluid_Kerr/PrimitiveRecovery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
#include "CCZ4Geometry.hpp"
#include "Cell.hpp"
#include "DefaultEoS.hpp"
#include "simd.hpp"
#include "Tensor.hpp"
#include "TensorAlgebra.hpp"
#include "UserVariables.hpp"
#include "UsingNamespace.H"
#include "VarsTools.hpp"

// template <class eos_t = DefaultEoS>
Expand Down Expand Up @@ -58,12 +60,10 @@ class PrimitiveRecovery

int i = 0;

auto cond = simd_all_false(simd_compare_lt(diff, tolerance));
//while (simd_all_false(simd_compare_lt(diff, tolerance)))
while (i<20)
// while (simd_compare_lt(tolerance, diff))
data_t empty;
while (!simd_all_false(simd_compare_lt(tolerance, diff), empty))
{
i++;
i++;
Wa = sqrt(pow(xa, 2.) / (pow(xa, 2.) - r));

vars.rho = pow(vars.chi, 1.5) * vars.D / Wa;
Expand All @@ -74,7 +74,7 @@ class PrimitiveRecovery
xn = Wa * (1. + vars.eps + P_over_rho);
diff = abs(xn - xa);
xa = xn;
if (i >= 20)
if (i >= 100)
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/simd/arm/neon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ template <> struct simd<double> : public simd_base<double>
return vmaxq_f64(a, b);
}

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond)
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
uint64x2_t high_bits = vshrq_n_u64(input, 63);
//Lanes are indexed like bits (big-endian)
Expand Down Expand Up @@ -178,7 +178,7 @@ template <> struct simd<float> : public simd_base<float>
return vmaxq_f32(a, b);
}

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond)
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
uint32x4_t high_bits = vshrq_n_u32(input, 31);
//Lanes are indexed like bits (big-endian)
Expand Down
4 changes: 2 additions & 2 deletions Source/simd/arm/sve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ template <> struct simd<double> : public simd_base<double>
return svmax_f64_z(svptrue_b64(), a, b);
}

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond)
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
//Would be nice to implement a movemask here, for extensions to lane-specific info
return !svptest_any(svptrue_b64(), cond);
Expand Down Expand Up @@ -212,7 +212,7 @@ template <> struct simd<float> : public simd_base<float>
return svmax_f32_z(svptrue_b32(), a, b);
}

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond)
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
//Would be nice to implement a movemask here, for extensions to lane-specific info
return !svptest_any(svptrue_b32(), cond);
Expand Down
3 changes: 2 additions & 1 deletion Source/simd/simd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ template <typename t> ALWAYS_INLINE t simd_max(const t &a, const t &b)
return (a > b) ? a : b;
}

template <typename t> ALWAYS_INLINE bool simd_all_false(const bool cond)
// Here, t is some simd variable
template <typename t> ALWAYS_INLINE bool simd_all_false(const bool cond, const t &b)
{
return !cond;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/simd/x64/avx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ template <> struct simd<double> : public simd_base<double>
return _mm256_max_pd(a, b);
}

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond)
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
int mask = _mm256_movemask_pd(cond);
return mask == 0 ? true : false;
Expand Down Expand Up @@ -199,7 +199,7 @@ template <> struct simd<float> : public simd_base<float>
return _mm256_max_ps(a, b);
}

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond)
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
int mask = _mm256_movemask_ps(cond);
return mask == 0 ? true : false;
Expand Down
4 changes: 2 additions & 2 deletions Source/simd/x64/avx512.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ template <> struct simd<double> : public simd_base<double>
return _mm512_max_pd(a, b);
}

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond)
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
int mask = static_cast<int>(cond);
return mask == 0 ? true : false;
Expand Down Expand Up @@ -204,7 +204,7 @@ template <> struct simd<float> : public simd_base<float>
return _mm512_max_ps(a, b);
}

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond)
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
int mask = static_cast<int>(cond);
return mask == 0 ? true : false;
Expand Down
4 changes: 2 additions & 2 deletions Source/simd/x64/sse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ template <> struct simd<double> : public simd_base<double>
return _mm_max_pd(a, b);
}

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond)
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
int mask = _mm_movemask_pd(cond);
return mask == 0 ? true : false;
Expand Down Expand Up @@ -221,7 +221,7 @@ template <> struct simd<float> : public simd_base<float>
return _mm_max_ps(a, b);
}

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond)
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
int mask = _mm_movemask_ps(cond);
return mask == 0 ? true : false;
Expand Down

0 comments on commit 2a36db1

Please sign in to comment.