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

Better error messages for unsupported statements in kernels #808

Merged
merged 3 commits into from
Oct 23, 2023

Conversation

bmhowe23
Copy link
Collaborator

@bmhowe23 bmhowe23 commented Oct 20, 2023

Summary

This PR has 2 related changes. In both cases, it changes the compiler behavior in unsupported conditions from a crash into a more typical compiler error message that points to the user's offending line of code.

Details

  1. It changes the error message when a user tries to put printf (or other variadic functions) in their kernel
    From:
not yet implemented: argument type conversion
...
PLEASE submit a bug report to https://github.com/NVIDIA/cuda-quantum and include the crash backtrace.

To:

statements.cpp:57:5: error: cannot call variadic function from quantum kernel
    printf("Hello\n");
    ^
statements.cpp:57:5: error: statement not supported in qpu kernel
  1. It changes the error message when a user tries to put cout (or other function with unsupported types) in their kernel
    From:
cudaq-quake: /workspaces/cuda-quantum/lib/Frontend/nvqpp/ConvertType.cpp:107: bool cudaq::details::QuakeBridgeVisitor::TraverseRecordType(clang::RecordType*): Assertion `typeStack.size() == typeStackDepth' failed.
PLEASE submit a bug report to https://github.com/NVIDIA/cuda-quantum and include the crash backtrace.

To:

loc("/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/char_traits.h":338:3):warning: compiler encountered type traversal issue
statements.cpp:53:5: error: statement not supported in qpu kernel
    std::cout << "Hello\n";
    ^

@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Oct 20, 2023
@bmhowe23 bmhowe23 enabled auto-merge (squash) October 20, 2023 22:47
@bmhowe23 bmhowe23 changed the title Better error message for unsupported func in qpu kernel Better error messages for unsupported statements in kernels Oct 23, 2023
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Oct 23, 2023
Copy link
Collaborator

@schweitzpgi schweitzpgi left a comment

Choose a reason for hiding this comment

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

LGTM

@bmhowe23 bmhowe23 merged commit d19d6c1 into NVIDIA:main Oct 23, 2023
109 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2023
@bmhowe23 bmhowe23 deleted the pr-better-err-msg-variadic branch October 24, 2023 17:20
@bettinaheim bettinaheim added this to the release 0.5.0 milestone Nov 15, 2023
@bettinaheim bettinaheim added release notes Changes need to be captured in the release notes bug fix To be listed under Bug Fixes in the release notes and removed release notes Changes need to be captured in the release notes labels Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fix To be listed under Bug Fixes in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants