- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a follow up question of "intel vtune to profile sgx application".
My real program is complicated and I have to use attaching to a process to profile. There is no way that I can run my program directly from VTune.
I find that starting the application from VTune directly would give a different result than attaching VTune to a process.
I modify the SampleEnclave example a little bit.
I add the following code to Enclave.cpp.
void func1() {
printf("in func1\n");
for (int i = 0; i < 1000000000; i++) {}
}
void func2() {
printf("in func2\n");
for (int i = 0; i < 1000000000; i++) {}
}
void enc_loop() {
printf("in the loop\n");
func1();
func2();
}
I add the following code to App.cpp. I get the pid and attach the VTune to the program, then I enter a character to let the enclave program continue to run.
printf("Enter a character to start, %d\n", (int)syscall(SYS_gettid));
getchar();
enc_loop(global_eid);
If I directly run the application from VTune, I would get the following result
Top Hotspots
Function Module Precise Clockticks
------------------- ----------------- ------------------
func1 enclave.signed.so 13,236,680,000
func2 enclave.signed.so 13,210,000,000
mutex_spin_on_owner vmlinux 150,400,000
do_ocall enclave.signed.so 115,160,000
sgx_spin_lock enclave.signed.so 104,420,000
[Others] N/A 337,860,000
If I attaching VTune to the process, I would get the following result. The func1 and func2 are not shown in the profile result.
Top Hotspots
Function Module Precise Clockticks
-------------------------- ------------------------ ------------------
__morestack libsgx_urts.so.1.1.103.3 14,380,000
[Outside any known module] [Unknown] 4,820,000
unmap_page_range vmlinux 540,000
find_get_entries vmlinux 500,000
free_pcppages_bulk vmlinux 300,000
[Others] N/A 4,920,000
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This is actually a VTune error. I will move this thread to the correct team.
Sincerely,
Sahira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel communities.
Could you please share the following details -
- OS and hardware details.
- VTune version.
- The exact steps and commands you used.
Regards,
Diya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hardware: Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz
OS: Ubuntu 18.04.2 LTS (Bionic Beaver)
Vtune: Intel(R) oneAPI VTune(TM) Profiler 2021.9.0 (build 621210) Command Line Tool
command 1: sudo /opt/intel/oneapi/vtune/latest/bin64/vtune -collect sgx-hotspots -knob sampling-interval=.01 ./app
command 2: sudo ./vtune -collect sgx-hotspots -knob sampling-interval=0.01 -target-pid 8692
I use the SampleEnclave example provided by Intel and make some modifications. I also attach the file after modifications.
The 'Enclave.edl.cpp' should be 'Enclave.edl'. For some reason, I can't upload '.edl' file, so I just rename it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
Thank you for sharing the details.
We are getting error while creating the executable file from our end because we don't have the header files mentioned in the code.
Please find the below screenshot.
Could you please share your .exe file so that we can check from our end.
Regards,
Diya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I upload the whole project code. Please rename it to 'SampleEnclave.tar.gz'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for sharing your details. We are able to reproduce your issue. We are working on this internally.
Regards,
Diya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
VTune dev here. Seeing how you have [Outside any known module] in your attach case, it may be that VTune could collect the samples from the enclave, but had trouble identifying the actual module these belong to.
It may not be apparent from the documentation, but in order for this to work the two conditions must be fulfilled:
- SGX SDK has to proactively report the enclave data to VTune, and it does so only when sgx_create_enclave* method is invoked with SGX_DEBUG_FLAG argument and is built with SGX_DEBUG or SGX_PRERELEASE makeflags, for security reasons.
- As a consequence of the above, VTune has to receive reports about the enclaves during the collection phase. It sets up the needed environment for the target application automatically when you choose to profile in launch mode, but to enable the reporting in attach mode you will have to prepare the environment for your application manually before launching it. Please refer to this article in the user manual on how to do this (ITT API is used for enclave reporting): https://www.intel.com/content/www/us/en/develop/documentation/vtune-help/top/api-support/instrumentation-and-tracing-technology-apis/basic-usage-and-configuration/attaching-itt-apis-to-a-launched-application.html
Please double check if the above is in place in your profiling environment.
BR,
Andrey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Good day to you .
We have not heard back from you . Is your issue resolved with the above solution?
If this resolves your issue, make sure to accept this as a solution. This would help others with similar issue. Thank you!
Regards,
Diya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Good day to you.
We assume that your issue is resolved.
If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.
Thanks and Regards,
Diya Nandy

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page