00001
00002
00003
00004
00005
00006
00007 #ifndef HWLOC_PLUGINS_H
00008 #define HWLOC_PLUGINS_H
00009
00014 struct hwloc_backend;
00015
00016 #include <hwloc.h>
00017 #ifdef HWLOC_INSIDE_PLUGIN
00018
00019 #include <ltdl.h>
00020 #endif
00021
00022
00023
00029 typedef enum hwloc_disc_component_type_e {
00032 HWLOC_DISC_COMPONENT_TYPE_CPU = (1<<0),
00033
00039 HWLOC_DISC_COMPONENT_TYPE_GLOBAL = (1<<1),
00040
00043 HWLOC_DISC_COMPONENT_TYPE_MISC = (1<<2)
00044 } hwloc_disc_component_type_t;
00045
00051 struct hwloc_disc_component {
00053 hwloc_disc_component_type_t type;
00054
00058 const char *name;
00059
00068 unsigned excludes;
00069
00073 struct hwloc_backend * (*instantiate)(struct hwloc_disc_component *component, const void *data1, const void *data2, const void *data3);
00074
00087 unsigned priority;
00088
00092 unsigned enabled_by_default;
00093
00098 struct hwloc_disc_component * next;
00099 };
00100
00120 struct hwloc_backend {
00122 struct hwloc_disc_component * component;
00124 struct hwloc_topology * topology;
00126 int envvar_forced;
00128 struct hwloc_backend * next;
00129
00131 unsigned long flags;
00132
00136 int is_thissystem;
00137
00139 void * private_data;
00143 void (*disable)(struct hwloc_backend *backend);
00144
00150 int (*discover)(struct hwloc_backend *backend);
00151
00154 int (*get_pci_busid_cpuset)(struct hwloc_backend *backend, struct hwloc_pcidev_attr_s *busid, hwloc_bitmap_t cpuset);
00155 };
00156
00160 HWLOC_DECLSPEC struct hwloc_backend * hwloc_backend_alloc(struct hwloc_disc_component *component);
00161
00163 HWLOC_DECLSPEC int hwloc_backend_enable(struct hwloc_topology *topology, struct hwloc_backend *backend);
00164
00175 typedef enum hwloc_component_type_e {
00177 HWLOC_COMPONENT_TYPE_DISC,
00178
00180 HWLOC_COMPONENT_TYPE_XML
00181 } hwloc_component_type_t;
00182
00188 struct hwloc_component {
00190 unsigned abi;
00191
00209 int (*init)(unsigned long flags);
00210
00222 void (*finalize)(unsigned long flags);
00223
00225 hwloc_component_type_t type;
00226
00228 unsigned long flags;
00229
00231 void * data;
00232 };
00233
00267 HWLOC_DECLSPEC struct hwloc_obj *hwloc_insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj);
00268
00270 typedef void (*hwloc_report_error_t)(const char * msg, int line);
00272 HWLOC_DECLSPEC void hwloc_report_os_error(const char * msg, int line);
00274 HWLOC_DECLSPEC int hwloc_hide_errors(void);
00275
00282 HWLOC_DECLSPEC struct hwloc_obj *hwloc__insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t root, hwloc_obj_t obj, hwloc_report_error_t report_error);
00283
00300 HWLOC_DECLSPEC void hwloc_insert_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, hwloc_obj_t obj);
00301
00306 HWLOC_DECLSPEC hwloc_obj_t hwloc_alloc_setup_object(hwloc_topology_t topology, hwloc_obj_type_t type, unsigned os_index);
00307
00316 HWLOC_DECLSPEC int hwloc_obj_add_children_sets(hwloc_obj_t obj);
00317
00325 HWLOC_DECLSPEC int hwloc_topology_reconnect(hwloc_topology_t topology, unsigned long flags __hwloc_attribute_unused);
00326
00348 static __hwloc_inline int
00349 hwloc_plugin_check_namespace(const char *pluginname __hwloc_attribute_unused, const char *symbol __hwloc_attribute_unused)
00350 {
00351 #ifdef HWLOC_INSIDE_PLUGIN
00352 lt_dlhandle handle;
00353 void *sym;
00354 handle = lt_dlopen(NULL);
00355 if (!handle)
00356
00357 return 0;
00358 sym = lt_dlsym(handle, symbol);
00359 lt_dlclose(handle);
00360 if (!sym) {
00361 static int verboseenv_checked = 0;
00362 static int verboseenv_value = 0;
00363 if (!verboseenv_checked) {
00364 const char *verboseenv = getenv("HWLOC_PLUGINS_VERBOSE");
00365 verboseenv_value = verboseenv ? atoi(verboseenv) : 0;
00366 verboseenv_checked = 1;
00367 }
00368 if (verboseenv_value)
00369 fprintf(stderr, "Plugin `%s' disabling itself because it cannot find the `%s' core symbol.\n",
00370 pluginname, symbol);
00371 return -1;
00372 }
00373 #endif
00374 return 0;
00375 }
00376
00390 static __hwloc_inline int
00391 hwloc_filter_check_pcidev_subtype_important(unsigned classid)
00392 {
00393 unsigned baseclass = classid >> 8;
00394 return (baseclass == 0x03
00395 || baseclass == 0x02
00396 || baseclass == 0x01
00397 || baseclass == 0x0b
00398 || classid == 0x0c04
00399 || classid == 0x0c06
00400 || baseclass == 0x12 );
00401 }
00402
00407 static __hwloc_inline int
00408 hwloc_filter_check_osdev_subtype_important(hwloc_obj_osdev_type_t subtype)
00409 {
00410 return (subtype != HWLOC_OBJ_OSDEV_DMA);
00411 }
00412
00419 static __hwloc_inline int
00420 hwloc_filter_check_keep_object_type(hwloc_topology_t topology, hwloc_obj_type_t type)
00421 {
00422 enum hwloc_type_filter_e filter = HWLOC_TYPE_FILTER_KEEP_NONE;
00423 hwloc_topology_get_type_filter(topology, type, &filter);
00424 assert(filter != HWLOC_TYPE_FILTER_KEEP_IMPORTANT);
00425 return filter == HWLOC_TYPE_FILTER_KEEP_NONE ? 0 : 1;
00426 }
00427
00432 static __hwloc_inline int
00433 hwloc_filter_check_keep_object(hwloc_topology_t topology, hwloc_obj_t obj)
00434 {
00435 hwloc_obj_type_t type = obj->type;
00436 enum hwloc_type_filter_e filter = HWLOC_TYPE_FILTER_KEEP_NONE;
00437 hwloc_topology_get_type_filter(topology, type, &filter);
00438 if (filter == HWLOC_TYPE_FILTER_KEEP_NONE)
00439 return 0;
00440 if (filter == HWLOC_TYPE_FILTER_KEEP_IMPORTANT) {
00441 if (type == HWLOC_OBJ_PCI_DEVICE)
00442 return hwloc_filter_check_pcidev_subtype_important(obj->attr->pcidev.class_id);
00443 if (type == HWLOC_OBJ_OS_DEVICE)
00444 return hwloc_filter_check_osdev_subtype_important(obj->attr->osdev.type);
00445 }
00446 return 1;
00447 }
00448
00462 HWLOC_DECLSPEC unsigned hwloc_pcidisc_find_cap(const unsigned char *config, unsigned cap);
00463
00469 HWLOC_DECLSPEC int hwloc_pcidisc_find_linkspeed(const unsigned char *config, unsigned offset, float *linkspeed);
00470
00475 HWLOC_DECLSPEC hwloc_obj_type_t hwloc_pcidisc_check_bridge_type(unsigned device_class, const unsigned char *config);
00476
00483 HWLOC_DECLSPEC int hwloc_pcidisc_setup_bridge_attr(hwloc_obj_t obj, const unsigned char *config);
00484
00489 HWLOC_DECLSPEC void hwloc_pcidisc_tree_insert_by_busid(struct hwloc_obj **treep, struct hwloc_obj *obj);
00490
00499 HWLOC_DECLSPEC int hwloc_pcidisc_tree_attach(struct hwloc_topology *topology, struct hwloc_obj *tree);
00500
00523 HWLOC_DECLSPEC struct hwloc_obj * hwloc_pcidisc_find_by_busid(struct hwloc_topology *topology, unsigned domain, unsigned bus, unsigned dev, unsigned func);
00524
00535 HWLOC_DECLSPEC struct hwloc_obj * hwloc_pcidisc_find_busid_parent(struct hwloc_topology *topology, unsigned domain, unsigned bus, unsigned dev, unsigned func);
00536
00542 #endif