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
00236 int (*init)(unsigned long flags);
00237
00249 void (*finalize)(unsigned long flags);
00250
00252 hwloc_component_type_t type;
00253
00255 unsigned long flags;
00256
00258 void * data;
00259 };
00260
00290 HWLOC_DECLSPEC struct hwloc_obj *hwloc_insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj);
00291
00293 typedef void (*hwloc_report_error_t)(const char * msg, int line);
00295 HWLOC_DECLSPEC void hwloc_report_os_error(const char * msg, int line);
00297 HWLOC_DECLSPEC int hwloc_hide_errors(void);
00298
00303 HWLOC_DECLSPEC struct hwloc_obj *hwloc__insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj, hwloc_report_error_t report_error);
00304
00319 HWLOC_DECLSPEC void hwloc_insert_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, hwloc_obj_t obj);
00320
00322 static __hwloc_inline struct hwloc_obj *
00323 hwloc_alloc_setup_object(hwloc_obj_type_t type, signed os_index)
00324 {
00325 struct hwloc_obj *obj = malloc(sizeof(*obj));
00326 memset(obj, 0, sizeof(*obj));
00327 obj->type = type;
00328 obj->os_index = os_index;
00329 obj->os_level = -1;
00330 obj->attr = malloc(sizeof(*obj->attr));
00331 memset(obj->attr, 0, sizeof(*obj->attr));
00332
00333 return obj;
00334 }
00335
00342 HWLOC_DECLSPEC int hwloc_fill_object_sets(hwloc_obj_t obj);
00343
00365 static __hwloc_inline int
00366 hwloc_plugin_check_namespace(const char *pluginname __hwloc_attribute_unused, const char *symbol __hwloc_attribute_unused)
00367 {
00368 #ifdef HWLOC_INSIDE_PLUGIN
00369 lt_dlhandle handle;
00370 void *sym;
00371 handle = lt_dlopen(NULL);
00372 if (!handle)
00373
00374 return 0;
00375 sym = lt_dlsym(handle, symbol);
00376 lt_dlclose(handle);
00377 if (!sym) {
00378 static int verboseenv_checked = 0;
00379 static int verboseenv_value = 0;
00380 if (!verboseenv_checked) {
00381 const char *verboseenv = getenv("HWLOC_PLUGINS_VERBOSE");
00382 verboseenv_value = verboseenv ? atoi(verboseenv) : 0;
00383 verboseenv_checked = 1;
00384 }
00385 if (verboseenv_value)
00386 fprintf(stderr, "Plugin `%s' disabling itself because it cannot find the `%s' core symbol.\n",
00387 pluginname, symbol);
00388 return -1;
00389 }
00390 #endif
00391 return 0;
00392 }
00393
00411 HWLOC_DECLSPEC int hwloc_insert_pci_device_list(struct hwloc_backend *backend, struct hwloc_obj *first_obj);
00412
00417 HWLOC_DECLSPEC unsigned hwloc_pci_find_cap(const unsigned char *config, unsigned cap);
00418
00424 HWLOC_DECLSPEC int hwloc_pci_find_linkspeed(const unsigned char *config, unsigned offset, float *linkspeed);
00425
00432 HWLOC_DECLSPEC int hwloc_pci_prepare_bridge(hwloc_obj_t obj, const unsigned char *config);
00433
00439 #endif