Welcome to mirror list, hosted at ThFree Co, Russian Federation.

amdgpu_plugin_topology.h « amdgpu « plugins - github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9d99cda1c2cf2d31906b1143a19ac61688031e8c (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef __KFD_PLUGIN_TOPOLOGY_H__
#define __KFD_PLUGIN_TOPOLOGY_H__

#define DRM_FIRST_RENDER_NODE 128
#define DRM_LAST_RENDER_NODE  255

#define TOPO_HEAP_TYPE_PUBLIC  1 /* HSA_HEAPTYPE_FRAME_BUFFER_PUBLIC */
#define TOPO_HEAP_TYPE_PRIVATE 2 /* HSA_HEAPTYPE_FRAME_BUFFER_PRIVATE */

#define TOPO_IOLINK_TYPE_ANY  0	 /* HSA_IOLINKTYPE_UNDEFINED */
#define TOPO_IOLINK_TYPE_PCIE 2	 /* HSA_IOLINKTYPE_PCIEXPRESS */
#define TOPO_IOLINK_TYPE_XGMI 11 /* HSA_IOLINK_TYPE_XGMI */

#define NODE_IS_GPU(node) ((node)->gpu_id != 0)
#define INVALID_CPU_ID	  0xFFFF

/*************************************** Structures ***********************************************/
struct tp_node;

struct tp_iolink {
	struct list_head listm;
	uint32_t type;
	uint32_t node_to_id;
	struct tp_node *node_to;
	struct tp_node *node_from;
	bool valid;		/* Set to false if target node is not accessible */
	struct tp_iolink *peer; /* If link is bi-directional, peer link */
};

struct tp_node {
	uint32_t id;
	uint32_t gpu_id;
	uint32_t cpu_cores_count;
	uint32_t simd_count;
	uint32_t mem_banks_count;
	uint32_t caches_count;
	uint32_t io_links_count;
	uint32_t max_waves_per_simd;
	uint32_t lds_size_in_kb;
	uint32_t num_gws;
	uint32_t wave_front_size;
	uint32_t array_count;
	uint32_t simd_arrays_per_engine;
	uint32_t cu_per_simd_array;
	uint32_t simd_per_cu;
	uint32_t max_slots_scratch_cu;
	uint32_t vendor_id;
	uint32_t device_id;
	uint32_t domain;
	uint32_t drm_render_minor;
	uint64_t hive_id;
	uint32_t num_sdma_engines;
	uint32_t num_sdma_xgmi_engines;
	uint32_t num_sdma_queues_per_engine;
	uint32_t num_cp_queues;
	uint32_t fw_version;
	uint32_t capability;
	uint32_t sdma_fw_version;
	bool vram_public;
	uint64_t vram_size;

	struct list_head listm_system;
	struct list_head listm_p2pgroup;
	struct list_head listm_mapping; /* Used only during device mapping */

	uint32_t num_valid_iolinks;
	struct list_head iolinks;

	int drm_fd;
};

struct tp_p2pgroup {
	uint32_t type;
	uint32_t num_nodes;
	struct list_head listm_system;
	struct list_head nodes;
};

struct tp_system {
	bool parsed;
	uint32_t num_nodes;
	struct list_head nodes;
	uint32_t num_xgmi_groups;
	struct list_head xgmi_groups;
};

struct id_map {
	uint32_t src;
	uint32_t dest;

	struct list_head listm;
};

struct device_maps {
	struct list_head cpu_maps; /* CPUs are mapped using node_id */
	struct list_head gpu_maps;

	struct list_head *tail_cpu; /* GPUs are mapped using gpu_id */
	struct list_head *tail_gpu;
};

/**************************************** Functions ***********************************************/
void topology_init(struct tp_system *sys);
void topology_free(struct tp_system *topology);

int topology_parse(struct tp_system *topology, const char *msg);
int topology_determine_iolinks(struct tp_system *sys);
void topology_print(const struct tp_system *sys, const char *msg);

struct id_map *maps_add_gpu_entry(struct device_maps *maps, const uint32_t src_id, const uint32_t dest_id);

struct tp_node *sys_add_node(struct tp_system *sys, uint32_t id, uint32_t gpu_id);
struct tp_iolink *node_add_iolink(struct tp_node *node, uint32_t type, uint32_t node_to_id);

struct tp_node *sys_get_node_by_gpu_id(const struct tp_system *sys, const uint32_t gpu_id);
struct tp_node *sys_get_node_by_render_minor(const struct tp_system *sys, const int drm_render_minor);
struct tp_node *sys_get_node_by_index(const struct tp_system *sys, uint32_t index);

int node_get_drm_render_device(struct tp_node *node);
void sys_close_drm_render_devices(struct tp_system *sys);

int set_restore_gpu_maps(struct tp_system *tp_checkpoint, struct tp_system *tp_local, struct device_maps *maps);

uint32_t maps_get_dest_gpu(const struct device_maps *maps, const uint32_t src_id);

void maps_init(struct device_maps *maps);
void maps_free(struct device_maps *maps);

#endif /* __KFD_PLUGIN_TOPOLOGY_H__ */