Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

field versioning bug #1056

Open
cosunae opened this issue Nov 5, 2020 · 0 comments
Open

field versioning bug #1056

cosunae opened this issue Nov 5, 2020 · 0 comments
Labels

Comments

@cosunae
Copy link
Contributor

cosunae commented Nov 5, 2020

With the example below, the field versioning triggers a bug.
There is a circular dependency with
hC <-, -> hC_t

which does not trigger a field versioning by the algorithm since the SCC does not contain horizontal extent accesses.
However the algorithm also checks that the graph contains (at least one) input only nodes and output only nodes.

if(stencilSCCs->empty() && !SCCs->empty() && !graph.isDAG()) {

When the algorithm inserts (in the backward traversal of statements) the statement,
hE = hC[i + 1] * (1 - alpha) + hC[i - 1] * alpha;

the condition that contains (at least one) input only node does not hold true. The algorithm thinks this is due to the SCC of hC <-, -> hC_t, which is not true, since this SCC was inserted before.

Full example:

#include "gtclang_dsl_defs/gtclang_dsl.hpp"
using namespace gtclang::dsl;
 
stencil lap {
  storage_ij hinitC;
  storage_ij hC;
  storage_ij hC_t;
  storage_ij vinitC;
  storage_ij vC;
  storage_ij vC_t;
  storage_ij uinitC;
  storage_ij uC;
  storage_ij uC_t;
  storage_ij hC_x;
  storage_ij hC_y;
  storage_ij uvC_div;
  storage_ij hE;
  storage_ij vE;
  storage_ij uE;
  storage_ij nx;
  storage_ij ny;
  storage_ij L;
  storage_ij alpha;
  storage_ij boundary_edges;
  storage_ij boundary_cells;
  storage_ij A;
  storage_ij edge_orientation;
  storage_ij dt;
  storage_ij Grav;
  Do {
    vertical_region(k_start, k_end) {
      hinitC = hC;
      uinitC = uC;
      vinitC = vC;
 
      // predict
      hC = hinitC + 0.5 * dt * hC_t;
      uC = uinitC + 0.5 * dt * uC_t;
      vC = vinitC + 0.5 * dt * vC_t;
 
      // lerp cell quantities to edges
      hE = hC[i + 1] * (1 - alpha) + hC[i - 1] * alpha;
      uE = uC[i + 1] * (1 - alpha) + uC[i - 1] * alpha;
      vE = vC[i + 1] * (1 - alpha) + vC[i - 1] * alpha;
 
      // height field gradient
      hC_x = hE[i + 1] * nx[i + 1] * L[i + 1] * edge_orientation[i + 1];
      hC_y = hE[i + 1] * ny[i + 1] * L[i + 1] * edge_orientation[i + 1];
 
       // divergence of velocity field
      uvC_div =
          ((uE[i + 1] * nx[i + 1] + vE[i + 1] * ny[i + 1]) * edge_orientation[i + 1] * L[i + 1]) /
          A;
 
      // build ODE's
      uC_t = -Grav * hC_x;
      vC_t = -Grav * hC_y;
      hC_t = hC * uvC_div;
 
      // corrector
      hC = hinitC + dt * hC_t;
      uC = uinitC + dt * uC_t;
      vC = vinitC + dt * vC_t;
    }
  }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant