00001
00002
00003
00004
00005
00006 #ifndef HWLOC_PLUGINS_H
00007 #define HWLOC_PLUGINS_H
00008
00013 struct hwloc_backend;
00014
00015 #include <hwloc.h>
00016 #ifdef HWLOC_INSIDE_PLUGIN
00017
00018 #include <ltdl.h>
00019 #endif
00020
00021
00022
00028 typedef enum hwloc_disc_component_type_e {
00031 HWLOC_DISC_COMPONENT_TYPE_CPU = (1<<0),
00032
00038 HWLOC_DISC_COMPONENT_TYPE_GLOBAL = (1<<1),
00039
00042 HWLOC_DISC_COMPONENT_TYPE_MISC = (1<<2)
00043 } hwloc_disc_component_type_t;
00044
00050 struct hwloc_disc_component {
00052 hwloc_disc_component_type_t type;
00053
00057 const char *name;
00058
00067 unsigned excludes;
00068
00072 struct hwloc_backend * (*instantiate)(struct hwloc_disc_component *component, const void *data1, const void *data2, const void *data3);
00073
00086 unsigned priority;
00087
00092 struct hwloc_disc_component * next;
00093 };
00094
00114 struct hwloc_backend {
00116 struct hwloc_disc_component * component;
00118 struct hwloc_topology * topology;
00120 int envvar_forced;
00122 struct hwloc_backend * next;
00123
00125 unsigned long flags;
00126
00130 int is_custom;
00131
00135 int is_thissystem;
00136
00138 void * private_data;
00142 void (*disable)(struct hwloc_backend *backend);
00143
00147 int (*discover)(struct hwloc_backend *backend);
00148
00151 int (*get_obj_cpuset)(struct hwloc_backend *backend, struct hwloc_backend *caller, struct hwloc_obj *obj, hwloc_bitmap_t cpuset);
00152
00156 int (*notify_new_object)(struct hwloc_backend *backend, struct hwloc_backend *caller, struct hwloc_obj *obj);
00157 };
00158
00160 enum hwloc_backend_flag_e {
00163 HWLOC_BACKEND_FLAG_NEED_LEVELS = (1UL<<0)
00164 };
00165
00169 HWLOC_DECLSPEC struct hwloc_backend * hwloc_backend_alloc(struct hwloc_disc_component *component);
00170
00172 HWLOC_DECLSPEC int hwloc_backend_enable(struct hwloc_topology *topology, struct hwloc_backend *backend);
00173
00179 HWLOC_DECLSPEC int hwloc_backends_get_obj_cpuset(struct hwloc_backend *caller, struct hwloc_obj *obj, hwloc_bitmap_t cpuset);
00180
00190 HWLOC_DECLSPEC int hwloc_backends_notify_new_object(struct hwloc_backend *caller, struct hwloc_obj *obj);
00191
00202 typedef enum hwloc_component_type_e {
00204 HWLOC_COMPONENT_TYPE_DISC,
00205
00207 HWLOC_COMPONENT_TYPE_XML
00208 } hwloc_component_type_t;
00209
00215 struct hwloc_component {
00217 unsigned abi;
00218
00220 hwloc_component_type_t type;
00221
00223 unsigned long flags;
00224
00226 void * data;
00227 };
00228
00258 HWLOC_DECLSPEC struct hwloc_obj *hwloc_insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj);
00259
00261 typedef void (*hwloc_report_error_t)(const char * msg, int line);
00263 HWLOC_DECLSPEC void hwloc_report_os_error(const char * msg, int line);
00265 HWLOC_DECLSPEC int hwloc_hide_errors(void);
00266
00271 HWLOC_DECLSPEC struct hwloc_obj *hwloc__insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj, hwloc_report_error_t report_error);
00272
00283 HWLOC_DECLSPEC void hwloc_insert_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, hwloc_obj_t obj);
00284
00286 static __hwloc_inline struct hwloc_obj *
00287 hwloc_alloc_setup_object(hwloc_obj_type_t type, signed os_index)
00288 {
00289 struct hwloc_obj *obj = malloc(sizeof(*obj));
00290 memset(obj, 0, sizeof(*obj));
00291 obj->type = type;
00292 obj->os_index = os_index;
00293 obj->os_level = -1;
00294 obj->attr = malloc(sizeof(*obj->attr));
00295 memset(obj->attr, 0, sizeof(*obj->attr));
00296
00297 return obj;
00298 }
00299
00306 HWLOC_DECLSPEC int hwloc_fill_object_sets(hwloc_obj_t obj);
00307
00322 static __hwloc_inline int
00323 hwloc_plugin_check_namespace(const char *pluginname __hwloc_attribute_unused, const char *symbol __hwloc_attribute_unused)
00324 {
00325 #ifdef HWLOC_INSIDE_PLUGIN
00326 lt_dlhandle handle;
00327 void *sym;
00328 handle = lt_dlopen(NULL);
00329 if (!handle)
00330
00331 return 0;
00332 sym = lt_dlsym(handle, symbol);
00333 lt_dlclose(handle);
00334 if (!sym) {
00335 static int verboseenv_checked = 0;
00336 static int verboseenv_value = 0;
00337 if (!verboseenv_checked) {
00338 char *verboseenv = getenv("HWLOC_PLUGINS_VERBOSE");
00339 verboseenv_value = verboseenv ? atoi(verboseenv) : 0;
00340 verboseenv_checked = 1;
00341 }
00342 if (verboseenv_value)
00343 fprintf(stderr, "Plugin `%s' disabling itself because it cannot find the `%s' core symbol.\n",
00344 pluginname, symbol);
00345 return -1;
00346 }
00347 #endif
00348 return 0;
00349 }
00350
00368 HWLOC_DECLSPEC int hwloc_insert_pci_device_list(struct hwloc_backend *backend, struct hwloc_obj *first_obj);
00369
00374 HWLOC_DECLSPEC unsigned hwloc_pci_find_cap(const unsigned char *config, unsigned cap);
00375
00381 HWLOC_DECLSPEC int hwloc_pci_find_linkspeed(const unsigned char *config, unsigned offset, float *linkspeed);
00382
00389 HWLOC_DECLSPEC int hwloc_pci_prepare_bridge(hwloc_obj_t obj, const unsigned char *config);
00390
00396 #endif