@@ -63,19 +63,21 @@ auto main()
6363
6464 using T = double ;
6565 {
66- auto cpu = multi::array<T, 2 >({64 , 1048576 }, 0 );
67- auto cpu_par = multi::array<T, 2 >({64 , 1048576 });
66+ auto cpu_own = multi::array<T, 3 >({64 , 64 , 64 }, 0 );
6867
68+ auto && cpu = cpu_own ();
6969 {
70- auto_timer t{" std::for_each" };
71- std::for_each (cpu.begin (), cpu.end (), [](auto && row) {
72- for (auto && e : row) {
73- e += std::sqrt (std::pow (e, 1.5 ) + std::sin (e));
70+ auto_timer const _{" std::for_each" };
71+ std::for_each (cpu.begin (), cpu.end (), [](auto && plane) {
72+ for (auto && row : plane) { // NOLINT(altera-unroll-loops)
73+ for (auto && elem : row) {
74+ elem += std::sqrt (std::pow (elem, 1.5 ) + std::sin (elem));
75+ }
7476 }
7577 });
7678 }
7779
78- auto gpu_par = multi::thrust::device_array<T, 2 >({64 , 1048576 } );
80+ auto gpu_par = multi::thrust::device_array<T, 3 >({64 , 64 , 64 }, 0 );
7981 // {
8082 // auto_timer t{"thrust::for_each(thrust::cuda::par)"};
8183 // thrust::for_each(gpu_par.begin(), gpu_par.end(), [] __device__ (auto&& row) {
@@ -85,7 +87,7 @@ auto main()
8587 // });
8688 // }
8789 {
88- auto_timer t {" thrust::for_each(thrust::cuda::par, elements)" };
90+ auto_timer const _ {" thrust::for_each(thrust::cuda::par, elements)" };
8991 thrust::for_each (thrust::cuda::par, gpu_par.elements ().begin (), gpu_par.elements ().end (), [] __device__ (auto & e) {
9092 e += std::sqrt (std::pow (e, 1.5 ) + std::sin (e));
9193 });
0 commit comments