Skip to content

Commit

Permalink
Updates from HISSTools_Library
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHarker committed Feb 11, 2023
1 parent ecbcbe9 commit 4ed7080
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion FrameLib_Dependencies/HISSTools_FFT/HISSTools_FFT_Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ namespace hisstools_fft_impl{
struct static_for<N, N>
{
template <typename Fn>
void operator()(Vector4x &result, const Vector4x &, const Vector4x &, Fn const&) const {}
void operator()(Vector4x & /* result */, const Vector4x & /* a */, const Vector4x & /* b */ , Fn const& /* fn */) const {}
};

template <typename Op>
Expand Down
3 changes: 2 additions & 1 deletion FrameLib_Dependencies/RandomGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace random_generators
// Basic CMWC Generator

// A complementary modulo with carry algorithm (proposed by George Marsaglia)
// Details can be found in Marsaglia, G. (2003). "Random number generators". Journal of Modern Applied Statistical Methods 2
// Details can be found in:
// Marsaglia, G. (2003). "Random number generators". Journal of Modern Applied Statistical Methods 2
// See - http://digitalcommons.wayne.edu/cgi/viewcontent.cgi?article=1725&context=jmasm

// The memory requirement is 34 unsigned 32 bit integers (can be altered using cmwc_lag_size)
Expand Down
41 changes: 22 additions & 19 deletions FrameLib_Dependencies/SIMDSupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ void deallocate_aligned(T *ptr)
template <class T>
T *allocate_aligned(size_t size)
{
void *mem;
posix_memalign(&mem, SIMDLimits<T>::byte_width, size * sizeof(T));
void *mem = nullptr;

if (posix_memalign(&mem, SIMDLimits<T>::byte_width, size * sizeof(T)))
return nullptr;

return static_cast<T *>(mem);
}

Expand Down Expand Up @@ -363,29 +366,29 @@ struct SizedVector
static_iterate<First + 1, Last>()(result, a, b, fn);
}

void load(SV &vector, const T *array)
void load(SV &v, const T *array)
{
vector.mData[First] = VecType(array + First * vec_size);
static_iterate<First + 1, Last>().load(vector, array);
v.mData[First] = VecType(array + First * vec_size);
static_iterate<First + 1, Last>().load(v, array);
}

void store(T *array, const SV& vector)
void store(T *array, const SV& v)
{
vector.mData[First].store(array + First * vec_size);
static_iterate<First + 1, Last>().store(array, vector);
v.mData[First].store(array + First * vec_size);
static_iterate<First + 1, Last>().store(array, v);
}

void set(SV &vector, const T& a)
void set(SV &v, const T& a)
{
vector.mData[First] = a;
static_iterate<First + 1, Last>().set(vector, a);
v.mData[First] = a;
static_iterate<First + 1, Last>().set(v, a);
}

template <class U>
void set(SV &vector, const SizedVector<U, 1, final_size>& a)
void set(SV &v, const SizedVector<U, 1, final_size>& a)
{
vector.mData[First] = a.mData[First];
static_iterate<First + 1, Last>().set(vector, a);
v.mData[First] = a.mData[First];
static_iterate<First + 1, Last>().set(v, a);
}
};

Expand All @@ -395,14 +398,14 @@ struct SizedVector
struct static_iterate<N, N>
{
template <typename Fn>
void operator()(SV &result, const SV& a, const SV& b, Fn const& fn) const {}
void operator()(SV & /*result*/, const SV& /* a */, const SV& /* b */, Fn const& /* fn */) const {}

void load(SV &vector, const T *array) {}
void store(T *array, const SV& vector) {}
void set(SV &vector, const T& a) {}
void load(SV & /* v */, const T * /* array */) {}
void store(T * /* array */, const SV& /* v */) {}
void set(SV & /* v */, const T& /* a */) {}

template <class U>
void set(SV &vector, const SizedVector<U, 1, final_size>& a) {}
void set(SV & /* v */, const SizedVector<U, 1, final_size>& /* a */) {}
};

// Op template
Expand Down
4 changes: 2 additions & 2 deletions FrameLib_Dependencies/TableReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ struct table_fetcher
table_fetcher(intptr_t length, double scale_val) : size(length), scale(scale_val) {}

template <class U, class V>
void split(U position, intptr_t& idx, V& fract, int N)
void split(U position, intptr_t& idx, V& fract, int /* N */)
{
idx = static_cast<intptr_t>(std::floor(position));
fract = static_cast<V>(position - static_cast<V>(idx));
}

intptr_t limit() { return size - 1; }

void prepare(InterpType interpolation) {}
void prepare(InterpType /* interpolation */) {}

const intptr_t size;
const double scale;
Expand Down
6 changes: 4 additions & 2 deletions FrameLib_Dependencies/WindowFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace window_functions

struct params
{
constexpr params(double A0 = 0.0, double A1 = 0.0, double A2 = 0.0, double A3 = 0.0, double A4 = 0.0, double exp = 1.0)
constexpr params(double A0 = 0, double A1 = 0, double A2 = 0, double A3 = 0, double A4 = 0, double exp = 1)
: a0(A0), a1(A1), a2(A2), a3(A3), a4(A4), exponent(exp) {}

constexpr params(const double *param_array, int N, double exp)
Expand Down Expand Up @@ -350,6 +350,8 @@ namespace window_functions
template <window_func Func, bool symmetric, class T>
void inline generate(T *window, uint32_t N, uint32_t begin, uint32_t end, const params& p)
{
constexpr int max_int = std::numeric_limits<int>().max();

auto sq = [&](double x) { return x * x; };
auto cb = [&](double x) { return x * x * x; };
auto qb = [&](double x) { return sq(sq(x)); };
Expand Down Expand Up @@ -414,7 +416,7 @@ namespace window_functions
for (uint32_t i = begin; i < end; i++)
*window++ = toType(qb(Func(i, N, p)));
}
else if (p.exponent > 0 && p.exponent <= std::numeric_limits<int>().max() && p.exponent == std::floor(p.exponent))
else if (p.exponent > 0 && p.exponent <= max_int && p.exponent == std::floor(p.exponent))
{
int exponent = static_cast<int>(p.exponent);

Expand Down

0 comments on commit 4ed7080

Please sign in to comment.