Loading src/Benchmarks/HeatEquationGrid/HeatmapNDimGrid/implementation.h +11 −7 Original line number Diff line number Diff line Loading @@ -359,11 +359,14 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters ¶ms) c const Real hx = params.xDomainSize / (Real)grid.getDimension(0); const Real hy = params.yDomainSize / (Real)grid.getDimension(1); const Real hx_inv = 1 / (hx * hx); const Real hy_inv = 1 / (hy * hy); const Real hx_inv = 1. / (hx * hx); const Real hy_inv = 1. / (hy * hy); auto entitiesCount = grid.getEntitiesCount(0); auto timestep = params.timeStep ? params.timeStep : std::min(hx * hx, hy * hy); auto xDomainSize = params.xDomainSize; auto yDomainSize = params.yDomainSize; auto sigma = params.sigma; TNL::Containers::Array<Real, Device> ux(entitiesCount), // data at step u aux(entitiesCount);// data at step u + 1 Loading @@ -378,10 +381,10 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters ¶ms) c auto position = entity.getCoordinates(); auto index = entity.getIndex(); auto x = position[0] * hx - params.xDomainSize / 2; auto y = position[1] * hx - params.yDomainSize / 2; auto x = position[0] * hx - xDomainSize / 2; auto y = position[1] * hx - yDomainSize / 2; uxView[index] = exp(params.sigma * (x * x + y * y)); uxView[index] = exp(sigma * (x * x + y * y)); }; const Container<2, bool> direction{ false, false }; Loading @@ -398,9 +401,10 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters ¶ms) c auto next = [=] __cuda_callable__(const GridEntity<2, int>& entity) mutable { auto index = entity.getIndex(); auto center = 2 * uxView[index]; auxView[index] = (uxView[index - 1] - 2 * uxView[index] + uxView[index + 1]) * hx_inv + (uxView[index - xDimension] - 2 * uxView[index] + uxView[index + xDimension]) * hy_inv; auxView[index] = (uxView[index - 1] - center + uxView[index + 1]) * hx_inv + (uxView[index - xDimension] - center + uxView[index + xDimension]) * hy_inv; }; auto update = [=] __cuda_callable__(int i) mutable { Loading src/Benchmarks/HeatEquationGrid/HeatmapParallelFor/implementation.h +15 −9 Original line number Diff line number Diff line Loading @@ -39,21 +39,26 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters ¶ms) c const Real hx = params.xDomainSize / (Real)params.xSize; const Real hy = params.yDomainSize / (Real)params.ySize; const Real hx_inv = 1 / (hx * hx); const Real hy_inv = 1 / (hy * hy); const Real hx_inv = 1. / (hx * hx); const Real hy_inv = 1. / (hy * hy); auto timestep = params.timeStep ? params.timeStep : std::min(hx * hx, hy * hy); auto uxView = ux.getView(), auxView = aux.getView(); auto xSize = params.xSize; auto xDomainSize = params.xDomainSize; auto yDomainSize = params.yDomainSize; auto sigma = params.sigma; auto init = [=] __cuda_callable__(int i, int j) mutable { auto index = j * params.xSize + i; auto index = j * xSize + i; auto x = i * hx - params.xDomainSize / 2; auto y = j * hy - params.yDomainSize / 2; auto x = i * hx - xDomainSize / 2.; auto y = j * hy - yDomainSize / 2.; uxView[index] = exp(params.sigma * (x * x + y * y)); uxView[index] = exp(sigma * (x * x + y * y)); }; TNL::Algorithms::ParallelFor2D<Device>::exec(1, 1, params.xSize - 1, params.ySize - 1, init); Loading @@ -63,10 +68,11 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters ¶ms) c auto next = [=] __cuda_callable__(int i, int j) mutable { auto index = j * params.xSize + i; auto index = j * xSize + i; auto center = 2 * uxView[index]; auxView[index] = (uxView[index - 1] - 2 * uxView[index] + uxView[index + 1]) * hx_inv + (uxView[index - params.xSize] - 2 * uxView[index] + uxView[index + params.xSize]) * hy_inv; auxView[index] = (uxView[index - 1] - center + uxView[index + 1]) * hx_inv + (uxView[index - xSize] - center + uxView[index + xSize]) * hy_inv; }; auto update = [=] __cuda_callable__(int i) mutable Loading src/Benchmarks/HeatEquationGrid/HeatmapTNLGrid/implementation.h +13 −8 Original line number Diff line number Diff line Loading @@ -26,21 +26,25 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters& params) c const Real hx = params.xDomainSize / (Real)params.xSize; const Real hy = params.yDomainSize / (Real)params.ySize; const Real hx_inv = 1 / (hx * hx); const Real hy_inv = 1 / (hy * hy); const Real hx_inv = 1. / (hx * hx); const Real hy_inv = 1. / (hy * hy); auto timestep = params.timeStep ? params.timeStep : std::min(hx * hx, hy * hy); auto uxView = ux.getView(), auxView = aux.getView(); auto xDomainSize = params.xDomainSize; auto yDomainSize = params.yDomainSize; auto sigma = params.sigma; auto init = [=] __cuda_callable__(const typename Grid2D::EntityType<0> &entity) mutable { auto index = entity.getIndex(); auto x = entity.getCoordinates().x() * hx - params.xDomainSize / 2; auto y = entity.getCoordinates().y() * hy - params.yDomainSize / 2; auto x = entity.getCoordinates().x() * hx - xDomainSize / 2.; auto y = entity.getCoordinates().y() * hy - yDomainSize / 2.; uxView[index] = exp(params.sigma * (x * x + y * y)); uxView[index] = exp(sigma * (x * x + y * y)); }; grid.template forInterior<0>(init); Loading @@ -48,12 +52,13 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters& params) c if (!writeGNUPlot("data.txt", params, ux)) return false; auto width = grid.getDimensions().x() + 1; auto next = [=] __cuda_callable__(const typename Grid2D::EntityType<0>&entity) mutable { auto index = entity.getIndex(); auto width = grid.getDimensions().x() + 1; auto center = 2 * uxView[index]; auxView[index] = (uxView[index - 1] - 2 * uxView[index] + uxView[index + 1]) * hx_inv + (uxView[index - width] - 2 * uxView[index] + uxView[index + width]) * hy_inv; auxView[index] = (uxView[index - 1] - center + uxView[index + 1]) * hx_inv + (uxView[index - width] - center + uxView[index + width]) * hy_inv; }; auto update = [=] __cuda_callable__(const typename Grid2D::EntityType<0>&entity) mutable { Loading Loading
src/Benchmarks/HeatEquationGrid/HeatmapNDimGrid/implementation.h +11 −7 Original line number Diff line number Diff line Loading @@ -359,11 +359,14 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters ¶ms) c const Real hx = params.xDomainSize / (Real)grid.getDimension(0); const Real hy = params.yDomainSize / (Real)grid.getDimension(1); const Real hx_inv = 1 / (hx * hx); const Real hy_inv = 1 / (hy * hy); const Real hx_inv = 1. / (hx * hx); const Real hy_inv = 1. / (hy * hy); auto entitiesCount = grid.getEntitiesCount(0); auto timestep = params.timeStep ? params.timeStep : std::min(hx * hx, hy * hy); auto xDomainSize = params.xDomainSize; auto yDomainSize = params.yDomainSize; auto sigma = params.sigma; TNL::Containers::Array<Real, Device> ux(entitiesCount), // data at step u aux(entitiesCount);// data at step u + 1 Loading @@ -378,10 +381,10 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters ¶ms) c auto position = entity.getCoordinates(); auto index = entity.getIndex(); auto x = position[0] * hx - params.xDomainSize / 2; auto y = position[1] * hx - params.yDomainSize / 2; auto x = position[0] * hx - xDomainSize / 2; auto y = position[1] * hx - yDomainSize / 2; uxView[index] = exp(params.sigma * (x * x + y * y)); uxView[index] = exp(sigma * (x * x + y * y)); }; const Container<2, bool> direction{ false, false }; Loading @@ -398,9 +401,10 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters ¶ms) c auto next = [=] __cuda_callable__(const GridEntity<2, int>& entity) mutable { auto index = entity.getIndex(); auto center = 2 * uxView[index]; auxView[index] = (uxView[index - 1] - 2 * uxView[index] + uxView[index + 1]) * hx_inv + (uxView[index - xDimension] - 2 * uxView[index] + uxView[index + xDimension]) * hy_inv; auxView[index] = (uxView[index - 1] - center + uxView[index + 1]) * hx_inv + (uxView[index - xDimension] - center + uxView[index + xDimension]) * hy_inv; }; auto update = [=] __cuda_callable__(int i) mutable { Loading
src/Benchmarks/HeatEquationGrid/HeatmapParallelFor/implementation.h +15 −9 Original line number Diff line number Diff line Loading @@ -39,21 +39,26 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters ¶ms) c const Real hx = params.xDomainSize / (Real)params.xSize; const Real hy = params.yDomainSize / (Real)params.ySize; const Real hx_inv = 1 / (hx * hx); const Real hy_inv = 1 / (hy * hy); const Real hx_inv = 1. / (hx * hx); const Real hy_inv = 1. / (hy * hy); auto timestep = params.timeStep ? params.timeStep : std::min(hx * hx, hy * hy); auto uxView = ux.getView(), auxView = aux.getView(); auto xSize = params.xSize; auto xDomainSize = params.xDomainSize; auto yDomainSize = params.yDomainSize; auto sigma = params.sigma; auto init = [=] __cuda_callable__(int i, int j) mutable { auto index = j * params.xSize + i; auto index = j * xSize + i; auto x = i * hx - params.xDomainSize / 2; auto y = j * hy - params.yDomainSize / 2; auto x = i * hx - xDomainSize / 2.; auto y = j * hy - yDomainSize / 2.; uxView[index] = exp(params.sigma * (x * x + y * y)); uxView[index] = exp(sigma * (x * x + y * y)); }; TNL::Algorithms::ParallelFor2D<Device>::exec(1, 1, params.xSize - 1, params.ySize - 1, init); Loading @@ -63,10 +68,11 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters ¶ms) c auto next = [=] __cuda_callable__(int i, int j) mutable { auto index = j * params.xSize + i; auto index = j * xSize + i; auto center = 2 * uxView[index]; auxView[index] = (uxView[index - 1] - 2 * uxView[index] + uxView[index + 1]) * hx_inv + (uxView[index - params.xSize] - 2 * uxView[index] + uxView[index + params.xSize]) * hy_inv; auxView[index] = (uxView[index - 1] - center + uxView[index + 1]) * hx_inv + (uxView[index - xSize] - center + uxView[index + xSize]) * hy_inv; }; auto update = [=] __cuda_callable__(int i) mutable Loading
src/Benchmarks/HeatEquationGrid/HeatmapTNLGrid/implementation.h +13 −8 Original line number Diff line number Diff line Loading @@ -26,21 +26,25 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters& params) c const Real hx = params.xDomainSize / (Real)params.xSize; const Real hy = params.yDomainSize / (Real)params.ySize; const Real hx_inv = 1 / (hx * hx); const Real hy_inv = 1 / (hy * hy); const Real hx_inv = 1. / (hx * hx); const Real hy_inv = 1. / (hy * hy); auto timestep = params.timeStep ? params.timeStep : std::min(hx * hx, hy * hy); auto uxView = ux.getView(), auxView = aux.getView(); auto xDomainSize = params.xDomainSize; auto yDomainSize = params.yDomainSize; auto sigma = params.sigma; auto init = [=] __cuda_callable__(const typename Grid2D::EntityType<0> &entity) mutable { auto index = entity.getIndex(); auto x = entity.getCoordinates().x() * hx - params.xDomainSize / 2; auto y = entity.getCoordinates().y() * hy - params.yDomainSize / 2; auto x = entity.getCoordinates().x() * hx - xDomainSize / 2.; auto y = entity.getCoordinates().y() * hy - yDomainSize / 2.; uxView[index] = exp(params.sigma * (x * x + y * y)); uxView[index] = exp(sigma * (x * x + y * y)); }; grid.template forInterior<0>(init); Loading @@ -48,12 +52,13 @@ bool HeatmapSolver<Real>::solve(const HeatmapSolver<Real>::Parameters& params) c if (!writeGNUPlot("data.txt", params, ux)) return false; auto width = grid.getDimensions().x() + 1; auto next = [=] __cuda_callable__(const typename Grid2D::EntityType<0>&entity) mutable { auto index = entity.getIndex(); auto width = grid.getDimensions().x() + 1; auto center = 2 * uxView[index]; auxView[index] = (uxView[index - 1] - 2 * uxView[index] + uxView[index + 1]) * hx_inv + (uxView[index - width] - 2 * uxView[index] + uxView[index + width]) * hy_inv; auxView[index] = (uxView[index - 1] - center + uxView[index + 1]) * hx_inv + (uxView[index - width] - center + uxView[index + width]) * hy_inv; }; auto update = [=] __cuda_callable__(const typename Grid2D::EntityType<0>&entity) mutable { Loading