-
Notifications
You must be signed in to change notification settings - Fork 4
/
subscribe.go
48 lines (39 loc) · 941 Bytes
/
subscribe.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// +build linux,cgo,!nogpu
package cupti
/*
#include <cupti.h>
extern void CUPTIAPI callback(void *userdata, CUpti_CallbackDomain domain,
CUpti_CallbackId cbid,
const void *cbInfo);
*/
import "C"
import "unsafe"
type callbackFunction func(userData unsafe.Pointer, domain0 C.CUpti_CallbackDomain, cbid0 C.CUpti_CallbackId, cbInfo unsafe.Pointer)
func cuptiEnableDomain() {
}
func (c *CUPTI) cuptiSubscribe() error {
var subscriber C.CUpti_SubscriberHandle
err := checkCUPTIError(
C.cuptiSubscribe(
&subscriber,
(C.CUpti_CallbackFunc)(unsafe.Pointer(C.callback)),
unsafe.Pointer(c),
),
)
if err != nil {
return err
}
c.subscriber = subscriber
return nil
}
func (c *CUPTI) cuptiUnsubscribe() error {
if c.subscriber == nil {
return nil
}
err := checkCUPTIError(C.cuptiUnsubscribe(c.subscriber))
if err != nil {
return err
}
c.subscriber = nil
return nil
}