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

Sampling API Error

chhenning
Beginner
784 Views
Hi there, I'm new to Intel Amplifier User API. I started with a very simple program to understand how things are working but even the simplest of all programs is producing
Sampling API error: resume sampling collection failed.
[bash]#include 
#include 

using namespace std;

//#define INTEL_NO_ITTNOTIFY_API
#include 


int _tmain(int argc, _TCHAR* argv[])
{
    __itt_resume();

    double total = 0;

    for( int i = 0; i < 10000; ++i )
    {
        for( int j = 0; j < 10000; ++j )
        {
            double a = sqrt( double( i ));
            double b = sqrt( double( j ));

            total += sqrt( a * b );
        }
    }

    __itt_pause();

    cout.setf( std::ios::floatfield, std::ios::fixed );
    cout << total << std::endl;

	return 0;
}
[/bash]
Am I doing something wrong?
Also, was this forum entry ever solved:
Thanks,
Christian
0 Kudos
3 Replies
Rob5
New Contributor II
784 Views
Christian,

Are you starting the analysis in paused mode (for example, from the GUI by clicking Start or Start Paused)? If not, then it may be that you are starting the application analysis run not paused - in which case the first itt_notify is an attempt to resume the application analysis when the analysis is already running.

Attempt to pause first, and then resume.

Rob
0 Kudos
chhenning
Beginner
784 Views
Hi Rob, thanks for your reply. I did what you were suggesting but it's not working. The console output shows:
The sampling collection paused.
Sampling API Error: resume sampling collection failed.
Sampling API Error: pause sampling collection failed.
I work on Windows7 64bit with Visual C++ 2010 and Intel VTune Amplifier XE 2011.
Is there a tutorial somewhere that shows how to use this API?
Thanks,
Christian
0 Kudos
Rob5
New Contributor II
784 Views

Christian,

So far I have only been able to replicate the behavior with your original example if I start collection un-paused. I may need to know more about how you are starting the analysis (un-paused or paused). If I start the analysis in the GUI by clicking the Start Paused button the example works as expected with no Sampling API error: resume sampling collection failed. However, if I start the analysis via the GUI regularly (not paused), the error occurs because there is nothing to resume since the analysis is not paused.

With your original example where you call a resume API first and then call the pause API, if you start the application un-paused the error occurs. In your example, you need to either start the application paused or alternatively start the application un-paused but swap the resume / pause API so that the pause API is called first.

If you are starting the analysis normal (un-paused), then in the code call the pause API first then call resume next presumably after you have passed the uninteresting work you do not wish to collect data, the error does not occur.

The first URL link below shows two usage examples of pause / resume in different cases depending on what you wish to accomplish. Note that the first usage example starts the analysis via the GUI in paused mode then the resume API is called. This may be a usage case where you wish to ignore the uninteresting start-up work of an application.

The following documentation discusses Collection Control API (pause / resume) in conjunction with pause / resume controls in the GUI.

Intel Parallel Studio XE 2011 - Linux* OS
http://software.intel.com/sites/products/documentation/hpc/amplifierxe/en-us/lin/ug_docs/olh/common/pause_resume_api.html

Additionally be aware that as the documentation notes, the call frequency should also be taken into consideration.

The Pause/Resume API call frequency is about 1Hz for a reasonable rate. Since this operation pauses and resumes data collection in all processes in the analysis run with the corresponding collection state notification to GUI, you are not recommended to call it on frequent basis for small workloads.

Articles:
http://software.intel.com/en-us/articles/use-new-pause-and-resume-api-from-intel-vtune-amplifier-2011-xe/

http://software.intel.com/sites/products/documentation/hpc/amplifierxe/en-us/lin/ug_docs/olh/common/start_collection_paused.html

Thanks
Rob

0 Kudos
Reply