Download User's Guide
Transcript
Introduction 1.3. CUPTI Activity API The CUPTI Activity API allows you to asynchronously collect a trace of an application's CPU and GPU CUDA activity. The following terminology is used by the activity API. Activity Record CPU and GPU activity is reported in C data structures called activity records. There is a different C structure type for each activity kind (e.g. CUpti_ActivityMemcpy). Records are generically referred to using the CUpti_Activity type. This type contains only a kind field that indicates the kind of the activity record. Using this kind, the object can be cast from the generic CUpti_Activity type to the specific type representing the activity. See the printActivity function in the activity_trace_async sample for an example. Activity Buffer An activity buffer is used to transfer one or more activity records from CUPTI to the client. CUPTI fills activity buffers with activity records as the corresponding activities occur on the CPU and GPU. The CUPTI client is responsible for providing empty activity buffers as necessary to ensure that no records are dropped. This section describes the new asynchronous buffering API implemented by cuptiActivityRegisterCallbacks, cuptiActivityFlush, and cuptiActivityFlushAll. The old buffering API implemented by cuptiActivityEnqueueBuffer and cuptiActivityDequeueBuffer is still supported but is deprecated and will be removed in a future release (see the API documentation for information on these functions). To ensure that all activity records are collected, CUPTI must be initialized before any CUDA driver or runtime API is invoked. Initialization can be done by enabling one or more activity kinds using cuptiActivityEnable or cuptiActivityEnableContext, as shown in the initTrace function of the activity_trace_async sample. Some activity kinds cannot be directly enabled, see the API documentation for for CUpti_ActivityKind for details. Functions cuptiActivityEnable and cuptiActivityEnableContext will return CUPTI_ERROR_NOT_COMPATIBLE if the requested activity kind cannot be enabled. The new activity buffer API uses callbacks to request and return buffers of activity records. The use the asynchronous buffering API you must first register two callbacks using cuptiActivityRegisterCallbacks. One of these callbacks will be invoked whenever CUPTI needs an empty activity buffer. The other callback is used to deliver a buffer containing one or more activity records to the client. To minimize profiling overhead the client should return as quickly as possible from these callbacks. Functions cuptiActivityFlush and cuptiActivityFlushAll can be used to force CUPTI to deliver any activity buffers that contain completed activity records. Functions cuptiActivityGetAttribute and cuptiActivitySetAttribute can be used www.nvidia.com CUPTI DA-05679-001 _v5.5 | 2