ugly hack for power9

This commit is contained in:
quackerd 2022-12-14 11:17:54 +01:00
parent 5e83406f81
commit 08887f9248
2 changed files with 29 additions and 1 deletions

View File

@ -2,21 +2,23 @@
#ifdef __amd64__
#include <immintrin.h>
#include <x86intrin.h>
#include <sys/sysctl.h>
#endif
#include <errno.h>
#include <sys/sysctl.h>
#include "topo.h"
#include "topop.h"
#define S2NS (1000000000UL)
#ifdef __amd64__
static uint64_t
tsc2ns(uint64_t tsc, uint64_t tsc_freq)
{
return (uint64_t)(
(double)tsc / (double)tsc_freq * S2NS);
}
#endif
int
topo_ts_init(struct topo_desc * desc, int verbose)
@ -37,6 +39,8 @@ topo_ts_init(struct topo_desc * desc, int verbose)
return rc;
#else
(void)desc;
(void)verbose;
return 0;
#endif
}
@ -51,6 +55,7 @@ topo_desc_uptime_ns(struct topo_desc * desc)
_mm_lfence();
return tsc2ns(tsc, desc->tsc_freq);
#else
(void)desc;
struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp);
return ((uint64_t)tp.tv_sec * S2NS + (uint64_t)tp.tv_nsec);

23
topo.c
View File

@ -292,6 +292,7 @@ tobj_find_node_by_mask(struct topo_obj * root, cpuset_t * set)
return best_fit == NULL ? root : best_fit;
}
__attribute__((unused))
static struct topo_obj *
tobj_find_node_by_flag(struct topo_obj * root, int flag)
{
@ -412,6 +413,7 @@ desc_init(struct topo_desc * desc, int verbose)
//
// public APIs
//
#ifdef __amd64__
int
topo_num_core(void)
{
@ -430,6 +432,27 @@ topo_core_to_numa(int coreid)
return g_default_desc.core_to_numa_lookup[coreid];
}
#else
int
topo_num_core(void)
{
return 176;
}
int
topo_num_numa(void)
{
return 2;
}
int
topo_core_to_numa(int coreid)
{
return coreid >= 88;
}
#endif
void
topo_destroy(void)
{