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

Add the mangled_args property to kernel_api types. #1443

Merged
merged 3 commits into from
Apr 30, 2024

Conversation

diptorupd
Copy link
Contributor

@diptorupd diptorupd commented Apr 24, 2024

  • Have you provided a meaningful PR description?
    Numba-dpex's custom types such as ItemType and NdItemType are currently not properly demangled and makes the demangled function signature hard to read. The PR fixes the issue by adding the mangled_args property to these types.

In addition, the SpirvKernelTarget was updated to use the numba_dpex.core.utils.itanium_mangler.

Before (look at the first argument "Item"):

Thread 2.129 hit Breakpoint 1, with SIMD lanes [0-1], __main__::data_parallel_sum_242(
    Item_3c1_3e, 
    DpnpNdArray<float, 1, C, level_zero_gpu>,
    DpnpNdArray<float, 1, C, level_zero_gpu>,
    DpnpNdArray<float, 1, C, level_zero_gpu>
) (item=..., a=..., b=..., c=...) at simple_sum.py:13

After:

Thread 2.129 hit Breakpoint 1, with SIMD lanes [0-1], __main__::data_parallel_sum_242(
    ItemType<1>,
    DpnpNdArray<float, 1, C, level_zero_gpu>,
    DpnpNdArray<float, 1, C, level_zero_gpu>,
    DpnpNdArray<float, 1, C, level_zero_gpu>
) (item=..., a=..., b=..., c=...) at simple_sum.py:13
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • If this PR is a work in progress, are you filing the PR as a draft?

Fixes #1242

@diptorupd diptorupd requested a review from ZzEeKkAa April 24, 2024 20:34
@diptorupd diptorupd force-pushed the improve/function_arg_mangling branch from 1379e63 to 7490c0c Compare April 24, 2024 20:36
@coveralls
Copy link
Collaborator

coveralls commented Apr 24, 2024

Coverage Status

coverage: 86.419% (+0.2%) from 86.252%
when pulling 71cc99f on improve/function_arg_mangling
into 675cb79 on main.

@diptorupd diptorupd changed the title Add the mangled_Args property to kernel_api types. Add the mangled_args property to kernel_api types. Apr 24, 2024
@diptorupd diptorupd marked this pull request as draft April 26, 2024 21:19
@diptorupd
Copy link
Contributor Author

@mpuputti The PR has my latest GDB-related changes I have done based on our triaging of the GDB support on numba-dpex kernels.

The changes do fix setting breakpoints on function names. I will investigate further if there are any unintended side effects.

@diptorupd diptorupd force-pushed the improve/function_arg_mangling branch 2 times, most recently from 0f64099 to 19d42ba Compare April 29, 2024 16:23
@diptorupd diptorupd marked this pull request as ready for review April 29, 2024 16:23
@@ -119,6 +120,39 @@ class SPIRVDevice(GPU):
target_registry[SPIRV_TARGET_NAME] = SPIRVDevice


class _DIBuilder(debuginfo.DIBuilder):
Copy link
Contributor

Choose a reason for hiding this comment

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

May be something specific to numba dpex is a better choice for naming?

Suggested change
class _DIBuilder(debuginfo.DIBuilder):
class SPIRVDIBuilder(debuginfo.DIBuilder):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the class into numba_dpex.core.debuginfo and renamed it to DIBuilder.

@@ -190,7 +190,7 @@ def foo(item, a, b):
kernel_ir = kcres.library.get_llvm_str()

for tag in ir_tags:
assert make_check(kernel_ir, tag)
assert not make_check(kernel_ir, tag)
Copy link
Contributor

Choose a reason for hiding this comment

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

Was it add to bypass test or there was a bug here? Change looks suspicious)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After these changes the linkagename tag is no longer used. So changed the test to a negative test case to make sure linkagename is not set. I have added comments make the change clearer.

Copy link
Contributor

@ZzEeKkAa ZzEeKkAa left a comment

Choose a reason for hiding this comment

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

Awesome changes! Thank you!

Finally breakpoints by name are working! Just few nits, otherwise good to go!

@diptorupd diptorupd force-pushed the improve/function_arg_mangling branch from 19d42ba to 71cc99f Compare April 30, 2024 16:21
@diptorupd diptorupd requested a review from ZzEeKkAa April 30, 2024 16:22
@ZzEeKkAa ZzEeKkAa merged commit 72a3167 into main Apr 30, 2024
65 of 72 checks passed
@ZzEeKkAa ZzEeKkAa deleted the improve/function_arg_mangling branch April 30, 2024 17:44
github-actions bot added a commit that referenced this pull request Apr 30, 2024
Add the mangled_args property to kernel_api types. 72a3167
github-actions bot pushed a commit that referenced this pull request Apr 30, 2024
Add the mangled_args property to kernel_api types. 72a3167
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.

Breakpoint with function name not working for numba-dpex.
3 participants