libtopo/topop.h
2022-06-10 19:29:01 +08:00

34 lines
782 B
C

#pragma once
#include <stdint.h>
#include <pthread.h>
#define TOPO_MAX_CHILDREN (256)
#define ALLOC_MAX_OBJS_PER_LVL (256)
#define ALLOC_MEM_OBJ_SIZE (4096) // 4k
#define ALLOC_MEM_OBJ_NUM (1024 * 256) // 4k * 1024 * 256 = 1GB per region
#define ALLOC_MEM_REGION_NUM (4) // 4 x 1GB = 4GB total
struct topo_desc {
struct topo_obj * root;
int core_to_numa_lookup[TOPO_MAX_CHILDREN];
int num_core;
int num_numa;
// ts
uint64_t tsc_freq;
// alloc
pthread_mutex_t alloc_lock;
int mem_idx[ALLOC_MAX_OBJS_PER_LVL];
int mem_region_idx[ALLOC_MAX_OBJS_PER_LVL];
void* mem_regions[ALLOC_MAX_OBJS_PER_LVL][ALLOC_MEM_REGION_NUM];
};
int
topo_ts_init(struct topo_desc *desc, int verbose);
uint64_t
topo_desc_uptime_ns(struct topo_desc * desc);