API Reference Manual  1.45.0
ODP CPU

API Description

CPU cycle count, frequency, etc.

information.

Functions

int odp_cpu_id (void)
 CPU identifier. More...
 
int odp_cpu_count (void)
 CPU count. More...
 
const char * odp_cpu_model_str (void)
 CPU model name of this CPU. More...
 
const char * odp_cpu_model_str_id (int id)
 CPU model name of a CPU. More...
 
uint64_t odp_cpu_hz (void)
 Current CPU frequency in Hz. More...
 
uint64_t odp_cpu_hz_id (int id)
 Current CPU frequency of a CPU (in Hz) More...
 
uint64_t odp_cpu_hz_max (void)
 Maximum CPU frequency in Hz. More...
 
uint64_t odp_cpu_hz_max_id (int id)
 Maximum CPU frequency of a CPU (in Hz) More...
 
uint64_t odp_cpu_cycles (void)
 Current CPU cycle count. More...
 
uint64_t odp_cpu_cycles_diff (uint64_t c2, uint64_t c1)
 CPU cycle count difference. More...
 
uint64_t odp_cpu_cycles_max (void)
 Maximum CPU cycle count. More...
 
uint64_t odp_cpu_cycles_resolution (void)
 Resolution of CPU cycle count. More...
 
void odp_cpu_pause (void)
 Pause CPU execution for a short while. More...
 
void odp_prefetch (const void *addr)
 Prefetch into data cache. More...
 
void odp_prefetch_l1 (const void *addr)
 Prefetch into L1 data cache. More...
 
void odp_prefetch_l2 (const void *addr)
 Prefetch into L2 data cache. More...
 
void odp_prefetch_l3 (const void *addr)
 Prefetch into L3 data cache. More...
 
void odp_prefetch_store (const void *addr)
 Prefetch into data cache for storing. More...
 
void odp_prefetch_store_l1 (const void *addr)
 Prefetch into L1 data cache for storing. More...
 
void odp_prefetch_store_l2 (const void *addr)
 Prefetch into L2 data cache for storing. More...
 
void odp_prefetch_store_l3 (const void *addr)
 Prefetch into L3 data cache for storing. More...
 
void odp_prefetch_strm_l1 (const void *addr)
 Streaming prefetch into L1 data cache. More...
 
void odp_prefetch_store_strm_l1 (const void *addr)
 Streaming prefetch into L1 data cache for storing. More...
 

Function Documentation

◆ odp_cpu_id()

int odp_cpu_id ( void  )

CPU identifier.

Determine CPU identifier on which the calling is running. CPU numbering is system specific.

Returns
CPU identifier
Examples
odp_bench_misc.c, odp_hello.c, odp_icache_perf.c, odp_stress.c, and odp_sysinfo.c.

◆ odp_cpu_count()

int odp_cpu_count ( void  )

CPU count.

Report the number of CPU's available to this ODP program. This may be smaller than the number of (online) CPU's in the system.

Returns
Number of available CPU's
Examples
odp_bench_misc.c, odp_l3fwd.c, and odp_sysinfo.c.

◆ odp_cpu_model_str()

const char* odp_cpu_model_str ( void  )

CPU model name of this CPU.

Returns the CPU model name of this CPU.

Returns
Pointer to CPU model name string
Examples
odp_sysinfo.c.

◆ odp_cpu_model_str_id()

const char* odp_cpu_model_str_id ( int  id)

CPU model name of a CPU.

Return CPU model name of the specified CPU.

Parameters
idCPU ID
Returns
Pointer to CPU model name string

◆ odp_cpu_hz()

uint64_t odp_cpu_hz ( void  )

Current CPU frequency in Hz.

Returns current frequency of this CPU. Returns zero if the frequency request is not supported.

Returns
CPU frequency in Hz
Return values
0Not supported or a failure
Examples
odp_bench_misc.c, and odp_sysinfo.c.

◆ odp_cpu_hz_id()

uint64_t odp_cpu_hz_id ( int  id)

Current CPU frequency of a CPU (in Hz)

Returns current frequency of the specified CPU. Returns zero if the frequency request is not supported.

Parameters
idCPU ID
Returns
CPU frequency in Hz
Return values
0Not supported or a failure
Examples
odp_bench_misc.c.

◆ odp_cpu_hz_max()

uint64_t odp_cpu_hz_max ( void  )

Maximum CPU frequency in Hz.

Returns the maximum frequency of this CPU. Returns zero if the frequency request is not supported.

Returns
CPU frequency in Hz
Return values
0Not supported or a failure
Examples
odp_bench_misc.c, and odp_sysinfo.c.

◆ odp_cpu_hz_max_id()

uint64_t odp_cpu_hz_max_id ( int  id)

Maximum CPU frequency of a CPU (in Hz)

Returns the maximum frequency of the specified CPU. Returns zero if the frequency request is not supported.

Parameters
idCPU ID
Returns
CPU frequency in Hz
Return values
0Not supported or a failure
Examples
odp_bench_misc.c.

◆ odp_cpu_cycles()

uint64_t odp_cpu_cycles ( void  )

Current CPU cycle count.

