Skip to main content
`Ctrl`+`K`

# PetscLogGpuTimeBegin

Start timer for device

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscLogGpuTimeBegin(void)

## Notes

When GPU is enabled, the timer is run on the GPU, it is a separate logging of time devoted to GPU computations (excluding kernel launch times).

When GPU is not available, the timer is run on the CPU, it is a separate logging of time devoted to GPU computations (including kernel launch times).

There is no need to call WaitForCUDA() or WaitForHIP() between `PetscLogGpuTimeBegin()` and `PetscLogGpuTimeEnd()`

This timer should NOT include times for data transfers between the GPU and CPU, nor setup actions such as allocating space.

The regular logging captures the time for data transfers and any CPU activities during the event. It is used to compute the flop rate on the GPU as it is actively engaged in running a kernel.

## Developer Notes

The GPU event timer captures the execution time of all the kernels launched in the default stream by the CPU between `PetscLogGpuTimeBegin()` and `PetscLogGpuTimeEnd()`.

`PetscLogGpuTimeBegin()` and `PetscLogGpuTimeEnd()` insert the begin and end events into the default stream (stream 0). The device will record a time stamp for the event when it reaches that event in the stream. The function xxxEventSynchronize() is called in `PetscLogGpuTimeEnd()` to block CPU execution, but not continued GPU execution, until the timer event is recorded.

## See Also

Profiling, `PetscLogView()`, `PetscLogGpuFlops()`, `PetscLogGpuTimeEnd()`, `PetscLogGpuTime()`

## Level

intermediate

## Location

src/sys/logging/plog.c

Index of all Log routines
Table of Contents for all manual pages
Index of all manual pages