devitocodes / devito

DSL and compiler framework for automated finite-differences and stencil computation
http://www.devitoproject.org
MIT License
562 stars 228 forks source link

Check Subdimension.local is honored to avoid OOB accesses #1164

Open FabioLuporini opened 4 years ago

FabioLuporini commented 4 years ago

reproducer:

python tti_example.py

look at the generated code for the padfunc builtin, you'll see something along the lines of

phi[abc_x_l + 4][y + 4][z + 4] = phi[44][y + 4][z + 4];

the 44 should be a symbolic entity, not an hardcoded number

FabioLuporini commented 4 years ago

update: this is due to SubDimension(local=...

FabioLuporini commented 4 years ago

however, the +40 due to nbl should become a symbol otherwise it's gonna be OOB if we supply a (much) smaller Function upon op.apply ?

mloubout commented 4 years ago

gonna be OOB if we supply a (much) smaller Function upon op.apply ?

THis line should prevent it no? https://github.com/devitocodes/devito/blob/08aa3f8648dfabb43677c44aba1639e5130c9b05/devito/builtins.py#L306

mloubout commented 4 years ago

No would OOB for the constant case still.