MCPcopy Create free account
hub / github.com/OpenPathGuidingLibrary/openpgl / bench_lookup_sample

Function bench_lookup_sample

tools/openpgl_bench/openpgl_bench.cpp:357–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355}
356
357void bench_lookup_sample(BenchParams &benchParams, bool applyCosine, bool sample)
358{
359 int nThreads = benchParams.num_threads;
360 int nRepetitions = 10;
361
362 int num_threads = 0; // tbb::info::default_concurrency();
363 if (nThreads > 0)
364 {
365 num_threads = nThreads;
366 }
367 tbb::global_control global_limit(tbb::global_control::max_allowed_parallelism, num_threads);
368 std::cout << "num_threads = " << num_threads << std::endl;
369
370 openpgl::cpp::Device device(benchParams.device_type);
371 openpgl::cpp::Field field(&device, benchParams.field_file_name);
372 openpgl::cpp::SampleStorage sampleStorage(benchParams.samples_file_names[0]);
373
374 std::cout << "Field::Validate: " << field.Validate() << std::endl;
375
376 int nSurfaceSamples = sampleStorage.GetSizeSurface();
377
378 std::cout << "Prepare Data: START" << std::endl;
379 std::mt19937_64 gen(1337);
380 std::uniform_real_distribution<float> distU(0.f, 1.f);
381
382 float *samplesSurfaceU = new float[nSurfaceSamples];
383 pgl_vec2f *samplesSurfaceDirectionUV = new pgl_vec2f[nSurfaceSamples];
384 pgl_vec3f *sampleSurfaceNormal = new pgl_vec3f[nSurfaceSamples];
385 pgl_vec3f *sampleSurfaceSampledDirection = new pgl_vec3f[nSurfaceSamples];
386 pgl_vec3f *positionsSurface = new pgl_vec3f[nSurfaceSamples];
387
388 for (int i = 0; i < nSurfaceSamples; i++)
389 {
390 int idx = i;
391 samplesSurfaceU[idx] = distU(gen);
392 samplesSurfaceDirectionUV[idx].x = distU(gen);
393 samplesSurfaceDirectionUV[idx].y = distU(gen);
394 sampleSurfaceNormal[idx] = squareToUniformSphere(distU(gen), distU(gen));
395
396 openpgl::cpp::SampleData sd = sampleStorage.GetSampleSurface(i);
397 positionsSurface[idx] = sd.position;
398 }
399
400 std::cout << "Prepare Data: END" << std::endl;
401
402 Timer timer;
403 timer.reset();
404 int step = nSurfaceSamples / num_threads;
405 tbb::parallel_for(tbb::blocked_range<int>(0, num_threads), [&](tbb::blocked_range<int> r) {
406 for (int n = r.begin(); n < r.end(); ++n)
407 {
408 openpgl::cpp::SurfaceSamplingDistribution ssd(&field);
409 for (int m = 0; m < nRepetitions; m++)
410 {
411 int tStep = n * step;
412 for (int i = 0; i < nSurfaceSamples; i++)
413 {
414 int idx = (i + tStep) % nSurfaceSamples;

Callers 1

mainFunction · 0.85

Calls 12

parallel_forFunction · 0.85
GetSizeSurfaceMethod · 0.80
GetSampleSurfaceMethod · 0.80
ApplyCosineProductMethod · 0.80
squareToUniformSphereFunction · 0.70
ValidateMethod · 0.45
resetMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
InitMethod · 0.45
SamplePDFMethod · 0.45
elapsedMethod · 0.45

Tested by

no test coverage detected