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

[Bug] Fix Erroneous handling of ndarray in real function in CFG #8245

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

lin-hitonami
Copy link
Contributor

@lin-hitonami lin-hitonami commented Jun 29, 2023

Issue: #

arg_id doesn't make sense when two statements come from different callables. Therefore we cannot decide whether a ExternalPtrStmt in the real function points to the same ndarray as another ExternalPtrStmt in the kernel by checking the arg_id of them.

Instead, we can assume that all ndarrays passed into a real function can be modified. When a ndarray is passed into a real function, a ExternalTensorBasePtrStmt is inserted into the argument of the real function, which will appear in the store destinations of the FuncCallStmt. Then, we can add support for it in the alias analysis. We also don't include the ExternalPtrStmts in the real functions in the store destination sets as they don't make any sense.

Brief Summary

🤖 Generated by Copilot at ba828dc

Add support for real functions writing to external arrays or tensors. Update alias analysis and store destination collection to handle external pointers. Add a test case for the new feature.

Walkthrough

🤖 Generated by Copilot at ba828dc

  • Add a special case for alias analysis of external tensor base pointers (link)
  • Skip external pointers and matrix pointers from external pointers when gathering store destinations of a function (link)
  • Add a test case for real functions writing to external arrays or tensors in test_ndarray.py (link)

@netlify
Copy link

netlify bot commented Jun 29, 2023

Deploy Preview for docsite-preview canceled.

Name Link
🔨 Latest commit b561a2c
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/649d5dd1bb1b3a0008fa5678

@lin-hitonami lin-hitonami merged commit 9c5fb98 into taichi-dev:master Jun 30, 2023
@lin-hitonami lin-hitonami deleted the fix-ndarray-cfg branch June 30, 2023 07:03
PGZXB pushed a commit to PGZXB/taichi that referenced this pull request Jul 13, 2023
…hi-dev#8245)

Issue: #

`arg_id` doesn't make sense when two statements come from different
callables. Therefore we cannot decide whether a `ExternalPtrStmt` in the
real function points to the same ndarray as another `ExternalPtrStmt` in
the kernel by checking the `arg_id` of them.

Instead, we can assume that all ndarrays passed into a real function can
be modified. When a ndarray is passed into a real function, a
`ExternalTensorBasePtrStmt` is inserted into the argument of the real
function, which will appear in the store destinations of the
`FuncCallStmt`. Then, we can add support for it in the alias analysis.
We also don't include the `ExternalPtrStmt`s in the real functions in
the store destination sets as they don't make any sense.

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at ba828dc</samp>

Add support for real functions writing to external arrays or tensors.
Update alias analysis and store destination collection to handle
external pointers. Add a test case for the new feature.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at ba828dc</samp>

* Add a special case for alias analysis of external tensor base pointers
([link](https://github.com/taichi-dev/taichi/pull/8245/files?diff=unified&w=0#diff-de599d158682f1f0209f39aa58631d6df8d8ded1eacb00d7d6c5200ef7391793R17-R38))
* Skip external pointers and matrix pointers from external pointers when
gathering store destinations of a function
([link](https://github.com/taichi-dev/taichi/pull/8245/files?diff=unified&w=0#diff-0bfbe49ff08844a76d5d2e1c5b81c2cf813be4a9089422b997bc380ec9a68eadL65-R75))
* Add a test case for real functions writing to external arrays or
tensors in `test_ndarray.py`
([link](https://github.com/taichi-dev/taichi/pull/8245/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0R1132-R1150))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants