Skip to content

Commit 5d33696

Browse files
committed
Modified names of the functions to represent what they do (ie. calc_pi_*) per suggestion from Paul.
Signed-off-by: todd.erdner <[email protected]>
1 parent 5c0c2c6 commit 5d33696

File tree

1 file changed

+22
-22
lines changed
  • DirectProgramming/DPC++/ParallelPatterns/dpc_reduce/src

1 file changed

+22
-22
lines changed

DirectProgramming/DPC++/ParallelPatterns/dpc_reduce/src/main.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using namespace sycl;
2020
// cpu_seq is a simple sequential CPU routine
2121
// that calculates all the slices and then
2222
// does a reduction.
23-
float cpu_seq(int num_steps) {
23+
float calc_pi_cpu_seq(int num_steps) {
2424
float step = 1.0 / (float)num_steps;
2525
float x;
2626
float sum = 0.0;
@@ -34,7 +34,7 @@ float cpu_seq(int num_steps) {
3434
// cpu_tbb is a simple parallel_reduce tbb routine
3535
// that calculates all the slices and then
3636
// uses tbb reduce to combine results.
37-
float cpu_tbb(int num_steps) {
37+
float calc_pi_cpu_tbb(int num_steps) {
3838
float step = 1.0 / (float)num_steps;
3939

4040
auto tbbtotal =
@@ -58,7 +58,7 @@ float cpu_tbb(int num_steps) {
5858
// how to do calculations directly in dpc++ with
5959
// mininmal complexity.
6060
template <typename Policy>
61-
float dpstd_native(size_t num_steps, Policy&& policy) {
61+
float calc_pi_dpstd_native(size_t num_steps, Policy&& policy) {
6262
float step = 1.0 / (float)num_steps;
6363

6464
float data[num_steps];
@@ -93,7 +93,7 @@ float dpstd_native(size_t num_steps, Policy&& policy) {
9393
// This option uses a parallel for to fill the array, and then use a single
9494
// task to reduce into groups and then use cpu for final reduction.
9595
template <typename Policy>
96-
float dpstd_native2(size_t num_steps, Policy&& policy, int group_size) {
96+
float calc_pi_dpstd_native2(size_t num_steps, Policy&& policy, int group_size) {
9797
float step = 1.0 / (float)num_steps;
9898

9999
float data[num_steps];
@@ -166,7 +166,7 @@ struct slice_area {
166166
// uses a tranform_init with plus/no_op and then
167167
// a local reduction then global reduction.
168168
template <typename Policy>
169-
float dpstd_native3(size_t num_steps, int groups, Policy&& policy) {
169+
float calc_pi_dpstd_native3(size_t num_steps, int groups, Policy&& policy) {
170170
float data[num_steps];
171171

172172
// Create buffer using host allocated "data" array
@@ -276,7 +276,7 @@ float dpstd_native3(size_t num_steps, int groups, Policy&& policy) {
276276
// calls transform_init to calculate the slices and then
277277
// does a reduction in two steps - global and then local.
278278
template <typename Policy>
279-
float dpstd_native4(size_t num_steps, int groups, Policy&& policy) {
279+
float calc_pi_dpstd_native4(size_t num_steps, int groups, Policy&& policy) {
280280
std::vector<float> data(num_steps);
281281
float result = 0.0;
282282

@@ -390,7 +390,7 @@ float dpstd_native4(size_t num_steps, int groups, Policy&& policy) {
390390
// calculations of each small rectangle. The second call is the reduce
391391
// call which sums up the results of all the elements in the buffer.
392392
template <typename Policy>
393-
float dpstd_two_steps_lib(int num_steps, Policy&& policy) {
393+
float calc_pi_dpstd_two_steps_lib(int num_steps, Policy&& policy) {
394394
float step = 1.0 / (float)num_steps;
395395

396396
buffer<float> calc_values{num_steps};
@@ -422,7 +422,7 @@ float dpstd_two_steps_lib(int num_steps, Policy&& policy) {
422422
// transform reduce. It does everything in one library
423423
// call.
424424
template <typename Policy>
425-
float dpstd_onestep(int num_steps, Policy& policy) {
425+
float calc_pi_dpstd_onestep(int num_steps, Policy& policy) {
426426
float step = 1.0f / (float)num_steps;
427427

428428
float total = std::transform_reduce(
@@ -450,65 +450,65 @@ int main(int argc, char** argv) {
450450
// Since we are using JIT compiler for samples,
451451
// we need to run each step once to allow for compile
452452
// to occur before we time execution of function.
453-
pi = dpstd_native(num_steps, policy);
454-
pi = dpstd_native2(num_steps, policy, groups);
455-
pi = dpstd_native3(num_steps, groups, policy);
456-
pi = dpstd_native4(num_steps, groups, policy);
453+
pi = calc_pi_dpstd_native(num_steps, policy);
454+
pi = calc_pi_dpstd_native2(num_steps, policy, groups);
455+
pi = calc_pi_dpstd_native3(num_steps, groups, policy);
456+
pi = calc_pi_dpstd_native4(num_steps, groups, policy);
457457

458-
pi = dpstd_two_steps_lib(num_steps, policy);
459-
pi = dpstd_onestep(num_steps, policy);
458+
pi = calc_pi_dpstd_two_steps_lib(num_steps, policy);
459+
pi = calc_pi_dpstd_onestep(num_steps, policy);
460460

461461
dpc_common::TimeInterval T;
462-
pi = cpu_seq(num_steps);
462+
pi = calc_pi_cpu_seq(num_steps);
463463
auto stop = T.Elapsed();
464464
std::cout << "Cpu Seq calc: \t\t";
465465
std::cout << std::setprecision(3) << "PI =" << pi;
466466
std::cout << " in " << stop << " seconds\n";
467467

468468
dpc_common::TimeInterval T2;
469-
pi = cpu_tbb(num_steps);
469+
pi = calc_pi_cpu_tbb(num_steps);
470470
auto stop2 = T2.Elapsed();
471471
std::cout << "Cpu TBB calc: \t\t";
472472
std::cout << std::setprecision(3) << "PI =" << pi;
473473
std::cout << " in " << stop2 << " seconds\n";
474474

475475
dpc_common::TimeInterval T3;
476-
pi = dpstd_native(num_steps, policy);
476+
pi = calc_pi_dpstd_native(num_steps, policy);
477477
auto stop3 = T3.Elapsed();
478478
std::cout << "dpstd native:\t\t";
479479
std::cout << std::setprecision(3) << "PI =" << pi;
480480
std::cout << " in " << stop3 << " seconds\n";
481481

482482
dpc_common::TimeInterval T3a;
483-
pi = dpstd_native2(num_steps, policy, groups);
483+
pi = calc_pi_dpstd_native2(num_steps, policy, groups);
484484
auto stop3a = T3a.Elapsed();
485485
std::cout << "dpstd native2:\t\t";
486486
std::cout << std::setprecision(3) << "PI =" << pi;
487487
std::cout << " in " << stop3a << " seconds\n";
488488

489489
dpc_common::TimeInterval T3b;
490-
pi = dpstd_native3(num_steps, groups, policy);
490+
pi = calc_pi_dpstd_native3(num_steps, groups, policy);
491491
auto stop3b = T3b.Elapsed();
492492
std::cout << "dpstd native3:\t\t";
493493
std::cout << std::setprecision(3) << "PI =" << pi;
494494
std::cout << " in " << stop3b << " seconds\n";
495495

496496
dpc_common::TimeInterval T3c;
497-
pi = dpstd_native4(num_steps, groups, policy);
497+
pi = calc_pi_dpstd_native4(num_steps, groups, policy);
498498
auto stop3c = T3c.Elapsed();
499499
std::cout << "dpstd native4:\t\t";
500500
std::cout << std::setprecision(3) << "PI =" << pi;
501501
std::cout << " in " << stop3c << " seconds\n";
502502

503503
dpc_common::TimeInterval T4;
504-
pi = dpstd_two_steps_lib(num_steps, policy);
504+
pi = calc_pi_dpstd_two_steps_lib(num_steps, policy);
505505
auto stop4 = T4.Elapsed();
506506
std::cout << "dpstd two steps:\t";
507507
std::cout << std::setprecision(3) << "PI =" << pi;
508508
std::cout << " in " << stop4 << " seconds\n";
509509

510510
dpc_common::TimeInterval T5;
511-
pi = dpstd_onestep(num_steps, policy);
511+
pi = calc_pi_dpstd_onestep(num_steps, policy);
512512
auto stop5 = T5.Elapsed();
513513
std::cout << "dpstd transform_reduce: ";
514514
std::cout << std::setprecision(3) << "PI =" << pi;

0 commit comments

Comments
 (0)