Git Product home page Git Product logo

hpc4wc's People

Contributors

beathubmann avatar cloudfederer avatar colintully92 avatar dastrm avatar deinfreund avatar dependabot[bot] avatar fytch avatar gvollenweider avatar hbanderier avatar huanglangwen avatar iyanmv avatar jonasgrutterethz avatar lrndrs avatar lujoss avatar maede97 avatar mrpaga avatar ntselepidis avatar ofuhrer avatar pascal-so avatar prosku avatar rcu1 avatar sadamov avatar stubbiali avatar szx-pku avatar thisfro avatar tomlausberg avatar twicki avatar veni-vidi-vici-dormivi avatar westernmagic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hpc4wc's Issues

Issue with `stencil2d` and `stencil2d_gt4py` modules

The apply_difussion() function in these two modules (day1/stencil2d.py, day5/stencil2d-gt4py-v0.py) do not work as expected when num_iter is even. This is because the swapping inside the function is only valid within the scope of the function. When num_iter is even, the swapping happens an odd number of times, so outside the function, the actual result is stored in in_field array and not in out_field. This means that when num_iter is even, out_field corresponds to num_iter - 1 iterations of the diffusion.

The following block code demonstrates this:

import numpy as np
from stencil2d import apply_diffusion

NX = NY = 128
NZ = 80
alpha = 1.0 / 32.0

in_field1 = np.zeros([NZ, NY, NX])
in_field1[:, NY//2 - NY//4 : NY//2 + NY//4, NX//2 - NX//4 : NX//2 + NX//4] = 1

in_field2 = np.copy(in_field1)

out_field1 = np.zeros_like(in_field1)
out_field2 = np.zeros_like(in_field1)

apply_diffusion(in_field1, out_field1, alpha=alpha, num_halo=2, num_iter=49)
apply_diffusion(in_field2, out_field2, alpha=alpha, num_halo=2, num_iter=50)

# out_field after 49 iterations equal to out_field after 50 iterations
np.allclose(out_field1, out_field2, rtol=1e-5, atol=1e-8, equal_nan=True)

The bug was found by @dymastery when working on the correctness checks in our project: #46.

A possible solution is to return out_field as we have done in our modified stencil2d and stencil2d_gt4py modules. This does not impact performance, as only a pointer is returned and no extra copies are made, and ensures that we keep track of the right field no matter the value of num_iter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.