intel / intel/confidential-computing.sgx.sdk
Vtune profiling support in SGX enclave
- Dominant language
- C++
- Stars
- 2
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Hi, as I know, "SGX Hotspots" is supproted in vtune since 2016.
I noticed that there is a piece of code of function ` __create_enclave` in psw (urts/urts_com.h), so what is the propose of this code below? Is it helpful for vtune profiling in sgx enclave? How can I enable the `isVTuneProfiling` flag?
` if(debug || !(get_enclave_creator()->use_se_hw()))
{
SE_TRACE(SE_TRACE_DEBUG, "Debug enclave. Checking if VTune is profiling or SGX_DBG_OPTIN is set\n");
__itt_init_ittlib(NULL, __itt_group_none);
bool isVTuneProfiling;
if(__itt_get_ittapi_global()->api_initialized && __itt_get_ittapi_global()->lib)
isVTuneProfiling = true;
else
isVTuneProfiling = false;
bool is_SGX_DBG_OPTIN_set = false;
is_SGX_DBG_OPTIN_set = is_SGX_DBG_OPTIN_variable_set();
if (isVTuneProfiling || is_SGX_DBG_OPTIN_set)
{
SE_TRACE(SE_TRACE_DEBUG, "VTune is profiling or SGX_DBG_OPTIN is set\n");
bool thread_updated;
thread_updated = enclave->update_debug_flag(1);
if(thread_updated == false)
{
SE_TRACE(SE_TRACE_DEBUG, "Failed to update debug OPTIN bit\n");
}
else
{
SE_TRACE(SE_TRACE_DEBUG, "Updated debug OPTIN bit\n");
}
if (isVTuneProfiling)
{
uint64_t enclave_start_addr;
uint64_t enclave_end_addr;
const char* enclave_path;
enclave_start_addr = (uint64_t) loader.get_start_addr();
enclave_end_addr = enclave_start_addr + (uint64_t) metadata->enclave_size -1;
SE_TRACE(SE_TRACE_DEBUG, "Invoking VTune's module mapping API __itt_module_load \n");
SE_TRACE(SE_TRACE_DEBUG, "Enclave_start_addr==0x%llx\n", enclave_start_addr);
SE_TRACE(SE_TRACE_DEBUG, "Enclave_end_addr==0x%llx\n", enclave_end_addr);
enclave_path = (const char*)file.name;
SE_TRACE(SE_TRACE_DEBUG, "Enclave_path==%s\n", enclave_path);
__itt_module_load((void*)enclave_start_addr, (void*) enclave_end_addr, enclave_path);
}
}`
Contributor guide
Research direction
Start in psw/urts/urts_com.h at __create_enclave and trace the __itt_init_ittlib, isVTuneProfiling, and __itt_module_load calls. Check how SGX_DBG_OPTIN is detected and how the loader obtains enclave addresses and paths. Done means documenting whether this code enables VTune profiling and the supported way to activate it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100