Skip to content

Commit 47a22c5

Browse files
authored
Arm backend: Added more profiling events to VGF (pytorch#22076)
Change-Id: I4f98a0bb917c7fb362d4c7333fd8614fb4391645 cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani Signed-off-by: Elena Zhelezina <elena.zhelezina@arm.com>
1 parent 86e9036 commit 47a22c5

1 file changed

Lines changed: 90 additions & 37 deletions

File tree

‎backends/arm/runtime/VGFSetup.cpp‎

Lines changed: 90 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,7 @@ bool VgfRepr::process_vgf(
17511751
}
17521752

17531753
for (int i = 0; i < IO_count; i++) {
1754+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_ALLOCATE_RESOURCE");
17541755
auto resource_type = resolve_descriptor_type(resource_decoder, i);
17551756
auto resource_format = vgflib::ToVkFormat(resource_decoder->getVkFormat(i));
17561757
auto alias_group = get_resource_alias_group_id(resource_decoder, i);
@@ -2624,6 +2625,7 @@ bool VgfRepr::process_vgf(
26242625
segments.clear();
26252626
segments.reserve(segment_count);
26262627
for (int segment_id = 0; segment_id < segment_count; ++segment_id) {
2628+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_BUILD_SEGMENT");
26272629
const auto segment_type = sequence_decoder->getSegmentType(segment_id);
26282630
if (segment_type != vgflib::ModuleType::GRAPH &&
26292631
segment_type != vgflib::ModuleType::COMPUTE) {
@@ -2679,8 +2681,11 @@ bool VgfRepr::process_vgf(
26792681
.codeSize = segment_m_spirv.size() * sizeof(uint32_t),
26802682
.pCode = segment_m_spirv.begin(),
26812683
};
2682-
result =
2683-
vkCreateShaderModule(vk_device, &smci, nullptr, &segment.vk_shader);
2684+
{
2685+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_CREATE_SHADER_MODULE");
2686+
result =
2687+
vkCreateShaderModule(vk_device, &smci, nullptr, &segment.vk_shader);
2688+
}
26842689
if (result != VK_SUCCESS) {
26852690
ET_LOG(Error, "Failed to load shader from segment %d", segment_module);
26862691
return false;
@@ -2802,8 +2807,11 @@ bool VgfRepr::process_vgf(
28022807
.bindingCount = static_cast<uint32_t>(layout_bindings.size()),
28032808
.pBindings = layout_bindings.data(),
28042809
};
2805-
result = vkCreateDescriptorSetLayout(
2806-
vk_device, &layout_info, nullptr, &segment.vk_layout);
2810+
{
2811+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_CREATE_DESCRIPTOR_SET_LAYOUT");
2812+
result = vkCreateDescriptorSetLayout(
2813+
vk_device, &layout_info, nullptr, &segment.vk_layout);
2814+
}
28072815
if (result != VK_SUCCESS) {
28082816
ET_LOG(Error, "Failed to create descriptor layout");
28092817
return false;
@@ -2833,8 +2841,14 @@ bool VgfRepr::process_vgf(
28332841
.poolSizeCount = static_cast<uint32_t>(poolSizes.size()),
28342842
.pPoolSizes = poolSizes.data(),
28352843
};
2836-
result = vkCreateDescriptorPool(
2837-
vk_device, &descriptor_pool_info, nullptr, &segment.vk_descriptor_pool);
2844+
{
2845+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_CREATE_DESCRIPTOR_POOL");
2846+
result = vkCreateDescriptorPool(
2847+
vk_device,
2848+
&descriptor_pool_info,
2849+
nullptr,
2850+
&segment.vk_descriptor_pool);
2851+
}
28382852
if (result != VK_SUCCESS) {
28392853
ET_LOG(Error, "Failed to create descriptor pool");
28402854
return false;
@@ -2849,8 +2863,11 @@ bool VgfRepr::process_vgf(
28492863
};
28502864

28512865
segment.descriptor_sets.resize(set_count);
2852-
result = vkAllocateDescriptorSets(
2853-
vk_device, &descriptor_set_info, segment.descriptor_sets.data());
2866+
{
2867+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_ALLOCATE_DESCRIPTOR_SETS");
2868+
result = vkAllocateDescriptorSets(
2869+
vk_device, &descriptor_set_info, segment.descriptor_sets.data());
2870+
}
28542871
if (result != VK_SUCCESS) {
28552872
ET_LOG(Error, "Failed to allocate descriptor sets");
28562873
return false;
@@ -2907,7 +2924,10 @@ bool VgfRepr::process_vgf(
29072924
.pBufferInfo = nullptr,
29082925
.pTexelBufferView = nullptr,
29092926
};
2910-
vkUpdateDescriptorSets(vk_device, 1, &desc_set, 0, nullptr);
2927+
{
2928+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_UPDATE_DESCRIPTOR_SET");
2929+
vkUpdateDescriptorSets(vk_device, 1, &desc_set, 0, nullptr);
2930+
}
29112931
} else if (
29122932
binding_info.descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) {
29132933
ET_LOG(
@@ -2934,7 +2954,10 @@ bool VgfRepr::process_vgf(
29342954
.pBufferInfo = &buffer_info,
29352955
.pTexelBufferView = nullptr,
29362956
};
2937-
vkUpdateDescriptorSets(vk_device, 1, &desc_set, 0, nullptr);
2957+
{
2958+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_UPDATE_DESCRIPTOR_SET");
2959+
vkUpdateDescriptorSets(vk_device, 1, &desc_set, 0, nullptr);
2960+
}
29382961
} else if (
29392962
binding_info.descriptor_type ==
29402963
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER ||
@@ -2974,7 +2997,10 @@ bool VgfRepr::process_vgf(
29742997
.pBufferInfo = nullptr,
29752998
.pTexelBufferView = nullptr,
29762999
};
2977-
vkUpdateDescriptorSets(vk_device, 1, &desc_set, 0, nullptr);
3000+
{
3001+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_UPDATE_DESCRIPTOR_SET");
3002+
vkUpdateDescriptorSets(vk_device, 1, &desc_set, 0, nullptr);
3003+
}
29783004
} else {
29793005
ET_LOG(
29803006
Error,
@@ -2994,8 +3020,14 @@ bool VgfRepr::process_vgf(
29943020
.pushConstantRangeCount = 0,
29953021
.pPushConstantRanges = nullptr,
29963022
};
2997-
result = vkCreatePipelineLayout(
2998-
vk_device, &pipeline_layout_info, nullptr, &segment.vk_pipeline_layout);
3023+
{
3024+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_CREATE_PIPELINE_LAYOUT");
3025+
result = vkCreatePipelineLayout(
3026+
vk_device,
3027+
&pipeline_layout_info,
3028+
nullptr,
3029+
&segment.vk_pipeline_layout);
3030+
}
29993031
if (result != VK_SUCCESS) {
30003032
ET_LOG(Error, "Failed to create pipeline layout");
30013033
return false;
@@ -3023,14 +3055,17 @@ bool VgfRepr::process_vgf(
30233055
.pResourceInfos = data_graph_resources.data(),
30243056
};
30253057

3026-
result = vkCreateDataGraphPipelinesARM(
3027-
vk_device,
3028-
VK_NULL_HANDLE,
3029-
VK_NULL_HANDLE,
3030-
1,
3031-
&graph_pipeline_info,
3032-
nullptr,
3033-
&segment.vk_pipeline);
3058+
{
3059+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_CREATE_DATA_GRAPH_PIPELINE");
3060+
result = vkCreateDataGraphPipelinesARM(
3061+
vk_device,
3062+
VK_NULL_HANDLE,
3063+
VK_NULL_HANDLE,
3064+
1,
3065+
&graph_pipeline_info,
3066+
nullptr,
3067+
&segment.vk_pipeline);
3068+
}
30343069
if (result != VK_SUCCESS) {
30353070
ET_LOG(
30363071
Error,
@@ -3046,8 +3081,11 @@ bool VgfRepr::process_vgf(
30463081
.flags = 0,
30473082
.dataGraphPipeline = segment.vk_pipeline,
30483083
};
3049-
result = vkCreateDataGraphPipelineSessionARM(
3050-
vk_device, &pipeline_session_info, nullptr, &segment.vk_session);
3084+
{
3085+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_CREATE_DATA_GRAPH_SESSION");
3086+
result = vkCreateDataGraphPipelineSessionARM(
3087+
vk_device, &pipeline_session_info, nullptr, &segment.vk_session);
3088+
}
30513089
if (result != VK_SUCCESS) {
30523090
ET_LOG(Error, "Failed to create DataGraphPipelineSession");
30533091
return false;
@@ -3062,8 +3100,15 @@ bool VgfRepr::process_vgf(
30623100
};
30633101

30643102
uint32_t bind_point_count = 0;
3065-
result = vkGetDataGraphPipelineSessionBindPointRequirementsARM(
3066-
vk_device, &bind_point_requirements_info, &bind_point_count, nullptr);
3103+
{
3104+
VGF_PROFILE_SCOPE(
3105+
event_tracer, "VGF_INIT_QUERY_DATA_GRAPH_BIND_POINT_COUNT");
3106+
result = vkGetDataGraphPipelineSessionBindPointRequirementsARM(
3107+
vk_device,
3108+
&bind_point_requirements_info,
3109+
&bind_point_count,
3110+
nullptr);
3111+
}
30673112
if (result != VK_SUCCESS) {
30683113
ET_LOG(Error, "Failed to get session bind point count");
30693114
return false;
@@ -3072,17 +3117,22 @@ bool VgfRepr::process_vgf(
30723117
vector<VkDataGraphPipelineSessionBindPointRequirementARM>
30733118
bind_point_requirements;
30743119
bind_point_requirements.resize(bind_point_count);
3075-
result = vkGetDataGraphPipelineSessionBindPointRequirementsARM(
3076-
vk_device,
3077-
&bind_point_requirements_info,
3078-
&bind_point_count,
3079-
bind_point_requirements.data());
3120+
{
3121+
VGF_PROFILE_SCOPE(
3122+
event_tracer, "VGF_INIT_QUERY_DATA_GRAPH_BIND_POINTS");
3123+
result = vkGetDataGraphPipelineSessionBindPointRequirementsARM(
3124+
vk_device,
3125+
&bind_point_requirements_info,
3126+
&bind_point_count,
3127+
bind_point_requirements.data());
3128+
}
30803129
if (result != VK_SUCCESS) {
30813130
ET_LOG(Error, "Failed to get session bind point requirements");
30823131
return false;
30833132
}
30843133

30853134
for (auto& bind_point_requirement : bind_point_requirements) {
3135+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_SETUP_DATA_GRAPH_BIND_POINT");
30863136
const bool is_transient_bind_point = bind_point_requirement.bindPoint ==
30873137
VK_DATA_GRAPH_PIPELINE_SESSION_BIND_POINT_TRANSIENT_ARM;
30883138

@@ -3263,13 +3313,16 @@ bool VgfRepr::process_vgf(
32633313
.basePipelineHandle = VK_NULL_HANDLE,
32643314
.basePipelineIndex = -1,
32653315
};
3266-
result = vkCreateComputePipelines(
3267-
vk_device,
3268-
VK_NULL_HANDLE,
3269-
1,
3270-
&compute_info,
3271-
nullptr,
3272-
&segment.vk_pipeline);
3316+
{
3317+
VGF_PROFILE_SCOPE(event_tracer, "VGF_INIT_CREATE_COMPUTE_PIPELINE");
3318+
result = vkCreateComputePipelines(
3319+
vk_device,
3320+
VK_NULL_HANDLE,
3321+
1,
3322+
&compute_info,
3323+
nullptr,
3324+
&segment.vk_pipeline);
3325+
}
32733326
if (result != VK_SUCCESS) {
32743327
ET_LOG(Error, "Failed to create compute pipeline");
32753328
return false;

0 commit comments

Comments
 (0)