Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
4975 Discussions

How do I use Using Pause/Resume API to do the following?

zgzg2020
Beginner
704 Views
Hi,
I am using a large third-party open-source software with OpenMP. The "main" C++ function is located in a closed-source counter part.
I have added some OpenMP for directives and I would like to see how well or worse the performance has become.
I read the article on Using Pause/Resume API. However, I want to do the opposite of what is written there. I want the sampling to be Off during the whole duration. Then, it turns on right before the part where I placed my OpenMP directives. Then, it goes back off, until it re-reaches that OpenMP directive part again.

For example:

[cpp]#include 
#include

int main () // I have no access to this part
{
//If I had access I can simply add VTPause()
time_t seconds;

while(...)
{
seconds = time (NULL);
// VTResume()
for(...)
printf ("%ld hours since January 1, 1970", seconds/3600);
// VTPause
}
return 0;
}[/cpp]

If that is not possible, then I would like to change my question to be that I want to calculate how much a certain function has taken. I have done some sampling in the past. But, the displayed information is just too much for me to know which one to look at. Many CLOCK columns.
0 Kudos
1 Solution
Vladimir_T_Intel
Moderator
704 Views
Quoting - zgzg2020

As I understand from the tutorial, if I want to monitor a certain area with VTune, I should place a VTPause() a the beginning of the program, and then add a VTResume() right before the area where I want to monitor.
But, because I do not have access to the main function of the program, I want to know what kind of orgnization do I place the VTPause()/VTResume() in my program? Where should I place them if I have no access to the main function? Note, I want to monitor a very small area in a very large program.

Not quite right. When using VTune API, you start VTune collection in "paused" mode. This means that VTune doesn't collect any data until program execution reached VTResume() call. After that collection starts and then it goes until reaching VTPause() call. So, you can collect profiling data on any code region within your program, just put VTResume() before and VTPause() after the code of interest.

View solution in original post

0 Kudos
9 Replies
Vladimir_T_Intel
Moderator
704 Views
Quoting - zgzg2020
Hi,
I am using a large third-party open-source software with OpenMP. The "main" C++ function is located in a closed-source counter part.
I have added some OpenMP for directives and I would like to see how well or worse the performance has become.
I read the article on Using Pause/Resume API. However, I want to do the opposite of what is written there. I want the sampling to be Off during the whole duration. Then, it turns on right before the part where I placed my OpenMP directives. Then, it goes back off, until it re-reaches that OpenMP directive part again.

For example:

[cpp]#include 
#include

int main () // I have no access to this part
{
//If I had access I can simply add VTPause()
time_t seconds;

while(...)
{
seconds = time (NULL);
// VTResume()
for(...)
printf ("%ld hours since January 1, 1970", seconds/3600);
// VTPause
}
return 0;
}[/cpp]

If that is not possible, then I would like to change my question to be that I want to calculate how much a certain function has taken. I have done some sampling in the past. But, the displayed information is just too much for me to know which one to look at. Many CLOCK columns.

Hi,

May be I didn't get it what do you mean by saying that you "want to do the opposite of what is written there", but if you put the VTResume()call right before the omp for' pragma and the VTPause() call right after the end of scope, you'll get the sampling results over threads created ror your function. If you interested in measuring performance gain only, you may want to insert only time calls instead.

0 Kudos
zgzg2020
Beginner
704 Views

Hi,

May be I didn't get it what do you mean by saying that you "want to do the opposite of what is written there", but if you put the VTResume()call right before the omp for' pragma and the VTPause() call right after the end of scope, you'll get the sampling results over threads created ror your function. If you interested in measuring performance gain only, you may want to insert only time calls instead.


As I understand from the tutorial, if I want to monitor a certain area with VTune, I should place a VTPause() a the beginning of the program, and then add a VTResume() right before the area where I want to monitor.
But, because I do not have access to the main function of the program, I want to know what kind of orgnization do I place the VTPause()/VTResume() in my program? Where should I place them if I have no access to the main function? Note, I want to monitor a very small area in a very large program.

Can you tell me how to use those time calls?
0 Kudos
zgzg2020
Beginner
704 Views

Hi,

May be I didn't get it what do you mean by saying that you "want to do the opposite of what is written there", but if you put the VTResume()call right before the omp for' pragma and the VTPause() call right after the end of scope, you'll get the sampling results over threads created ror your function. If you interested in measuring performance gain only, you may want to insert only time calls instead.


I looked for what "time calls" are, but couldn't find them. Is there a closer keyword I can look for to find those?

0 Kudos
Vladimir_T_Intel
Moderator
705 Views
Quoting - zgzg2020

As I understand from the tutorial, if I want to monitor a certain area with VTune, I should place a VTPause() a the beginning of the program, and then add a VTResume() right before the area where I want to monitor.
But, because I do not have access to the main function of the program, I want to know what kind of orgnization do I place the VTPause()/VTResume() in my program? Where should I place them if I have no access to the main function? Note, I want to monitor a very small area in a very large program.

Not quite right. When using VTune API, you start VTune collection in "paused" mode. This means that VTune doesn't collect any data until program execution reached VTResume() call. After that collection starts and then it goes until reaching VTPause() call. So, you can collect profiling data on any code region within your program, just put VTResume() before and VTPause() after the code of interest.

0 Kudos
Vladimir_T_Intel
Moderator
704 Views
Quoting - zgzg2020

I looked for what "time calls" are, but couldn't find them. Is there a closer keyword I can look for to find those?


By "time call" I was meaning just using Windows API time functions. Something liketimeGetTimeor QueryPerformanceCounter for better precision.
0 Kudos
zgzg2020
Beginner
704 Views

Not quite right. When using VTune API, you start VTune collection in "paused" mode. This means that VTune doesn't collect any data until program execution reached VTResume() call. After that collection starts and then it goes until reaching VTPause() call. So, you can collect profiling data on any code region within your program, just put VTResume() before and VTPause() after the code of interest.


I see now. Thanks for clearing that out for me!
0 Kudos
zgzg2020
Beginner
704 Views

By "time call" I was meaning just using Windows API time functions. Something liketimeGetTime or QueryPerformanceCounter for better precision.

I don't know what I pressed by mistake, and got those large fonts : ).
Anyway, thanks!!
0 Kudos
zgzg2020
Beginner
704 Views

By "time call" I was meaning just using Windows API time functions. Something liketimeGetTime or QueryPerformanceCounter for better precision.

I have just finished adding QueryPerformanceCounter into my project. From what I can see, it is very precise. I used to use ctime's clock() function, which was nothing like this one.

Anyway, thank you for your help!!! : )
0 Kudos
Vladimir_T_Intel
Moderator
704 Views
Quoting - zgzg2020

I have just finished adding QueryPerformanceCounter into my project. From what I can see, it is very precise. I used to use ctime's clock() function, which was nothing like this one.

Anyway, thank you for your help!!! : )

You are welcome! Good to know that it helped :)
0 Kudos
Reply