@@ -89,8 +89,11 @@ float calc_pi_dpstd_native(size_t num_steps, Policy&& policy) {
89
89
});
90
90
policy.queue ().wait ();
91
91
92
- float mynewresult =
93
- buf.get_access <access::mode::read>()[0 ] / (float )num_steps;
92
+
93
+ // float mynewresult = buf.get_access<access::mode::read>()[0] / (float)num_steps;
94
+ host_accessor answer (buf,read_only) ;
95
+ float mynewresult = answer[0 ]/(float )num_steps;
96
+
94
97
return mynewresult;
95
98
}
96
99
@@ -386,10 +389,9 @@ float calc_pi_dpstd_native3(size_t num_steps, int groups, Policy&& policy) {
386
389
countby2 *= 2 ;
387
390
} while (countby2 < n_groups);
388
391
}
389
-
390
- float answer = temp_buf.template get_access <access::mode::read>()[0 ];
391
- result = answer / (float )num_steps;
392
- return result;
392
+
393
+ host_accessor answer (temp_buf,read_only) ;
394
+ return answer[0 ]/(float )num_steps;
393
395
}
394
396
395
397
// dpstd_native4 fills a buffer with number 1...num_steps and then
@@ -495,10 +497,11 @@ float calc_pi_dpstd_native4(size_t num_steps, int groups, Policy&& policy) {
495
497
countby2 *= 2 ;
496
498
} while (countby2 < n_groups);
497
499
}
498
- float answer = temp_buf.template get_access <access::mode::read_write>()[0 ];
499
- result = answer / (float )num_steps;
500
-
501
- return result;
500
+ // float answer = temp_buf.template get_access<access::mode::read_write>()[0];
501
+ // result = answer / (float)num_steps;
502
+
503
+ host_accessor answer (temp_buf,read_only) ;
504
+ return answer[0 ]/(float )num_steps;
502
505
}
503
506
504
507
// This function shows the use of two different DPC++ library calls.
0 commit comments