Macros

This section describes benchmarking library macros.

DISABLE_NVPLAYFAIR

A benchmark can define this macro as part of the CFLAGs given to the compiler. This will transform all the calls to NvPlayfair library APIs into innocuous macros and remove the dependency of the benchmark on libnvplayfair.so during runtime.

NVP_CHECKERR_EXIT

This is an error checking macro, which can be used as a wrapper around all NvPlayfair library API calls. It provides straight-forward error handling by printing a message on console / log file and exiting the program when an error is reported by an NvPlayfair API.

/* Example Usage */
NVP_CHECKERR_EXIT(NvpRecordSample(NULL, startTimeMark, endTimeMark);
 
/* Expected Output
 *   myBenchmark.c, myFunction:13, NvPlayfair Error: NVP_FAIL_NULLPTR */

NVP_GET_SAMPLE_COUNT

This macro can be used to get the sample count in the internal ring-buffer of the given NvpPerfData_t* object.
/* Example Usage */
uint64_t curSampleCount = NVP_GET_SAMPLE_COUNT(perfDataObj);

for_each_sample

This is a convenience macro, which can be used to iterate over the timestamp and latency values of all the samples recorded so far in the given NvpPerfData_t* object.

/* Example Usage */
uint32_t sampleNumber = 0;
uint64_t timestamp, latency;
 
for_each_sample(&perfData, timestamp, latency) {
    printf("Sample #: %d Timestamp: %ul Latency: %ul\n",
            sampleNumber++, timestamp, latency);
}

for_each_sample_latency

This is similar to "for_each_sample" macro but it provides only the latency value for each sample in the given object.

/* Example Usage */
uint32_t sampleNumber = 0;
uint64_t latency;
 
for_each_sample_latency(&perfData, latency) {
    printf("Sample #: %d Latency: %ul\n", sampleNumber++, latency);
}