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

Added basic setup for getting raw LLVM remarks output #9601

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

kc611
Copy link
Contributor

@kc611 kc611 commented Jun 3, 2024

As titled,
This PR intends to get the raw LLVM remarks output from the JIT code.

Action items:

The following tasks are planned to be accomplished in this PR:

  • Demangle function names correctly.
  • Display correct path to the file in debug information.
  • Display correct column name in debug information.
  • Differentiate remarks on the basis of the dispatcher object that evokes them.
  • Add tests

@kc611
Copy link
Contributor Author

kc611 commented Jun 10, 2024

Now added RemarksInterface object, usage as below:

from  numba import njit
import numpy as np
import math
from numba import config
from numba.experimental.remarks import RemarksInterface


@njit()
def foo(n):
    ret = np.empty(n, dtype=np.float64)
    arr = np.arange(n)
    for x in range(n):
        ret[x] = math.sin(arr[x])
    return ret

with RemarksInterface() as remarks:
    foo(10000)

print(remarks.file_path)

# All nodes without a caller
print(remarks.head_nodes)

# Head node [1] is foo from the above example
for x in remarks.head_nodes[1].remarks:
    args = x.pop("Args") # Remove the Args key, args still needs to be processed properly
    print(x)

    remark_info = ""
    for arg in args:
        for value in arg.values():
            remark_info  = str(value)   " "

    print("Remark String:", remark_info)
    print("\n")
    break # To prevent long outputs

Outputs:

numba_opt_remarks/03504790-1718015780.1033485.yaml
[NRT_incref, cpython::__main__::foo(long long)]
{'Pass': 'inline', 'Name': 'NoDefinition', 'Function': 'cpython::__main__::foo(long long)', 'Status': 'Missed', 'Caller': 'cpython::__main__::foo(long long)', 'Callee': 'PyArg_UnpackTuple'}
Remark String: PyArg_UnpackTuple  will not be inlined into  cpython::__main__::foo(long long)  because its definition is unavailable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants