plugins.h
/*
* Copyright © 2013 Inria. All rights reserved.
* See COPYING in top-level directory.
*/
#ifndef HWLOC_PLUGINS_H
#define HWLOC_PLUGINS_H
struct hwloc_backend;
#include <hwloc.h>
typedef enum hwloc_disc_component_type_e {
HWLOC_DISC_COMPONENT_TYPE_CPU = (1<<0),
HWLOC_DISC_COMPONENT_TYPE_GLOBAL = (1<<1),
HWLOC_DISC_COMPONENT_TYPE_MISC = (1<<2)
} hwloc_disc_component_type_t;
struct hwloc_disc_component {
hwloc_disc_component_type_t type;
const char *name;
unsigned excludes;
struct hwloc_backend * (*instantiate)(struct hwloc_disc_component *component, const void *data1, const void *data2, const void *data3);
unsigned priority;
struct hwloc_disc_component * next;
};
struct hwloc_backend {
struct hwloc_disc_component * component;
struct hwloc_topology * topology;
int envvar_forced;
struct hwloc_backend * next;
unsigned long flags;
int is_custom;
int is_thissystem;
void * private_data;
void (*disable)(struct hwloc_backend *backend);
int (*discover)(struct hwloc_backend *backend);
int (*get_obj_cpuset)(struct hwloc_backend *backend, struct hwloc_backend *caller, struct hwloc_obj *obj, hwloc_bitmap_t cpuset);
int (*notify_new_object)(struct hwloc_backend *backend, struct hwloc_backend *caller, struct hwloc_obj *obj);
};
enum hwloc_backend_flag_e {
HWLOC_BACKEND_FLAG_NEED_LEVELS = (1UL<<0)
};
struct hwloc_backend * hwloc_backend_alloc(struct hwloc_disc_component *component);
int hwloc_backend_enable(struct hwloc_topology *topology, struct hwloc_backend *backend);
int hwloc_backends_get_obj_cpuset(struct hwloc_backend *caller, struct hwloc_obj *obj, hwloc_bitmap_t cpuset);
int hwloc_backends_notify_new_object(struct hwloc_backend *caller, struct hwloc_obj *obj);
typedef enum hwloc_component_type_e {
HWLOC_COMPONENT_TYPE_DISC,
HWLOC_COMPONENT_TYPE_XML
} hwloc_component_type_t;
struct hwloc_component {
unsigned abi;
hwloc_component_type_t type;
unsigned long flags;
void * data;
};
struct hwloc_obj *hwloc_insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj);
typedef void (*hwloc_report_error_t)(const char * msg, int line);
void hwloc_report_os_error(const char * msg, int line);
int hwloc_hide_errors(void);
struct hwloc_obj *hwloc__insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj, hwloc_report_error_t report_error);
void hwloc_insert_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, hwloc_obj_t obj);
static inline struct hwloc_obj *
hwloc_alloc_setup_object(hwloc_obj_type_t type, signed os_index)
{
struct hwloc_obj *obj = malloc(sizeof(*obj));
memset(obj, 0, sizeof(*obj));
obj->type = type;
obj->os_index = os_index;
obj->os_level = -1;
obj->attr = malloc(sizeof(*obj->attr));
memset(obj->attr, 0, sizeof(*obj->attr));
/* do not allocate the cpuset here, let the caller do it */
return obj;
}
#endif /* HWLOC_PLUGINS_H */