File: prof_protocol.h

package info (click to toggle)
rocm-hipamd 6.4.3-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 23,036 kB
  • sloc: cpp: 211,057; ansic: 35,860; sh: 755; python: 623; perl: 275; asm: 166; makefile: 27
file content (93 lines) | stat: -rw-r--r-- 3,766 bytes parent folder | download | duplicates (4)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* Copyright (c) 2018 - 2021 Advanced Micro Devices, Inc.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE. */

#ifndef INC_EXT_PROF_PROTOCOL_H_
#define INC_EXT_PROF_PROTOCOL_H_

#include <stdint.h>

// Traced API domains
typedef enum {
  ACTIVITY_DOMAIN_HSA_API = 0,                    // HSA API domain
  ACTIVITY_DOMAIN_HSA_OPS = 1,                    // HSA async activity domain
  ACTIVITY_DOMAIN_HIP_OPS = 2,                    // HIP async activity domain
  ACTIVITY_DOMAIN_HCC_OPS = ACTIVITY_DOMAIN_HIP_OPS, // HCC async activity domain
  ACTIVITY_DOMAIN_HIP_VDI = ACTIVITY_DOMAIN_HIP_OPS, // HIP VDI domain
  ACTIVITY_DOMAIN_HIP_API = 3,                    // HIP API domain
  ACTIVITY_DOMAIN_KFD_API = 4,                    // KFD API domain
  ACTIVITY_DOMAIN_EXT_API = 5,                    // External ID domain
  ACTIVITY_DOMAIN_ROCTX   = 6,                    // ROCTX domain
  ACTIVITY_DOMAIN_NUMBER
} activity_domain_t;

// Extension API opcodes
typedef enum {
  ACTIVITY_EXT_OP_MARK = 0,
  ACTIVITY_EXT_OP_EXTERN_ID = 1
} activity_ext_op_t;

// API callback type
typedef void (*activity_rtapi_callback_t)(uint32_t domain, uint32_t cid, const void* data, void* arg);
typedef uint32_t activity_kind_t;
typedef uint32_t activity_op_t;

// API callback phase
typedef enum {
  ACTIVITY_API_PHASE_ENTER = 0,
  ACTIVITY_API_PHASE_EXIT = 1
} activity_api_phase_t;

// Trace record types
// Correlation id
typedef uint64_t activity_correlation_id_t;

// Activity record type
struct activity_record_t {
    uint32_t domain;                               // activity domain id
    activity_kind_t kind;                          // activity kind
    activity_op_t op;                              // activity op
    activity_correlation_id_t correlation_id;      // activity ID
    uint64_t begin_ns;                             // host begin timestamp
    uint64_t end_ns;                               // host end timestamp
    union {
      struct {
        int device_id;                             // device id
        uint64_t queue_id;                         // queue id
      };
      struct {
        uint32_t process_id;                       // device id
        uint32_t thread_id;                        // thread id
      };
      struct {
        activity_correlation_id_t external_id;     // external correlatino id
      };
    };
  union {
    size_t bytes;                                  // data size bytes
    const char* kernel_name;
  };
};

// Activity sync calback type
typedef void (*activity_sync_callback_t)(uint32_t cid, activity_record_t* record, const void* data, void* arg);
// Activity async calback type
typedef void (*activity_async_callback_t)(uint32_t op, activity_record_t* record, void* arg);

#endif  // INC_EXT_PROF_PROTOCOL_H_