Hardware Locality (hwloc)  1.11.12
plugins.h
1 /*
2  * Copyright © 2013-2015 Inria. All rights reserved.
3  * See COPYING in top-level directory.
4  */
5 
6 #ifndef HWLOC_PLUGINS_H
7 #define HWLOC_PLUGINS_H
8 
13 struct hwloc_backend;
14 
15 #include <hwloc.h>
16 #ifdef HWLOC_INSIDE_PLUGIN
17 /* needed for hwloc_plugin_check_namespace() */
18 #include <ltdl.h>
19 #endif
20 
21 
22 
32 
39 
44 
53 
57  const char *name;
58 
67  unsigned excludes;
68 
72  struct hwloc_backend * (*instantiate)(struct hwloc_disc_component *component, const void *data1, const void *data2, const void *data3);
73 
86  unsigned priority;
87 
92  struct hwloc_disc_component * next;
93 };
94 
116  struct hwloc_disc_component * component;
118  struct hwloc_topology * topology;
120  int envvar_forced;
122  struct hwloc_backend * next;
123 
125  unsigned long flags;
126 
131 
136 
138  void * private_data;
142  void (*disable)(struct hwloc_backend *backend);
143 
147  int (*discover)(struct hwloc_backend *backend);
148 
151  int (*get_obj_cpuset)(struct hwloc_backend *backend, struct hwloc_backend *caller, struct hwloc_obj *obj, hwloc_bitmap_t cpuset);
152 
156  int (*notify_new_object)(struct hwloc_backend *backend, struct hwloc_backend *caller, struct hwloc_obj *obj);
157 };
158 
164 };
165 
169 HWLOC_DECLSPEC struct hwloc_backend * hwloc_backend_alloc(struct hwloc_disc_component *component);
170 
172 HWLOC_DECLSPEC int hwloc_backend_enable(struct hwloc_topology *topology, struct hwloc_backend *backend);
173 
179 HWLOC_DECLSPEC int hwloc_backends_get_obj_cpuset(struct hwloc_backend *caller, struct hwloc_obj *obj, hwloc_bitmap_t cpuset);
180 
190 HWLOC_DECLSPEC int hwloc_backends_notify_new_object(struct hwloc_backend *caller, struct hwloc_obj *obj);
191 
205 
209 
217  unsigned abi;
218 
236  int (*init)(unsigned long flags);
237 
249  void (*finalize)(unsigned long flags);
250 
253 
255  unsigned long flags;
256 
258  void * data;
259 };
260 
290 HWLOC_DECLSPEC struct hwloc_obj *hwloc_insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj);
291 
293 typedef void (*hwloc_report_error_t)(const char * msg, int line);
295 HWLOC_DECLSPEC void hwloc_report_os_error(const char * msg, int line);
297 HWLOC_DECLSPEC int hwloc_hide_errors(void);
298 
303 HWLOC_DECLSPEC struct hwloc_obj *hwloc__insert_object_by_cpuset(struct hwloc_topology *topology, hwloc_obj_t obj, hwloc_report_error_t report_error);
304 
319 HWLOC_DECLSPEC void hwloc_insert_object_by_parent(struct hwloc_topology *topology, hwloc_obj_t parent, hwloc_obj_t obj);
320 
322 static __hwloc_inline struct hwloc_obj *
324 {
325  struct hwloc_obj *obj = malloc(sizeof(*obj));
326  memset(obj, 0, sizeof(*obj));
327  obj->type = type;
328  obj->os_index = os_index;
329  obj->os_level = -1;
330  obj->attr = malloc(sizeof(*obj->attr));
331  memset(obj->attr, 0, sizeof(*obj->attr));
332  /* do not allocate the cpuset here, let the caller do it */
333  return obj;
334 }
335 
342 HWLOC_DECLSPEC int hwloc_fill_object_sets(hwloc_obj_t obj);
343 
365 static __hwloc_inline int
366 hwloc_plugin_check_namespace(const char *pluginname __hwloc_attribute_unused, const char *symbol __hwloc_attribute_unused)
367 {
368 #ifdef HWLOC_INSIDE_PLUGIN
369  lt_dlhandle handle;
370  void *sym;
371  handle = lt_dlopen(NULL);
372  if (!handle)
373  /* cannot check, assume things will work */
374  return 0;
375  sym = lt_dlsym(handle, symbol);
376  lt_dlclose(handle);
377  if (!sym) {
378  static int verboseenv_checked = 0;
379  static int verboseenv_value = 0;
380  if (!verboseenv_checked) {
381  const char *verboseenv = getenv("HWLOC_PLUGINS_VERBOSE");
382  verboseenv_value = verboseenv ? atoi(verboseenv) : 0;
383  verboseenv_checked = 1;
384  }
385  if (verboseenv_value)
386  fprintf(stderr, "Plugin `%s' disabling itself because it cannot find the `%s' core symbol.\n",
387  pluginname, symbol);
388  return -1;
389  }
390 #endif /* HWLOC_INSIDE_PLUGIN */
391  return 0;
392 }
393 
411 HWLOC_DECLSPEC int hwloc_insert_pci_device_list(struct hwloc_backend *backend, struct hwloc_obj *first_obj);
412 
417 HWLOC_DECLSPEC unsigned hwloc_pci_find_cap(const unsigned char *config, unsigned cap);
418 
424 HWLOC_DECLSPEC int hwloc_pci_find_linkspeed(const unsigned char *config, unsigned offset, float *linkspeed);
425 
432 HWLOC_DECLSPEC int hwloc_pci_prepare_bridge(hwloc_obj_t obj, const unsigned char *config);
433 
439 #endif /* HWLOC_PLUGINS_H */