cupti

package module
v0.0.0-...-45295f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2019 License: NCSA Imports: 29 Imported by: 13

README

CUPTI bindings in Go Build Status

Example

The callback functions are publised to a tracing server. You need to have a carml_config.yml and the tracing server running to see the spans. Refer to CarML Config and Starting Tracer Server

Make sure /usr/local/cuda/lib64 and /usr/local/cuda/extras/CUPTI/lib64 are in your LD_LIBRARY_PATH

cd examples/vector_add
make
cd ../cupti
go run main.go

Then go to TRACER_URL:16686 to see the spans

Issues

The CGO interface passes go pointers to the C API. This is an error by the CGO runtime. If you get the following error

panic: runtime error: cgo argument has Go pointer to Go pointer

Then you need to place

export GODEBUG=cgocheck=0

in your ~/.bashrc or ~/.zshrc file and then run either source ~/.bashrc or source ~/.zshrc.

Notes

  • The CUDA Profiling Tools Interface (CUPTI) enables the creation of profiling and tracing tools that target CUDA applications. CUPTI provides four APIs: the Activity API, the Callback API, the Event API, and the Metric API.
  • CUPTI initialization occurs lazily the first time you invoke any CUPTI function. For the Activity, Event, Metric, and Callback APIs there are no requirements on when this initialization must occur (i.e. you can invoke the first CUPTI function at any point).
  • The CUPTI Activity API allows you to asynchronously collect a trace of an application's CPU and GPU CUDA activity.
    • Activity Record. CPU and GPU activity is reported in C data structures called activity records.
    • Activity Buffer. An activity buffer is used to transfer one or more activity records from CUPTI to the client. An asynchronous buffering API is implemented by cuptiActivityRegisterCallbacks and cuptiActivityFlushAll.
  • The CUPTI Callback API allows you to register a callback into your own code. Your callback will be invoked when the application being profiled calls a CUDA runtime or driver function, or when certain events occur in the CUDA driver.
    • Callback Domain.
    • Callback ID. Each callback is given a unique ID within the corresponding callback domain so that you can identify it within your callback function.
    • Callback Function Your callback function must be of type CUpti_CallbackFunc. This function type has two arguments that specify the callback domain and ID so that you know why the callback is occurring. The type also has a cbdata argument that is used to pass data specific to the callback.
    • Subscriber. A subscriber is used to associate each of your callback functions with one or more CUDA API functions. There can be at most one subscriber initialized with cuptiSubscribe() at any time. Before initializing a new subscriber, the existing subscriber must be finalized with cuptiUnsubscribe().
  • The CUPTI Event API allows you to query, configure, start, stop, and read the event counters on a CUDA-enabled device.
  • The CUPTI Metric API allows you to collect application metrics calculated from one or more event values. The following terminology is used by the metric API.

References

Documentation

Index

Constants

View Source
const (
	BUFFER_SIZE = 32 * 1024
	ALIGN_SIZE  = 8
)

Variables

View Source
var (
	DefaultCUPTILibraryPath string
	DefaultCUDALibraryPath  string
)
View Source
var (
	Config = &cuptiConfig{
		done: make(chan struct{}),
	}
)
View Source
var DefaultActivities = []string{
	"CUPTI_ACTIVITY_KIND_MEMCPY",
	"CUPTI_ACTIVITY_KIND_MEMSET",
	"CUPTI_ACTIVITY_KIND_KERNEL",

	"CUPTI_ACTIVITY_KIND_DRIVER",
	"CUPTI_ACTIVITY_KIND_RUNTIME",
	"CUPTI_ACTIVITY_KIND_OVERHEAD",
}
View Source
var (
	DefaultCallbacks = []string{
		"CUPTI_DRIVER_TRACE_CBID_cuLaunchKernel",
		"CUPTI_DRIVER_TRACE_CBID_cuMemcpyDtoH_v2",
		"CUPTI_DRIVER_TRACE_CBID_cuMemcpyDtoHAsync_v2",
		"CUPTI_DRIVER_TRACE_CBID_cuMemcpyHtoD_v2",
		"CUPTI_DRIVER_TRACE_CBID_cuMemcpyHtoDAsync_v2",
		"CUPTI_DRIVER_TRACE_CBID_cuMemcpyDtoD_v2",
		"CUPTI_DRIVER_TRACE_CBID_cuMemcpyDtoDAsync_v2",
		"CUPTI_RUNTIME_TRACE_CBID_cudaDeviceSynchronize_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaStreamSynchronize_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaMalloc_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaMallocArray_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaMallocHost_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaHostAlloc_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaFree_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaFreeHost_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaLaunch_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaMemcpy_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaMemcpyAsync_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaSetupArgument_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaMallocManaged_v6000",
		"CUPTI_RUNTIME_TRACE_CBID_cudaMallocPitch_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaThreadSynchronize_v3020",
		"CUPTI_RUNTIME_TRACE_CBID_cudaIpcGetEventHandle_v4010",
		"CUPTI_RUNTIME_TRACE_CBID_cudaIpcOpenEventHandle_v4010",
		"CUPTI_RUNTIME_TRACE_CBID_cudaIpcGetMemHandle_v4010",
		"CUPTI_RUNTIME_TRACE_CBID_cudaIpcOpenMemHandle_v4010",
		"CUPTI_RUNTIME_TRACE_CBID_cudaIpcCloseMemHandle_v4010",
	}
)
View Source
var (
	DefaultDomains = []string{
		"CUPTI_CB_DOMAIN_RUNTIME_API",
		"CUPTI_CB_DOMAIN_DRIVER_API",
		"CUPTI_CB_DOMAIN_NVTX",
	}
)
View Source
var (
	DefaultEvents = []string{
		"CUPTI_EVENT_COLLECTION_MODE_KERNEL",
	}
)

Functions

This section is empty.

Types

type CUPTI

type CUPTI struct {
	*Options
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*CUPTI, error)

func (*CUPTI) Close

func (c *CUPTI) Close() error

func (*CUPTI) DeviceReset

func (ti *CUPTI) DeviceReset() (time.Time, error)

func (*CUPTI) SetContext

func (c *CUPTI) SetContext(ctx context.Context)

func (*CUPTI) Subscribe

func (c *CUPTI) Subscribe() error

func (*CUPTI) Unsubscribe

func (c *CUPTI) Unsubscribe() error

func (*CUPTI) Wait

func (c *CUPTI) Wait()

type Error

type Error struct {
	Code types.CUptiResult
}

func (*Error) Error

func (e *Error) Error() string

type Option

type Option func(o *Options)

func Activities

func Activities(activities []string) Option

func Callbacks

func Callbacks(callbacks []string) Option

func Context

func Context(ctx context.Context) Option

func Domains

func Domains(domains []string) Option

func Events

func Events(events []string) Option

func SamplingPeriod

func SamplingPeriod(s int) Option

type Options

type Options struct {
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions(opts ...Option) *Options

type VersionInfo

type VersionInfo struct {
	Version int
}

func Version

func Version() (VersionInfo, error)

func (VersionInfo) String

func (v VersionInfo) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL