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

Testable Device-Side Assertion Failures on CPUs #605

Merged
merged 14 commits into from
Mar 18, 2020

Conversation

xumingkuan
Copy link
Collaborator

Related issue id = #591

A continuation of #582

@xumingkuan
Copy link
Collaborator Author

Test case:

ti.init(debug=True)

@ti.kernel
def boom():
  assert 0

boom()

Output:

error code: 0000000000000000
<some debug printf's in `taichi_assert_runtime`>

Are we checking the error code too early?

@yuanming-hu
Copy link
Member

yuanming-hu commented Mar 16, 2020

(Note that when two threads use printf simultaneously, there's no guarantee their outputs will be sorted according to wall clock time.)

@xumingkuan
Copy link
Collaborator Author

xumingkuan commented Mar 16, 2020

I got this in another run:

error code in taichi_assert_runtime: 1
error code: 0000000000000000

Go to sleep now. Maybe debug it tomorrow.

@yuanming-hu
Copy link
Member

I'm actually slightly confused: why error code: 0000000000000000 instead of error code: 0?

@xumingkuan
Copy link
Collaborator Author

std::cout << "i64 " << (typeid(error_code) == typeid(unsigned long long)) << std::endl;
std::cout << "u64 " << (typeid(error_code) == typeid(long long)) << std::endl;
std::cout << "ptr " << (typeid(error_code) == typeid(void *)) << std::endl;
std::cout << "error code: " << error_code << std::endl;

Output:

i64 0
u64 0
ptr 1
error code: 0000000000000000

@yuanming-hu
Copy link
Member

Oh I see. You are printing a pointer.

@xumingkuan
Copy link
Collaborator Author

auto error_code = runtime_jit_module->fetch_result<long long>();
By making this change, the output becomes:

error code in taichi_assert_runtime: 1
i64 1
u64 0
ptr 0
error code: 0

@yuanming-hu
Copy link
Member

How is this going? Do you need any help? I'm available via Skype if you would like to chat.

@xumingkuan
Copy link
Collaborator Author

Let's Skype chat then.

@yuanming-hu
Copy link
Member

Please move ErrorMessage to LLVMRuntime.

@xumingkuan xumingkuan marked this pull request as ready for review March 17, 2020 06:21
Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Could you please add some unit tests for bound checks and basic assert statements in tests/python/test_assert.py?

@xumingkuan
Copy link
Collaborator Author

The exception raised is RuntimeError but not AssertionError. Maybe AssertionError is only for python assertions?

@yuanming-hu
Copy link
Member

The exception raised is RuntimeError but not AssertionError. Maybe AssertionError is only for python assertions?

Yeah, let's just use RuntimeError for it now.

@yuanming-hu
Copy link
Member

Need any help on this PR?

@xumingkuan
Copy link
Collaborator Author

Why did CI fail?

@yuanming-hu
Copy link
Member

Let me see.

@xumingkuan
Copy link
Collaborator Author

(Unlike AppVeyor, I can't find console log on Travis CI...)

@yuanming-hu
Copy link
Member

(Unlike AppVeyor, I can't find console log on Travis CI...)

That's true. But good problem solvers don't find excuses. They look for ways to solve the problems or ask for help from someone more experienced :-)

@xumingkuan
Copy link
Collaborator Author

Go to cook dinner now. I think this is an issue across platforms but I only have access to my Windows laptop. See you later.

@yuanming-hu
Copy link
Member

Yeah, it is indeed a cross-platform issue but please let me know next time when you run into something that you can't resolve on your own.

@yuanming-hu
Copy link
Member

Should be fixed now. Please rebase your commits on master.

@archibate
Copy link
Collaborator

The exception raised is RuntimeError but not AssertionError. Maybe AssertionError is only for python assertions?

std::exception is translated into RuntimeError. See pybind11 doc:exception for more info.

Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yuanming-hu yuanming-hu merged commit 97e1b50 into taichi-dev:master Mar 18, 2020
@xumingkuan xumingkuan deleted the assert branch March 18, 2020 22:11
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.

3 participants