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

Where is IttnotifyInfo defined/declared? #85

Open
iamkroot opened this issue Mar 3, 2023 · 3 comments
Open

Where is IttnotifyInfo defined/declared? #85

iamkroot opened this issue Mar 3, 2023 · 3 comments

Comments

@iamkroot
Copy link

iamkroot commented Mar 3, 2023

LLVM includes the IntelJITEventsWrapper that was updated in Profiling the code generated by MCJIT engine using Intel VTune profiler.

The commit message mentions-

To overcome limitations described above, we have introduced new APIs as a part of Intel ITT APIs to report the entire in-memory ELF module to be further processed as regular ELF binaries with debug information.

And from the diff, it seems to revolve around calling the iJitIttNotifyInfo func with the memory region that contains the generated ELF.

...Except, IttnotifyInfoFunc is initialized to 0. And there is no mention of a similarly-named method inside jitprofiling.h as there is for iJIT_NotifyEvent (the older API).

As a result, the default IntelJITEventListener in LLVM is totally non-functional. It simply ignores the events when IttnotifyInfoFunc is 0.

So the question is- where is IttnotifyInfoFunc declared, and how can we use it from inside the LLVM listener?

@ekovanova
Copy link
Contributor

@iamkroot, we use iJitIttNotifyInfo functionality only for testing purposes in the llvm-jitlistener tool.

To create an Intel JIT event listener for the llvm-jitlistener we provide it with the IttnotifyInfo function
in llvm/tools/llvm-jitlistener/llvm-jitlistener.cpp

image

Could you please describe how you would you like to use these listeners?
Theoretically, we could link the functionality of this LLVM listener with __itt_module_load_with_sections and __itt_module_unload_with_sections ITT APIs

@iamkroot
Copy link
Author

Could you please describe how you would you like to use these listeners?

I have a JIT-ted program running through LLVM's MCJIT ExecutionEngine. I want to profile this using VTune (great software!), but my code is heavily inlined.

From reading the LLVM PR, I assumed that this was something that we could handle out-of-the-box using IntelJITEventListener. But as you mentioned, the iJitIttNotifyInfo is only used for debugging/dumping the ELF and is not calling anything on the VTune/ittnotify side in the default listener.

Theoretically, we could link the functionality of this LLVM listener with __itt_module_load_with_sections and __itt_module_unload_with_sections ITT APIs

Would that handle inlined functions? I also see iJVM_EVENT_TYPE_METHOD_INLINE_LOAD_FINISHED inside jitprofiling.c, and was planning to use that instead.

@ekovanova
Copy link
Contributor

I have a JIT-ted program running through LLVM's MCJIT ExecutionEngine. I want to profile this using VTune (great software!), but my code is heavily inlined.

Well, since your JIT-ted program running through LLVM's MCJIT ExecutionEngine you just need to make sure that it was compiled with DLLVM_USE_INTEL_JITEVENTS=ON option. LLVM's MCJIT already has VTune profiling support and you do not need to make changes in LLVM project.

From reading the LLVM PR, I assumed that this was something that we could handle out-of-the-box using IntelJITEventListener. But as you mentioned, the iJitIttNotifyInfo is only used for debugging/dumping the ELF and is not calling anything on the VTune/ittnotify side in the default listener.

MCJIT already instrumented with ITT API __itt_module_load_with_sections which dumps ELF file and provides VTune with all the necessary information during profiling.
In this case inlines are not a problem :)
And you do not need the iJitIttNotifyInfo functionality, we have it only for testing purposes in the llvm-jitlistener tool.

Also I would like to note, that in case of VTune attach to a launched application, we recommend to manually set INTEL_LIBITTNOTIFY64 (and INTEL_LIBITTNOTIFY32 for 32 bit) environment variable before launching the application.

@iamkroot sorry for the delayed reply, I was on a vacation.

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

No branches or pull requests

2 participants