@@ -80,37 +80,32 @@ TEST_CASE("Primitive_FindZeroCrossings")
8080 double dt = GetTime () - start;
8181 LogNotice (" CPU: %.3f ms, %zu edges, %zu samples\n " , dt*1000 , edges.size (), depth);
8282
83- {
84- LogNotice (" First few ref timestamps:\n " );
85- LogIndenter li;
86- for (size_t i=0 ; i<5 ; i++)
87- LogNotice (" %" PRIi64 " \n " , edges[i]);
88- }
89-
9083 // Do the GPU version
9184 // Run twice, second time for score, so we don't count deferred init or allocations in the benchmark
9285 LevelCrossingDetector ldet;
93- ldet.FindZeroCrossings (wfm, threshold, cmdBuf, queue);
86+ auto & gpuedges = ldet.GetResults ();
87+ size_t gpulen = ldet.FindZeroCrossings (wfm, threshold, cmdBuf, queue);
9488 start = GetTime ();
95- ldet.FindZeroCrossings (wfm, threshold, cmdBuf, queue);
89+ gpulen = ldet.FindZeroCrossings (wfm, threshold, cmdBuf, queue);
9690 dt = GetTime () - start;
97- LogNotice (" GPU: %.3f ms, TBD \n " , dt*1000 );
91+ LogNotice (" GPU: %.3f ms, %zu edges \n " , dt*1000 , gpulen );
9892
99- /*
100- //Initial sanity check: we should have the same number of data bits as we generated,
101- //and all sizes should be consistent
102- REQUIRE(nsamples == samples.m_offsets.size());
103- REQUIRE(nsamples == samples.m_durations.size());
104- REQUIRE(nsamples == samples.m_samples.size());
93+ // Don't count the final memcpy against run time since we assume the buffer is going to get used on the GPU
94+ gpuedges.PrepareForCpuAccess ();
10595
106- //Check each of the bits
107- for(size_t i=0; i<nsamples; i++)
96+ // Verify everything matches
97+ // Allow +/- 1 timebase unit of mismatch for different CPU-GPU rounding behavior in the interpolation
98+ REQUIRE (gpulen == edges.size ());
99+ for (size_t i=0 ; i<edges.size (); i++)
108100 {
109- REQUIRE(samples.m_offsets[i] == samples_expected.m_offsets[i]);
110- REQUIRE(samples.m_durations[i] == samples_expected.m_durations[i]);
111- REQUIRE(samples.m_samples[i] == samples_expected.m_samples[i]);
101+ int64_t delta = edges[i] - gpuedges[i];
102+
103+ if ( (delta > 1 ) || (delta < -1 ) )
104+ LogNotice (" mismatch at i=%zu\n " , i);
105+
106+ REQUIRE (delta <= 1 );
107+ REQUIRE (delta >= -1 );
112108 }
113- */
114109
115110 // done, clean up
116111 delete wfm;
0 commit comments