EM-ODP
4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
event_machine_config.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012, Nokia Siemens Networks
3
* Copyright (c) 2015-2025, Nokia Solutions and Networks
4
* All rights reserved.
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
8
* are met:
9
*
10
* * Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* * Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
* * Neither the name of the copyright holder nor the names of its
16
* contributors may be used to endorse or promote products derived
17
* from this software without specific prior written permission.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32
/**
33
* @file
34
*
35
* Event Machine configuration options
36
*/
37
38
#ifndef EVENT_MACHINE_CONFIG_H
39
#define EVENT_MACHINE_CONFIG_H
40
41
#pragma GCC visibility push(default)
42
43
#ifdef __cplusplus
44
extern
"C"
{
45
#endif
46
47
#ifdef EM_64_BIT
48
/**
49
* @page page_version 64-bit version
50
* This documentation represent the 64-bit version of Event Machine API.
51
* Define EM_64_BIT or EM_32_BIT to select between 64- and 32-bit versions.
52
*/
53
#elif defined(EM_32_BIT)
54
/**
55
* @page page_version 32-bit version
56
* This documentation represent the 32-bit version of Event Machine API.
57
* Define EM_64_BIT or EM_32_BIT to select between 64- and 32-bit versions.
58
*/
59
#else
60
#error Missing architecture definition. Define EM_64_BIT or EM_32_BIT!
61
/**
62
* @page page_version 64/32-bit version not selected
63
* This documentation has not selected between 64/32-bit version of
64
* the Event Machine API. Some types might be missing.
65
* Define EM_64_BIT or EM_32_BIT to select between 64- and 32-bit
66
* versions.
67
*/
68
#endif
69
70
/**
71
* Support C++ static casts in EM API files
72
*/
73
#ifndef __cplusplus
74
#define EM_STATIC_CAST(type, value) ((type)(value))
75
#else
76
#define EM_STATIC_CAST(type, value) (static_cast < type > (value))
77
#endif
78
79
/**
80
* Support C++ reinterpret casts in EM API files
81
*/
82
#ifndef __cplusplus
83
#define EM_REINTERPRET_CAST(type, value) ((type)(value))
84
#else
85
#define EM_REINTERPRET_CAST(type, value) (reinterpret_cast < type > (value))
86
#endif
87
88
/**
89
* Compile-time upper limit for the maximum number of EM-cores.
90
*
91
* Sets the maximum number of EM-cores that can be requested to be supported by
92
* EM at startup, i.e. sets a limit for the em_conf_t::core_count parameter.
93
* This is a compile time upper limit for the number of EM-cores of type
94
* EM_CORE_TYPE_WORKER or EM_CORE_TYPE_CONTROL.
95
*/
96
#ifndef EM_MAX_CORES
97
#define EM_MAX_CORES 64
98
#endif
99
100
/**
101
* Max number of EM external threads/processes supported,
102
* i.e. EM external threads/processes of type EM_CORE_TYPE_EXTERNAL.
103
*/
104
#ifndef EM_MAX_EXTTHRS
105
#define EM_MAX_EXTTHRS 32
106
#endif
107
108
/**
109
* Maximum number of EM atomic groups
110
*/
111
#ifndef EM_MAX_ATOMIC_GROUPS
112
#define EM_MAX_ATOMIC_GROUPS 128
113
#endif
114
115
/**
116
* Max atomic group name length
117
*/
118
#ifndef EM_ATOMIC_GROUP_NAME_LEN
119
#define EM_ATOMIC_GROUP_NAME_LEN 32
120
#endif
121
122
/**
123
* Maximum total number of EOs
124
*/
125
#ifndef EM_MAX_EOS
126
#define EM_MAX_EOS 512
127
#endif
128
129
/**
130
* Maximum EO name string length
131
*/
132
#ifndef EM_EO_NAME_LEN
133
#define EM_EO_NAME_LEN 32
134
#endif
135
136
/**
137
* Maximum number of event groups
138
*/
139
#ifndef EM_MAX_EVENT_GROUPS
140
#define EM_MAX_EVENT_GROUPS 1024
141
#endif
142
143
/**
144
* Maximum number of notifications
145
*/
146
#ifndef EM_EVENT_GROUP_MAX_NOTIF
147
#define EM_EVENT_GROUP_MAX_NOTIF 6
148
#endif
149
150
/**
151
* Maximum queue name string length
152
*/
153
#ifndef EM_QUEUE_NAME_LEN
154
#define EM_QUEUE_NAME_LEN 32
155
#endif
156
157
/**
158
* Maximum number of output queues
159
*/
160
#ifndef EM_MAX_OUTPUT_QUEUES
161
#define EM_MAX_OUTPUT_QUEUES 64
162
#endif
163
164
/**
165
* Number of queue scheduling priorities, normal default is 8.
166
* @see em_queue_prio_e
167
*/
168
#ifndef EM_QUEUE_PRIO_NUM
169
#define EM_QUEUE_PRIO_NUM 8
170
#endif
171
172
/**
173
* Determines the EM queue handles range to use.
174
* Note: value must be >= 1 and <= 'UINT16_MAX - em_queue_max_num() + 1'
175
* idx EM Queue handle
176
* 0 -> 0 + offset
177
* 1 -> 1 + offset
178
* ...
179
* max-1 -> max-1 + offset
180
*/
181
#ifndef EM_QUEUE_RANGE_OFFSET
182
#define EM_QUEUE_RANGE_OFFSET 1
183
#endif
184
185
/**
186
* The maximum number of aggregator queues that can be created for a single
187
* EM queue. An aggregator queue allows multiple events to be aggregated into
188
* a vector event before enqueueing to the parent queue.
189
* @see em_queue_aggr_conf_t and em_queue_param_t.
190
*
191
* @note The actual maximum number of aggregator queues that can be created for
192
* a single EM queue is determined by the minimum of this value and the
193
* ODP implementation limits for event aggregators, which can be queried
194
* with odp_queue_capability() for plain queues or with
195
* odp_schedule_capability() for scheduled queues, and are checked by EM
196
* at queue creation time.
197
*/
198
#ifndef EM_QUEUE_MAX_AGGR
199
#define EM_QUEUE_MAX_AGGR 4
200
#endif
201
202
/**
203
* Maximum number of EM queue groups
204
*/
205
#ifndef EM_MAX_QUEUE_GROUPS
206
#define EM_MAX_QUEUE_GROUPS (EM_MAX_CORES + 64)
207
#endif
208
209
/**
210
* Default queue group for EM
211
*/
212
#define EM_QUEUE_GROUP_DEFAULT EM_REINTERPRET_CAST(em_queue_group_t, EM_MAX_QUEUE_GROUPS)
213
214
/**
215
* Max queue group name length
216
*/
217
#ifndef EM_QUEUE_GROUP_NAME_LEN
218
#define EM_QUEUE_GROUP_NAME_LEN 32
219
#endif
220
221
/**
222
* The name of the EM default queue group
223
*/
224
#define EM_QUEUE_GROUP_DEFAULT_NAME "default"
225
226
/**
227
* Base-name of EM core-specific queue groups (one per EM-core),
228
* if created by EM (note: see the EM runtime config file for option).
229
* The full queue group name for a single-core group is: "core" + "%d",
230
* which gives "core0", "core1", ... "core99", ...
231
* EM earlier relied on these queue groups for internal core specific
232
* messaging and also allowed applications to use them. Currently EM
233
* does not internally need these groups but will create them based on
234
* an EM config file option for applications relying on their existence.
235
*
236
* Example: Find the queue group that includes only this core.
237
* (EM single-core queue group creation enabled in config file)
238
* @code
239
* char qgrp_name[EM_QUEUE_GROUP_NAME_LEN];
240
* int core = em_core_id();
241
* em_queue_group_t qgrp_core;
242
*
243
* snprintf(qgrp_name, sizeof(qgrp_name), "%s%d",
244
* EM_QUEUE_GROUP_CORE_BASE_NAME, core);
245
* ...
246
* qgrp_core = em_queue_group_find(qgrp_name);
247
* ...
248
* @endcode
249
*/
250
#define EM_QUEUE_GROUP_CORE_BASE_NAME "core"
251
252
/**
253
* Maximum number of EM pools
254
*/
255
#ifndef EM_CONFIG_POOLS
256
#define EM_CONFIG_POOLS 16
257
#endif
258
259
/**
260
* Define the EM default event pool
261
*/
262
#define EM_POOL_DEFAULT EM_REINTERPRET_CAST(em_pool_t, 1)
263
264
/**
265
* Max event pool name length
266
*/
267
#ifndef EM_POOL_NAME_LEN
268
#define EM_POOL_NAME_LEN 32
269
#endif
270
271
/**
272
* @brief The maximum number of subpools in each EM pool.
273
* The subpool is a pool with buffers of only one size.
274
*/
275
#ifndef EM_MAX_SUBPOOLS
276
#define EM_MAX_SUBPOOLS 4
277
#endif
278
279
/**
280
* The name of the EM default event pool
281
*/
282
#define EM_POOL_DEFAULT_NAME "default"
283
284
/**
285
* Reserve for EM pool subpool statistic internal use
286
*/
287
#define EM_POOL_SUBPOOL_STAT_INTERNAL 129
288
289
/**
290
* The maximum size in bytes that can be configured for the event user area.
291
* The user area is located outside of the payload in the event metadata (hdr)
292
* and can be used to store event related state without affecting the payload.
293
*/
294
#ifndef EM_EVENT_USER_AREA_MAX_SIZE
295
#define EM_EVENT_USER_AREA_MAX_SIZE 256
296
#endif
297
298
/**
299
* The maximum number of events to request from the scheduler and then
300
* dispatch in one burst.
301
*
302
* @note the odp sched burst size is determined by the odp-config-file values:
303
* sched_basic: burst_size_default[...] and burst_size_max[...]
304
*/
305
#ifndef EM_SCHED_MULTI_MAX_BURST
306
#define EM_SCHED_MULTI_MAX_BURST 32
307
#endif
308
309
/**
310
* The maximum number of events from an atomic group to dispatch in one burst.
311
*/
312
#ifndef EM_SCHED_AG_MULTI_MAX_BURST
313
#define EM_SCHED_AG_MULTI_MAX_BURST 32
314
#endif
315
316
/**
317
* The maximum number of events from a local queue (EM_QUEUE_TYPE_LOCAL) to
318
* dispatch in one burst.
319
*/
320
#ifndef EM_QUEUE_LOCAL_MULTI_MAX_BURST
321
#define EM_QUEUE_LOCAL_MULTI_MAX_BURST 32
322
#endif
323
324
/**
325
* The default maximum number of events passed to the EO's multi-event
326
* receive function (when the EO has been created with em_eo_create_multircv()).
327
* This value is used by EM as a default if the user does not specify
328
* a value (i.e. gives '0') for 'em_eo_multircv_param_t::max_events' when
329
* calling em_eo_create_multircv()
330
*/
331
#ifndef EM_EO_MULTIRCV_MAX_EVENTS
332
#define EM_EO_MULTIRCV_MAX_EVENTS 32
333
#endif
334
335
/**
336
* Maximum number of EM callbacks/hooks that can be registered.
337
*
338
* The user may register up to the number 'EM_CALLBACKS_MAX' of each
339
* callback/hook. API-hooks, such as the alloc-, free- and send-hook, or
340
* dispatcher callbacks, such as the enter- and exit-callbacks as well as
341
* idle-hooks can be registered each up to this limit.
342
*/
343
#ifndef EM_CALLBACKS_MAX
344
#define EM_CALLBACKS_MAX 8
345
#endif
346
347
/**
348
* '0': allow EM to buffer events sent to output queues before calling the
349
* user provided output callback to improve throughput
350
* '1': each em_send/_multi() will immediately call the user provided output
351
* queue callback with no EM internal buffering
352
* This define mostly affects behaviour and performance when sending events from
353
* an ordered scheduling context where EM needs to ensure event ordering before
354
* calling the user provided output callback function.
355
*/
356
#ifndef EM_OUTPUT_QUEUE_IMMEDIATE
357
#define EM_OUTPUT_QUEUE_IMMEDIATE 0
358
#endif
359
360
/*
361
* Enable dispatcher callback functions
362
*/
363
#ifndef EM_DISPATCH_CALLBACKS_ENABLE
364
#define EM_DISPATCH_CALLBACKS_ENABLE 1
365
#endif
366
367
/**
368
* Enable the usage of EM API hooks
369
*
370
* User provided API hook functions can be provided via em_init(). EM will
371
* call the given hooks each time the corresponding API function is called.
372
*/
373
#ifndef EM_API_HOOKS_ENABLE
374
#define EM_API_HOOKS_ENABLE 1
375
#endif
376
377
/**
378
* Guards event groups in undefined and error situations
379
*
380
* Excess and aborted group events don't belong to a valid group when received.
381
* Most event group APIs check if the core local event group has expired during
382
* receive function. Impacts performance when event groups are used.
383
*/
384
#ifndef EM_EVENT_GROUP_SAFE_MODE
385
#define EM_EVENT_GROUP_SAFE_MODE 1
386
#endif
387
388
/**
389
* Enable the usage of EM idle hooks
390
*
391
* User provided idle hook functions can be provided via em_conf_t::idle_hooks
392
* when calling em_init() or via their register functions. EM will call the
393
* given hooks in the dispatcher depending on whether there are events to be
394
* processed by the core.
395
*
396
* @note em-odp: the 'EM_IDLE_HOOKS_ENABLE' value is set/changed by a
397
* command-line option to the 'configure' script, e.g.:
398
* $build> ../configure ... --enable-idle-hooks[=yes|no]
399
*/
400
#ifndef EM_IDLE_HOOKS_ENABLE
401
#define EM_IDLE_HOOKS_ENABLE 1
402
#endif
403
404
/**
405
* Enable the EM dispatcher/scheduler to set the time (in ns) the scheduler
406
* should wait for events before returning (when no events are immediately
407
* available). Waiting for events, rather than busy-waiting, might save power.
408
* The EM dispatch loop will call odp_schedule_multi(..., sched_wait_ns, ...)
409
* when EM_SCHED_WAIT_ENABLE=1.
410
* The EM dispatch loop will call odp_schedule_multi_no_wait()
411
* when EM_SCHED_WAIT_ENABLE=0.
412
* The 'sched_wait_ns' value can be set via an EM config file option:
413
* config/em-odp.conf: dispatch.sched_wait_ns = value
414
*
415
* @note em-odp: the 'EM_SCHED_WAIT_ENABLE' value is set/changed by a
416
* command-line option to the 'configure' script, e.g.:
417
* $build> ../configure ... --enable-sched-wait[=yes|no]
418
*/
419
#ifndef EM_SCHED_WAIT_ENABLE
420
#define EM_SCHED_WAIT_ENABLE 1
421
#endif
422
423
/**
424
* EM Error check level
425
*
426
* Conditionally compiled error checking level, range 0...3
427
* Level 0 does not do any runtime argument checking (be careful!)
428
* Level 1 adds minimum checks
429
* Level 2 adds most checks except the slowest ones
430
* Level 3 adds all checks and gives lowest performance
431
*
432
* @note em-odp: the 'EM_CHECK_LEVEL' value is set/changed by a command-line
433
* option to the 'configure' script, e.g.:
434
* $build> ../configure ... --enable-check-level=3
435
*/
436
#ifndef EM_CHECK_LEVEL
437
#define EM_CHECK_LEVEL 3
438
#endif
439
440
/**
441
* Event State Verification (ESV)
442
*
443
* '0': disabled
444
* '1': enabled - event state is verified when the event is passed from EM to
445
* the user (e.g. dispatch) and from the user to EM (e.g. send)
446
* to catch illegal usage patterns like double-send, double-free,
447
* usage-after-send etc.
448
*
449
* Also see the config/em-odp.conf file for ESV runtime options!
450
*
451
* @note em-odp: the 'EM_ESV_ENABLE' value is set/changed by a command-line
452
* option to the 'configure' script, e.g.:
453
* $build> ../configure ... --enable-esv[=yes|no]
454
*/
455
#ifndef EM_ESV_ENABLE
456
#define EM_ESV_ENABLE 1
457
#endif
458
459
/**
460
* EM debug printouts - enable/disable all debug printouts
461
*
462
* '0': disabled
463
* '1': enabled
464
*
465
* The EM_DEBUG_PRINT_ALL define is a convenience define that, if set via
466
* 'configure --enable-debug-print/-all', will set all individual debug print
467
* options to 'enabled' (1).
468
* Summary of configure interactions:
469
* Default: EM_DEBUG_PRINT_ALL = 0,
470
* Subflags:
471
* EM_DEBUG_PRINT_TIMER = 0,
472
* EM_DEBUG_PRINT_BASE = 0
473
* --enable-debug-print-all (alias: --enable-debug-print): _ALL=1 seeds
474
* _TIMER=1 & _BASE=1 (unless individually disabled).
475
* --disable-debug-print-all: _ALL=0, subflags keep explicitly set values,
476
* otherwise they are set to 0.
477
* --enable-debug-print-timer/base: set that subflag to 1 (_ALL unchanged).
478
* --disable-debug-print-timer/base: set that subflag to 0 and force _ALL=0.
479
* Disabling any subflag after enabling _ALL clears _ALL (non-uniform state).
480
*/
481
#ifndef EM_DEBUG_PRINT_ALL
482
#define EM_DEBUG_PRINT_ALL 0
483
#endif
484
485
/**
486
* EM debug printouts - enable/disable timer debug printouts
487
*
488
* '0': disabled
489
* '1': enabled
490
*
491
* The 'EM_DEBUG_PRINT_TIMER' value is set/changed by a command-line option to
492
* the 'configure' script, e.g.:
493
* $build> ../configure ... --enable-debug-print-timer[=yes|no]
494
*
495
* Note: seeded to 1 by --enable-debug-print/-all unless overridden.
496
*/
497
#ifndef EM_DEBUG_PRINT_TIMER
498
#define EM_DEBUG_PRINT_TIMER 0
499
#endif
500
501
/**
502
* EM debug printouts - enable/disable base level debug printouts
503
*
504
* '0': disabled
505
* '1': enabled
506
*
507
* The 'EM_DEBUG_PRINT_BASE' value is set/changed by a command-line option to
508
* the 'configure' script, e.g.:
509
* $build> ../configure ... --enable-debug-print-base[=yes|no]
510
*
511
* Note: seeded to 1 by --enable-debug-print/-all unless overridden.
512
*/
513
#ifndef EM_DEBUG_PRINT_BASE
514
#define EM_DEBUG_PRINT_BASE 0
515
#endif
516
517
/**
518
* Debug Timestamps for timing analysis.
519
*
520
* Enabling may reduce performance but allows to trace dispatcher timings.
521
* Timestamps are per dispatcher (thread local).
522
*
523
* '0': disabled (default)
524
* '1': enabled, lower overhead but potentially inaccurate (no HW barriers)
525
* '2': enabled, strict version with full HW barriers
526
*
527
* Use value 1 for lower overhead timestamps and value 2 for strict timestamp
528
* with HW barriers.
529
*
530
* The 'EM_DEBUG_TIMESTAMP_ENABLE' value is set/changed by a command-line option
531
* to the 'configure' script, e.g.:
532
* $build> ../configure ... --enable-debug-timestamps=0...2
533
*
534
* @see event_machine_helper.h
535
*/
536
#ifndef EM_DEBUG_TIMESTAMP_ENABLE
537
#define EM_DEBUG_TIMESTAMP_ENABLE 0
538
#endif
539
540
#ifdef __cplusplus
541
}
542
#endif
543
544
#pragma GCC visibility pop
545
#endif
/* EVENT_MACHINE_CONFIG_H */