Counters API

The counters API is used to observe user-defined global characteristic counters that are unknown to VTune Amplifier. For example, it is useful for system on a chip (SoC) development when different counters may represent different parts of the SoC and count some hardware characteristics.

Use This Primitive

To Do This

__itt_counter

__itt_counter_create(const char *name, const char *domain);

__itt_counter_createA(const char *name, const char *domain);

__itt_counter_createW(const wchar_t *name, const wchar_t *domain);

__itt_counter_create_typed (const char *name, const char *domain, __itt_metadata_type type);

__itt_counter_create_typedA __itt_counter_create_typedA(const char *name, const char *domain, __itt_metadata_type type);

__itt_counter_create_typedW __itt_counter_create_typedW(const wchar_t *name, const wchar_t *domain, __itt_metadata_type type);

Define and create a new counter object. A counter name and domain name should be specified. To load a specialized type of data, specify the counter type. By default the unsigned int64 type is used.

__itt_counter_inc (__itt_counter id);

__itt_counter_inc_delta(__itt_counter id, unsigned long long value);

__itt_counter_dec(__itt_counter id);

__itt_counter_dec_delta(__itt_counter id, unsigned long long value);

Increment\decrement counter value. Applicable to uint64 counters only.

__itt_counter_set_value(__itt_counter id, void *value_ptr);

Directly set the counter value. This is the recommended way to change the value of a counter.

__itt_counter_destroy(__itt_counter id);

Remove an existing counter.

Usage Example

The following example creates a counter that measures temperature and memory usage metrics.

#include "ittnotify.h"

__itt_counter temperatureCounter = __itt_counter_create("Temperature", "Domain");
__itt_counter memoryUsageCounter = __itt_counter_create("Memory Usage", "Domain");
unsigned __int64 temperature;

while (...)
{
    ...
    temperature = getTemperature();
    __itt_counter_set_value(temperatureCounter, &temperature);

    __itt_counter_inc_delta(memoryUsageCounter, getAllocatedMemSize());
    __itt_counter_dec_delta(memoryUsageCounter, getDeallocatedMemSize());
    ...
}

__itt_counter_destroy(temperatureCounter);
__itt_counter_destroy(memoryUsageCounter);
For more complete information about compiler optimizations, see our Optimization Notice.
Select sticky button color: 
Orange (only for download buttons)