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-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bd4cef381402
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 381dbdc381c6
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jun 12, 2020

  1. ScopeSyncWizard: Fixed a few bugs. Multithreaded cross-correlations f…

    …or faster deskewing of deep waveforms. Limited max allowed skew to 10K points.
    azonenberg committed Jun 12, 2020
    Copy the full SHA
    381dbdc View commit details
Showing with 13 additions and 7 deletions.
  1. +13 −7 glscopeclient/ScopeSyncWizard.cpp
20 changes: 13 additions & 7 deletions glscopeclient/ScopeSyncWizard.cpp
Original file line number Diff line number Diff line change
@@ -331,10 +331,12 @@ void ScopeSyncWizard::OnWaveformDataReady()
m_primaryWaveform = pw;
m_secondaryWaveform = sw;

//Don't allow more than 50K samples of skew between instruments.
//The cross-correlation would start to get expensive at that point!
/*
Max allowed skew between instruments is 10K points.
At 10 Gsps this is a whopping 1000 ns, typical values are in the low tens of ns.
*/
m_maxSkewSamples = static_cast<int64_t>(pw->m_offsets.size() / 2);
m_maxSkewSamples = min(m_maxSkewSamples, 50000L);
m_maxSkewSamples = min(m_maxSkewSamples, 10000L);
m_delta = - m_maxSkewSamples;

//Set the timer
@@ -347,7 +349,7 @@ bool ScopeSyncWizard::OnTimer()
int64_t len = m_primaryWaveform->m_offsets.size();
size_t slen = m_secondaryWaveform->m_offsets.size();

int64_t samplesPerBlock = 1000;
int64_t samplesPerBlock = 5000;
int64_t blockEnd = min(m_delta + samplesPerBlock, len/2);
blockEnd = min(blockEnd, m_maxSkewSamples);

@@ -360,10 +362,12 @@ bool ScopeSyncWizard::OnTimer()
m_activeSecondaryPage->m_progressBar.set_text("Cross-correlate skew reference waveform");
m_activeSecondaryPage->m_progressBar.set_fraction(progress);

for(; m_delta < blockEnd; m_delta ++)
std::mutex cmutex;
#pragma omp parallel for
for(int64_t d = m_delta; d < blockEnd; d ++)
{
//Convert delta from samples of the primary waveform to picoseconds
int64_t deltaPs = m_primaryWaveform->m_timescale * m_delta;
int64_t deltaPs = m_primaryWaveform->m_timescale * d;

//Loop over samples in the primary waveform
ssize_t samplesProcessed = 0;
@@ -406,15 +410,17 @@ bool ScopeSyncWizard::OnTimer()
double normalizedCorrelation = correlation / samplesProcessed;

//Update correlation
lock_guard<mutex> lock(cmutex);
if(normalizedCorrelation > m_bestCorrelation)
{
m_bestCorrelation = normalizedCorrelation;
m_bestCorrelationOffset = m_delta;
}
}
m_delta = blockEnd;

//Need more data to go on
if(m_delta < len/2)
if(m_delta < m_maxSkewSamples)
return true;

//Collect the skew from this round