Skip to content

Commit

Permalink
Merge pull request #30 from yasahi-hpc/hotfix-executors-cpu
Browse files Browse the repository at this point in the history
[Bugfix] fix memory space issue for executors with CPU backend
  • Loading branch information
yasahi-hpc authored Aug 4, 2023
2 parents 885bf52 + 3f9959d commit 2b590b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mini-apps/heat3d/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename ElementType>
Expand Down
7 changes: 6 additions & 1 deletion tutorial/05_heat2d/heat2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <numeric>
#include <array>
#include <stdexec/execution.hpp>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/transform_reduce.h>
#include <thrust/execution_policy.h>
Expand All @@ -15,7 +16,11 @@
#include "exec/on.hpp"
#include "heat2D.hpp"

using Vector = thrust::device_vector<double>;
#if defined(ENABLE_OPENMP)
using Vector = thrust::host_vector<double>;
#else
using Vector = thrust::device_vector<double>;
#endif

int main(int argc, char *argv[]) {
// Set configuration
Expand Down
6 changes: 3 additions & 3 deletions tutorial/05_heat2d/heat2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class Scheduler>
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2b590b3

Please sign in to comment.