From 3f9959d0dcf75a977891224abb406f94d1a3de21 Mon Sep 17 00:00:00 2001 From: Yuuichi Asahi Date: Fri, 4 Aug 2023 14:36:03 +0900 Subject: [PATCH] [Bugfix] fix memory space issue for executors with CPU backend --- mini-apps/heat3d/types.hpp | 2 +- tutorial/05_heat2d/heat2D.cpp | 7 ++++++- tutorial/05_heat2d/heat2D.hpp | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/mini-apps/heat3d/types.hpp b/mini-apps/heat3d/types.hpp index ecfac88..6a10e83 100644 --- a/mini-apps/heat3d/types.hpp +++ b/mini-apps/heat3d/types.hpp @@ -14,7 +14,7 @@ namespace stdex = std::experimental; #if defined(_NVHPC_CUDA) || defined(__CUDACC__) using default_layout = stdex::layout_left; #else - using default_layout = stdex::layout_right; + using default_layout = stdex::layout_left; #endif template diff --git a/tutorial/05_heat2d/heat2D.cpp b/tutorial/05_heat2d/heat2D.cpp index 76ae0de..4ba08b9 100644 --- a/tutorial/05_heat2d/heat2D.cpp +++ b/tutorial/05_heat2d/heat2D.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -15,7 +16,11 @@ #include "exec/on.hpp" #include "heat2D.hpp" -using Vector = thrust::device_vector; +#if defined(ENABLE_OPENMP) + using Vector = thrust::host_vector; +#else + using Vector = thrust::device_vector; +#endif int main(int argc, char *argv[]) { // Set configuration diff --git a/tutorial/05_heat2d/heat2D.hpp b/tutorial/05_heat2d/heat2D.hpp index 11df83a..63fd705 100644 --- a/tutorial/05_heat2d/heat2D.hpp +++ b/tutorial/05_heat2d/heat2D.hpp @@ -163,7 +163,7 @@ void initialize(const Config& conf, const std::size_t n = conf.nx_ * conf.ny_; auto initializer = stdexec::just() | exec::on( scheduler, stdexec::bulk(n, init_functor(conf, x, y, u, un)) ); - stdexec::sync_wait(initializer); + stdexec::sync_wait( std::move(initializer) ); } template @@ -180,7 +180,7 @@ void finalize(const Config& conf, auto analytical_solution = stdexec::just() | exec::on( scheduler, stdexec::bulk(n, analytical_solution_functor(conf, time, x, y, un)) ); - stdexec::sync_wait(analytical_solution); + stdexec::sync_wait( std::move(analytical_solution) ); // Check errors // un: analytical, u: numerical solutions @@ -212,7 +212,7 @@ void step(const Config& conf, auto time_step = stdexec::just() | exec::on( scheduler, stdexec::bulk(n, heat2d_functor(conf, u, un)) ) | stdexec::then( [&]{ std::swap(u, un); }); - stdexec::sync_wait(time_step); + stdexec::sync_wait( std::move(time_step) ); } static void report_performance(const Config& conf, double seconds) {