11.07.2015 Views

CUPTI User's Guide

CUPTI User's Guide

CUPTI User's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

device-specific limits. At any given time, a device may be configured to count eventsfrom a limited number of event groups. All events in an event group must belong tothe same event domain.Event Group Set: An event group set is a collection of event groups that can be enabled atthe same time. Event group sets are created by cuptiEventGroupSetsCreate andcuptiMetricCreateEventGroupSets.The tables included in this section list the events available for each device, as determinedby the device’s compute capability. You can also determine the events available on adevice using the cuptiDeviceEnumEventDomains and cuptiEventDomainEnumEventsfunctions. The cupti_query sample described on page 25 shows how to use thesefunctions. You can also enumerate all the <strong>CUPTI</strong> events available on any device using thecuptiEnumEventDomains function.Configuring and reading event counts requires the following steps. First, select your eventcollection mode. If you want to count events that occur during the execution of a kernel,use cuptiSetEventCollectionMode to set mode <strong>CUPTI</strong>_EVENT_COLLECTION_MODE_KERNEL.If you want to continuously sample the event counts, use mode<strong>CUPTI</strong>_EVENT_COLLECTION_MODE_CONTINUOUS. Next determine the names of the events thatyou want to count, and then use the cuptiEventGroupCreate, cuptiEventGetIdFromName,and cuptiEventGroupAddEvent functions to create and initialize an event group with thoseevents. If you are unable to add all the events to a single event group then you will need tocreate multiple event groups. Alternatively, you can use the cuptiEventGroupSetsCreatefunction to automatically create the event group(s) required for a set of events.To begin counting a set of events, enable the event group or groups that contain thoseevents by using the cuptiEventGroupEnable function. If your events are contained inmultiple event groups you may be unable to enable all of the event groups at the sametime, due to device limitations. In this case, you will need to gather the events acrossmultiple executions of the application.Use the cuptiEventGroupReadEvent and/or cuptiEventGroupReadAllEvents functions toread the event values. When you are done collecting events, use thecuptiEventGroupDisable function to stop counting of the events contained in an eventgroup. The callback_event sample described on page 25 shows how to use thesefunctions to create, enable, and disable event groups, and how to read event counts.Collecting Kernel Execution EventsA common use of the event API is to count a set of events during the execution of a kernel(as demonstrated by the callback_event sample). The following code shows a typicalcallback used for this purpose. Assume that the callback was enabled only for a kernellaunch using the CUDA runtime (i.e. by cuptiEnableCallback(1, subscriber,<strong>CUPTI</strong>_CB_DOMAIN_RUNTIME_API, <strong>CUPTI</strong>_RUNTIME_TRACE_CBID_cudaLaunch_v3020). ToCUDA Tools SDK <strong>CUPTI</strong> User’s <strong>Guide</strong> DA-05679-001_v01 | 9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!