1 /** TODO: copyright notice */
2
3 #include "config.h"
4
5 #include "slurm/slurm.h"
6
7 #include "src/common/layouts_mgr.h"
8 #include "src/common/entity.h"
9 #include "src/common/log.h"
10
11 const char plugin_name[] = "Power layouts plugin";
12 const char plugin_type[] = "layouts/power";
13 const uint32_t plugin_version = SLURM_VERSION_NUMBER;
14
15 /* specific options for power tests layout */
16 s_p_options_t entity_options[] = {
17 /* base keys */
18 {"CurrentPower", S_P_UINT32},
19 {"IdleWatts", S_P_UINT32},
20 {"MaxWatts", S_P_UINT32},
21 {"DownWatts",S_P_UINT32},
22 {"PowerSaveWatts",S_P_UINT32},
23 /* parents aggregated keys */
24 {"CurrentSumPower", S_P_UINT32},
25 {"IdleSumWatts", S_P_UINT32},
26 {"MaxSumWatts", S_P_UINT32},
27 {NULL}
28 };
29 s_p_options_t options[] = {
30 {"Entity", S_P_EXPLINE, NULL, NULL, entity_options},
31 {NULL}
32 };
33
34 const layouts_keyspec_t keyspec[] = {
35 /* base keys */
36 {"CurrentPower", L_T_UINT32},
37 {"IdleWatts", L_T_UINT32},
38 {"MaxWatts", L_T_UINT32},
39 {"DownWatts",L_T_UINT32},
40 {"PowerSaveWatts",L_T_UINT32},
41 {"NumFreqChoices",L_T_UINT32},
42 /* parents aggregated keys */
43 {"CurrentSumPower", L_T_UINT32,
44 KEYSPEC_UPDATE_CHILDREN_SUM, "CurrentPower"},
45 {"IdleSumWatts", L_T_UINT32,
46 KEYSPEC_UPDATE_CHILDREN_SUM, "IdleWatts"},
47 {"MaxSumWatts", L_T_UINT32,
48 KEYSPEC_UPDATE_CHILDREN_SUM, "MaxWatts"},
49 {NULL}
50
51 };
52
53 /* types allowed in the entity's "type" field */
54 const char* etypes[] = {
55 "Center",
56 "Node",
57 NULL
58 };
59
60 const layouts_plugin_spec_t plugin_spec = {
61 options,
62 keyspec,
63 LAYOUT_STRUCT_TREE,
64 etypes,
65 true, /* if this evalued to true, keys inside plugin_keyspec present in
66 * plugin_options having corresponding types, are automatically
67 * handled by the layouts manager.
68 */
69 true /* if this evalued to true, keys updates trigger an automatic
70 * update of their entities neighborhoods based on their
71 * KEYSPEC_UPDATE_* set flags
72 */
73 };
74
75 /* manager is lock when this function is called */
76 /* disable this callback by setting it to NULL, warn: not every callback can
77 * be desactivated this way */
layouts_p_conf_done(xhash_t * entities,layout_t * layout,s_p_hashtbl_t * tbl)78 int layouts_p_conf_done(
79 xhash_t* entities, layout_t* layout, s_p_hashtbl_t* tbl)
80 {
81 return 1;
82 }
83
84
85 /* disable this callback by setting it to NULL, warn: not every callback can
86 * be desactivated this way */
layouts_p_entity_parsing(entity_t * e,s_p_hashtbl_t * etbl,layout_t * layout)87 void layouts_p_entity_parsing(
88 entity_t* e, s_p_hashtbl_t* etbl, layout_t* layout)
89 {
90 }
91
92 /* manager is lock then this function is called */
93 /* disable this callback by setting it to NULL, warn: not every callback can
94 * be desactivated this way */
layouts_p_update_done(layout_t * layout,entity_t ** e_array,int e_cnt)95 int layouts_p_update_done(layout_t* layout, entity_t** e_array, int e_cnt)
96 {
97 int i;
98 debug3("layouts/power: receiving update callback for %d entities",
99 e_cnt);
100 for (i = 0; i < e_cnt; i++) {
101 if (e_array[i] == NULL) {
102 debug3("layouts/power: skipping update of nullified"
103 "entity[%d]", i);
104 } else {
105 debug3("layouts/power: updating entity[%d]=%s",
106 i, e_array[i]->name);
107 }
108 }
109 return 1;
110 }
111
init(void)112 int init(void)
113 {
114 return SLURM_SUCCESS;
115 }
116
fini(void)117 int fini(void)
118 {
119 return SLURM_SUCCESS;
120 }
121