Return current CPU cycle count. Cycle count may not be reset at ODP init and thus may wrap back to zero between two calls. Use odp_cpu_cycles_max() to read the maximum count value after which it wraps. Cycle count frequency follows the CPU frequency and thus may change at any time. Cycle count should not be used for time measurements due to the possibility of frequency variation. The count may advance in steps larger than one. Use odp_cpu_cycles_resolution() to read the step size.

Returns zero if CPU cycle counter is not supported.

Returns
Current CPU cycle count
Return values
0Not supported
Examples
odp_bench_misc.c, odp_cpu_bench.c, odp_dma_perf.c, odp_dmafwd.c, odp_icache_perf.c, odp_pool_perf.c, odp_queue_perf.c, odp_sched_perf.c, odp_stash_perf.c, and odp_timer_perf.c.

◆ odp_cpu_cycles_diff()

uint64_t odp_cpu_cycles_diff ( uint64_t  c2,
uint64_t  c1 
)

CPU cycle count difference.

Calculate difference between cycle counts c1 and c2. Parameter c1 must be the first cycle count sample and c2 the second. The function handles correctly single cycle count wrap between c1 and c2.

Parameters
c2Second cycle count
c1First cycle count
Returns
CPU cycles from c1 to c2
Examples
odp_bench_misc.c, odp_dma_perf.c, odp_dmafwd.c, odp_icache_perf.c, odp_pool_perf.c, odp_queue_perf.c, odp_sched_perf.c, odp_stash_perf.c, and odp_timer_perf.c.

◆ odp_cpu_cycles_max()

uint64_t odp_cpu_cycles_max ( void  )

Maximum CPU cycle count.

Maximum CPU cycle count value before it wraps back to zero. Returns zero if CPU cycle counter is not supported.

Returns
Maximum CPU cycle count value
Return values
0Not supported
Examples
odp_bench_misc.c.

◆ odp_cpu_cycles_resolution()

uint64_t odp_cpu_cycles_resolution ( void  )

Resolution of CPU cycle count.

CPU cycle count may advance in steps larger than one. This function returns resolution of odp_cpu_cycles() in CPU cycles. Returns zero if CPU cycle counter is not supported.

Returns
CPU cycle count resolution in CPU cycles
Return values
0Not supported
Examples
odp_bench_misc.c.

◆ odp_cpu_pause()

void odp_cpu_pause ( void  )

Pause CPU execution for a short while.

This call is intended for tight loops which poll a shared resource. A short pause within the loop may save energy and improve system performance as CPU polling frequency is reduced.

Examples
odp_bench_misc.c, and odp_ipsecfwd.c.

◆ odp_prefetch()

void odp_prefetch ( const void *  addr)

Prefetch into data cache.

Hints CPU to prefetch data into all data cache levels. Depending on implementation, this function may be equal to odp_prefetch_l1().

Parameters
addrData address to be prefetched (may be invalid)
Examples
odp_bench_misc.c.

◆ odp_prefetch_l1()

void odp_prefetch_l1 ( const void *  addr)

Prefetch into L1 data cache.

Hints CPU to prefetch data into L1 data cache.

Parameters
addrData address to be prefetched (may be invalid)

◆ odp_prefetch_l2()

void odp_prefetch_l2 ( const void *  addr)

Prefetch into L2 data cache.

Hints CPU to prefetch data into L2 data cache.

Parameters
addrData address to be prefetched (may be invalid)

◆ odp_prefetch_l3()

void odp_prefetch_l3 ( const void *  addr)

Prefetch into L3 data cache.

Hints CPU to prefetch data into L3 data cache.

Parameters
addrData address to be prefetched (may be invalid)

◆ odp_prefetch_store()

void odp_prefetch_store ( const void *  addr)

Prefetch into data cache for storing.

Hints CPU to prefetch data into all data cache levels for storing. Depending on implementation, this function may be equal to odp_prefetch_store_l1().

Parameters
addrData address to be prefetched (may be invalid)
Examples
odp_bench_misc.c.

◆ odp_prefetch_store_l1()

void odp_prefetch_store_l1 ( const void *  addr)

Prefetch into L1 data cache for storing.

Hints CPU to prefetch data into L1 data cache for storing.

Parameters
addrData address to be prefetched (may be invalid)

◆ odp_prefetch_store_l2()

void odp_prefetch_store_l2 ( const void *  addr)

Prefetch into L2 data cache for storing.

Hints CPU to prefetch data into L2 data cache for storing.

Parameters
addrData address to be prefetched (may be invalid)

◆ odp_prefetch_store_l3()

void odp_prefetch_store_l3 ( const void *  addr)

Prefetch into L3 data cache for storing.

Hints CPU to prefetch data into L3 data cache for storing.

Parameters
addrData address to be prefetched (may be invalid)

◆ odp_prefetch_strm_l1()

void odp_prefetch_strm_l1 ( const void *  addr)

Streaming prefetch into L1 data cache.

Hints CPU to prefetch data of low temporal locality into L1 data cache. Streaming prefetch is optimal for data that will be used only once.

Parameters
addrData address to be prefetched (may be invalid)

◆ odp_prefetch_store_strm_l1()

void odp_prefetch_store_strm_l1 ( const void *  addr)

Streaming prefetch into L1 data cache for storing.

Hints CPU to prefetch data of low temporal locality into L1 data cache for storing. Streaming prefetch is optimal for data that will be used only once.

Parameters
addrData address to be prefetched (may be invalid)