Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c94b565ae340
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 45d156e1c215
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Dec 7, 2020

  1. Compute next highest power of 2 function

    Compute next highest power of 2 to fix issues when using code (in different parts):
      const size_t npoints = pow(2, ceil(log2(depth))); (see scopehal\TestWaveformSource.cpp => TestWaveformSource::DegradeSerialData()...)
    The original code (pow(2, ceil(log2())) has some border effects when built with MSYS2 mingw64 "Release" mode as it does not compute correctly the highest power of 2 for example with parameter 100000 it was returning 131071 (instead of 131072) which crashed ffts.
    This implementation fix issue ngscopeclient/scopehal-apps#295
    The function next_pow2() shall replace pow(2, ceil(log2())) in following code:
    scopehal\TestWaveformSource.cpp
    	Line 282: 	//const size_t npoints = pow(2, ceil(log2(depth)));
    scopeprotocols\DeEmbedFilter.cpp
    	Line 230: 	const size_t npoints = pow(2, ceil(log2(npoints_raw)));
    scopeprotocols\FFTFilter.cpp
    	Line 179: 	const size_t npoints = pow(2, ceil(log2(npoints_raw)));
    scopeprotocols\JitterSpectrumFilter.cpp
    	Line 195: 	const size_t npoints = pow(2, ceil(log2(npoints_raw)));
    bvernoux authored Dec 7, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    25a912f View commit details
  2. Merge pull request #374 from bvernoux/patch-1

    Compute next highest power of 2 function
    azonenberg authored Dec 7, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    45d156e View commit details
Showing with 15 additions and 0 deletions.
  1. +15 −0 scopehal/scopehal.cpp
15 changes: 15 additions & 0 deletions scopehal/scopehal.cpp
Original file line number Diff line number Diff line change
@@ -409,3 +409,18 @@ string to_string_sci(double d)
snprintf(tmp, sizeof(tmp), "%e", d);
return tmp;
}

/**
@brief compute the next highest power of 2 of 64-bit value
*/
uint64_t next_pow2(uint64_t v)
{
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v++;
return v;
}