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

VTune timestamp api

Min_Xu
Beginner
1,689 Views

Hi

I would like a function that would provide me the timestamp vTune uses in its timeline, so that any program trace/output can be tagged with this timestamp for a more comprehensive analysis (e.g.., I would like to know how many tasks a worker thread still have at a particular timestamp in the vtune timeline view)..

This function does not appear to be available in the current vtuneapi dll.  Is it something that can be added, or can you show me now to get the equivalent value for the CPU ticks (preferred over OS ticks since more accurate)  in .NET code?   I have looked other .NET forums on accurate timestamp function but there doesn't seem to have any correlation with vTune:

1)  DateTime.Now is inaccurate (15 ms update cycle)

2)  StopWatch will drift

 

Thanks

0 Kudos
11 Replies
David_A_Intel1
Employee
1,689 Views

Hi Min:

I'm not sure I totally understand your question, but...the rdtsc instruction is how you get the processor timestamp counter value.  It is an assembly instruction, so you would need to build a library and call the routine from .NET code.  You won't be able to simply map it to the VTune Amplifier timeline, however.  Amplifier does not use the raw value.  I think it starts from 'zero' for every collection.

There is already an API to insert a "marker" in the timeline.  When you talk about tasks and worker threads, what threading model are you using?

Finally, you might check out the "Import CSV data" and "custom collectors" topics in the product documentation.  You can overlay data collected outside of the tool, if you comply with the data requirements.

0 Kudos
Min_Xu
Beginner
1,689 Views

Hi

I believe vTune sets the Elapsed time to 0 when launching the application, but the CPU Timestamp and the OS Timestamp (in the Show timescale as) appear to have an origin way earlier than when the application is launched.  Would like a function to give a value in the same scale and origin, so that I can correlate "Tasks and Frames" chart to trace (file log) output
 

I am using standard .NET threads for Worker threads, with various tasks that have various affinity and dependency requirements, so would like a more comprehensive analysis.

 

Thanks

0 Kudos
Peter_W_Intel
Employee
1,689 Views

There is already an API to insert a "marker" in the timeline...

Mr.Anderson is right! You can refer to ittnotify.h - I provided the usage in this article, sorry this was written in Chinese but example code can be referred...

See the picture in the article, all your marked time range (on threads) will be displayed in timeline report. You can select specific time-range, then do "Zoom-in and Filter by Selection" to generate a new report, you may use "Thread / Function / Call stack" as view point, so you will see your interest of function (time stamp, elapsed) under specific thread, in bottom-up report. 

0 Kudos
Bernard
Valued Contributor I
1,689 Views

@Min xu

You can add compiler intrinsinc __rdtsc() which will save you from little bit of assembly coding.

0 Kudos
Min_Xu
Beginner
1,689 Views

Hi Peter

A time marker is not enough.  I need to have different transaction identified, and most important of all, I need the count of various queues (common, priority, private etc etc) indicated.  I also need other information such as type of task the worker is performing (which would indicate its requirement for exclusive access).  Time marker unfortunately is not enough.

 

iliyapolak:

Is that the value that the vTune is displaying for CPU timestamp, would the read out value correlate to vTune's timescale on the "Tasks and Frames" graph?  Should I worry about the different cores having the same time origin and cpu speedstep etc etc?

 

Thanks

0 Kudos
Bernard
Valued Contributor I
1,689 Views

Do you refer to rdtsc instruction?

0 Kudos
Min_Xu
Beginner
1,689 Views

iliyapolak

Yes, you were discussing the rdtsc instruction.

Is the value from this instruction what vTune displays for CPU timestamp?  Should I worry about the different cores having the same time origin and cpu speedstep etc etc?

 

0 Kudos
Bernard
Valued Contributor I
1,689 Views

I think that Mr.Anderson gave an answer regarding time measurement of VTune.

Now regarding the performance issues related to rdtsc please follow these links:

http://software.intel.com/en-us/forums/topic/288625

http://software.intel.com/en-us/forums/topic/335541

http://software.intel.com/en-us/forums/topic/306222

0 Kudos
Min_Xu
Beginner
1,689 Views
Since establishing the cpu tsc count per core to the application timeline as displayed by vTune is extremely hard, I chose to use .NET System.Diagnostics.Process.GetCurrentProcess().StartTime as the application starting time, and use DateTime.Now.Subtract(starttime).TotalMilliseconds to log the timestamp in a file, and manually adjust (given a known event in both log file and in the vTune Tasks and Frames view) to match up. However, when calling Writeline / String.Format on this double value (double precision decimal), the output fractional millisecond portion is completely useless, as the .1 and .01 position of the fractional part is almost always in sync with the 1000 and 100 integral portion, respectively.
0 Kudos
Peter_W_Intel
Employee
1,689 Views

Let's talk back to VTune Amplifier. I don't know if I can address your requirements...however you can try:

Using advanced-hotspots to profiling your app->View bottom-up report->select "grouping" as "Thread \ Function \ Callstack"->Change viewpoint to "Hardware Event Counts". This will display time by CPU clocks on each function of each thread. It's better than using __rdtsc() without inserting code.

0 Kudos
David_A_Intel1
Employee
1,689 Views

BTW @Min Xu, the "Creating a CSV File with External Data" topic in the VTune Amplifier XE product documentation shows you how to format the CSV file, including specifying whether the data is from QueryPerformanceCounter, rdtsc, or others.  Since your code is .NET, I would suspect that using QueryPerformanceCounter would be the easiest to access.

So, it's not so much about tagging program output with the VTune Amplifier XE timestamp as it is correlating the program output with the VTune Amplifier XE data, right?  Importing the data and specifying the clock source will allow VTune Amplifier XE to do that.

0 Kudos
Reply