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

Generate proper mangled name for kernel functions #1112

Merged
merged 2 commits into from
Aug 18, 2023
Merged

Conversation

diptorupd
Copy link
Contributor

@diptorupd diptorupd commented Aug 18, 2023

  • Have you provided a meaningful PR description?

Fixes how function names are generated at the LLVM IR level for numba_dpex.kernel decorated functions and auto-generated kernels for parfor nodes.

Previously an unreadable gobbledegook was generated

dpex_py_devfn__5F__5F_main_5F__5F__2E_kernel_5F_vector_5F_sum_24_1_2E_USMNdArray_28_dtype_3D_float64_2C__20_ndim_3D_1_2C__20_layout_3D_C_2C__20_address_5F_space_3D_1_2C__20_usm_5F_type_3D_device_2C__20_device_3D_level_5F_zero_3A_gpu_3A_0_2C__20_sycl_5F_queue_3D_DpctlSyclQueue_29__2E_USMNdArray_28_dtype_3D_float64_2C__20_ndim_3D_1_2C__20_layout_3D_C_2C__20_address_5F_space_3D_1_2C__20_usm_5F_type_3D_device_2C__20_device_3D_level_5F_zero_3A_gpu_3A_0_2C__20_sycl_5F_queue_3D_DpctlSyclQueue_29__2E_USMNdArray_28_dtype_3D_float64_2C__20_ndim_3D_1_2C__20_layout_3D_C_2C__20_address_5F_space_3D_1_2C__20_usm_5F_type_3D_device_2C__20_device_3D_level_5F_zero_3A_gpu_3A_0_2C__20_sycl_5F_queue_3D_DpctlSyclQueue_29_

After the fix:

_ZN8__main__28kernel_vector_sum_241dpex_fnB2v1B40c8tJTC_2fWQI8IW1CiAAYKPM6RBFDjESyhCQA_3dE10USMNdArrayIdLi1E1C14level_zero_gpuE10USMNdArrayIdLi1E1C14level_zero_gpuE10USMNdArrayIdLi1E1C14level_zero_gpuE

The new function names can also be demangled (e.g., using c++filt) into human readable format:

main::kernel_vector_sum_241dpex_fn[abi:v1][abi:c8tJTC_2fWQI8IW1CiAAYKPM6RBFDjESyhCQA_3d](USMNdArray<double, 1, C, level_zero_gpu>, USMNdArray<double, 1, C, level_zero_gpu>, USMNdArray<double, 1, C, level_zero_gpu>)

For parfor auto generated kernels:

_ZN08NumbaEnv13_3cdynamic_3e33__dpex_parfor_kernel_0_245dpex_fnB2v5B40c8tJTC_2fWQI8IW1CiAAYKPM6RBFDjESyhCQA_3dE10USMNdArrayIfLi1E1C10opencl_gpuE10USMNdArrayIfLi1E1C10opencl_gpuE10USMNdArrayIfLi1E1C10opencl_gpuE

that demangles into:

NumbaEnv::_3cdynamic_3e::__dpex_parfor_kernel_0_245dpex_fn[abi:v5][abi:c8tJTC_2fWQI8IW1CiAAYKPM6RBFDjESyhCQA_3d](USMNdArray<float, 1, C, opencl_gpu>, USMNdArray<float, 1, C, opencl_gpu>, USMNdArray<float, 1, C, opencl_gpu>)

Additionally, the LLVM module is now lightly optimized prior to spirv generation to ensure that the spir_func gets fully inlined into the spir_kernel wrapper function.

  • 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 #260

@diptorupd diptorupd requested a review from adarshyoga August 18, 2023 02:18
@diptorupd diptorupd merged commit 547382d into main Aug 18, 2023
@diptorupd diptorupd deleted the fix/kernel_func_name branch August 18, 2023 03:22
github-actions bot added a commit that referenced this pull request Aug 18, 2023
Generate proper mangled name for kernel functions 547382d
github-actions bot added a commit to chudur-budur/numba-dpex that referenced this pull request Aug 18, 2023
…name

Generate proper mangled name for kernel functions 547382d
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.

Provide easily distinguishable kernel names
1 participant