NEST main@f146f75
Loading...
Searching...
No Matches
nest_types.h
Go to the documentation of this file.
1/*
2 * nest_types.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef NEST_TYPES_H
24#define NEST_TYPES_H
25
26// C++ includes:
27#include <cfloat>
28#include <climits>
29#include <cstddef>
30#include <limits>
31#include <stdint.h>
32#include <type_traits>
33
34// Generated includes:
35#include "config.h"
36
37#include <cstdint> // `uint64_t`
38
42
43namespace nest
44{
45
55
56// constexpr-functions for convenient compile-time generation of the bit-masks
57// and bit-constants. An ill-defined length or size will cause a compile-time
58// error, e.g., num_bits to be shifted exceeds the sizeof(<datatype>) * 8.
59constexpr uint64_t
60generate_bit_mask( const uint8_t num_bits, const uint8_t bit_position )
61{
62 return ( ( ( static_cast< uint64_t >( 1 ) << num_bits ) - 1 ) << bit_position );
63}
64
65constexpr uint64_t
66generate_max_value( const uint8_t num_bits )
67{
68 return ( ( static_cast< uint64_t >( 1 ) << num_bits ) - 1 );
69}
70
71
72// Sizes of bitfields used in various classes in the kernel.
73
74#if TARGET_BITS_SPLIT == TARGET_BITS_SPLIT_STANDARD
75constexpr uint8_t NUM_BITS_RANK = 18U;
76constexpr uint8_t NUM_BITS_TID = 9U;
77constexpr uint8_t NUM_BITS_SYN_ID = 9U;
78#elif TARGET_BITS_SPLIT == TARGET_BITS_SPLIT_HPC
79constexpr uint8_t NUM_BITS_RANK = 20U;
80constexpr uint8_t NUM_BITS_TID = 10U;
81constexpr uint8_t NUM_BITS_SYN_ID = 6U;
82#endif
83constexpr uint8_t NUM_BITS_LCID = 27U;
84constexpr uint8_t NUM_BITS_PROCESSED_FLAG = 1U;
85constexpr uint8_t NUM_BITS_MARKER_SPIKE_DATA = 2U;
86constexpr uint8_t NUM_BITS_FLUSH_EVENT = 1U;
87constexpr uint8_t NUM_BITS_LAG = 14U;
88constexpr uint8_t NUM_BITS_NODE_ID = 61U;
89
90// These types are used in delay_types.h and denote the space available for the dendritic and axonal portions of the
91// total transmission delay. The delay is only split into two parts for selected synapse types.
92// Given that axonal delays can be much larger than dendritic/backpropagation delays, they require more bits.
93constexpr uint8_t NUM_BITS_DENDRITIC_DELAY = 14U;
94constexpr uint8_t NUM_BITS_AXONAL_DELAY = sizeof( unsigned int ) * 8 - NUM_BITS_DENDRITIC_DELAY;
95
96
97// Maximally allowed values for bitfields
98
104constexpr uint64_t MAX_NODE_ID = DISABLED_NODE_ID - 1;
105
109typedef long long tic_t;
110constexpr tic_t tic_t_max = std::numeric_limits< tic_t >::max();
111constexpr tic_t tic_t_min = std::numeric_limits< tic_t >::min();
112
116__attribute__( ( __unused__ ) ) constexpr size_t invalid_index = std::numeric_limits< size_t >::max();
117
121typedef size_t synindex;
123
130typedef unsigned short targetindex;
131constexpr targetindex invalid_targetindex = USHRT_MAX;
132__attribute__( ( __unused__ ) ) const size_t max_targetindex = invalid_targetindex - 1;
133
137constexpr size_t invalid_lcid = MAX_LCID;
138
142constexpr size_t invalid_thread = std::numeric_limits< size_t >::max();
143
147constexpr size_t invalid_port = std::numeric_limits< size_t >::max();
148
152constexpr long delay_min = std::numeric_limits< long >::min();
153constexpr long delay_max = std::numeric_limits< long >::max();
154
171{
172 NONE = 0,
173 SPIKE = 1,
176};
177
186template < typename E >
187constexpr auto
188to_underlying( E e ) noexcept
189{
190 return static_cast< std::underlying_type_t< E > >( e );
191}
192}
193
194#endif /* #ifndef NEST_TYPES_H */
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
constexpr uint64_t generate_bit_mask(const uint8_t num_bits, const uint8_t bit_position)
Default types used by the NEST kernel.
Definition nest_types.h:60
constexpr uint8_t NUM_BITS_PROCESSED_FLAG
Definition nest_types.h:84
constexpr uint64_t DISABLED_NODE_ID
Definition nest_types.h:103
constexpr uint8_t NUM_BITS_SYN_ID
Definition nest_types.h:77
constexpr uint64_t MAX_NODE_ID
Definition nest_types.h:104
constexpr uint8_t NUM_BITS_LCID
Definition nest_types.h:83
constexpr int64_t MAX_TID
Definition nest_types.h:101
constexpr long delay_min
Values for min and max delay.
Definition nest_types.h:152
constexpr synindex invalid_synindex
Definition nest_types.h:122
constexpr uint64_t MAX_SYN_ID
Definition nest_types.h:102
long long tic_t
Type for Time tics.
Definition nest_types.h:109
constexpr uint8_t NUM_BITS_RANK
Definition nest_types.h:75
constexpr tic_t tic_t_min
Definition nest_types.h:111
constexpr uint8_t NUM_BITS_DENDRITIC_DELAY
Definition nest_types.h:93
constexpr tic_t tic_t_max
Definition nest_types.h:110
constexpr size_t invalid_thread
Value for invalid connection thread id.
Definition nest_types.h:142
constexpr uint8_t NUM_BITS_TID
Definition nest_types.h:76
constexpr uint8_t NUM_BITS_FLUSH_EVENT
Definition nest_types.h:86
constexpr int64_t MAX_RANK
Definition nest_types.h:100
constexpr auto to_underlying(E e) noexcept
Cast enum value to underlying integer type.
Definition nest_types.h:188
constexpr uint64_t generate_max_value(const uint8_t num_bits)
Definition nest_types.h:66
__attribute__((__unused__)) const expr size_t invalid_index
Unsigned long type for enumerations.
constexpr size_t invalid_lcid
Marker for invalid LCID values.
Definition nest_types.h:137
unsigned short targetindex
Unsigned short type for compact target representation.
Definition nest_types.h:130
SignalType
enum type of signal conveyed by spike events of a node.
Definition nest_types.h:171
@ SPIKE
Definition nest_types.h:173
@ ALL
Definition nest_types.h:175
@ BINARY
Definition nest_types.h:174
@ NONE
Definition nest_types.h:172
constexpr uint8_t NUM_BITS_MARKER_SPIKE_DATA
Definition nest_types.h:85
constexpr targetindex invalid_targetindex
Definition nest_types.h:131
constexpr size_t invalid_port
Value for invalid connection port number.
Definition nest_types.h:147
constexpr uint8_t NUM_BITS_AXONAL_DELAY
Definition nest_types.h:94
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:121
constexpr long delay_max
Definition nest_types.h:153
constexpr uint8_t NUM_BITS_LAG
Definition nest_types.h:87
constexpr uint64_t MAX_LCID
Definition nest_types.h:99
constexpr uint8_t NUM_BITS_NODE_ID
Definition nest_types.h:88