NEST main@caf0ae8
 
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
43namespace nest
44{
45
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_DELAY = 21U;
89constexpr uint8_t NUM_BITS_NODE_ID = 61U;
90
91// Maximally allowed values for bitfields
92
98constexpr uint64_t MAX_NODE_ID = DISABLED_NODE_ID - 1;
99
103typedef long long tic_t;
104constexpr tic_t tic_t_max = std::numeric_limits< tic_t >::max();
105constexpr tic_t tic_t_min = std::numeric_limits< tic_t >::min();
106
110__attribute__( ( __unused__ ) ) constexpr size_t invalid_index = std::numeric_limits< size_t >::max();
111
115typedef size_t synindex;
117
124typedef unsigned short targetindex;
125constexpr targetindex invalid_targetindex = USHRT_MAX;
126__attribute__( ( __unused__ ) ) const size_t max_targetindex = invalid_targetindex - 1;
127
131constexpr size_t invalid_lcid = MAX_LCID;
132
136constexpr size_t invalid_thread = std::numeric_limits< size_t >::max();
137
141constexpr size_t invalid_port = std::numeric_limits< size_t >::max();
142
146constexpr long delay_min = std::numeric_limits< long >::min();
147constexpr long delay_max = std::numeric_limits< long >::max();
148
165{
166 NONE = 0,
167 SPIKE = 1,
169 ALL = SPIKE | BINARY
171
180template < typename E >
181constexpr auto
182to_underlying( E e ) noexcept
183{
184 return static_cast< std::underlying_type_t< E > >( e );
185}
186}
187
188#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:97
constexpr uint8_t NUM_BITS_DELAY
Definition nest_types.h:88
constexpr uint8_t NUM_BITS_SYN_ID
Definition nest_types.h:77
constexpr uint64_t MAX_NODE_ID
Definition nest_types.h:98
constexpr uint8_t NUM_BITS_LCID
Definition nest_types.h:83
constexpr int64_t MAX_TID
Definition nest_types.h:95
constexpr long delay_min
Values for min and max delay.
Definition nest_types.h:146
constexpr synindex invalid_synindex
Definition nest_types.h:116
constexpr uint64_t MAX_SYN_ID
Definition nest_types.h:96
long long tic_t
Type for Time tics.
Definition nest_types.h:103
constexpr uint8_t NUM_BITS_RANK
Definition nest_types.h:75
constexpr tic_t tic_t_min
Definition nest_types.h:105
constexpr tic_t tic_t_max
Definition nest_types.h:104
constexpr size_t invalid_thread
Value for invalid connection thread id.
Definition nest_types.h:136
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:94
constexpr auto to_underlying(E e) noexcept
Cast enum value to underlying integer type.
Definition nest_types.h:182
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:131
unsigned short targetindex
Unsigned short type for compact target representation.
Definition nest_types.h:124
SignalType
enum type of signal conveyed by spike events of a node.
Definition nest_types.h:165
@ SPIKE
Definition nest_types.h:167
@ ALL
Definition nest_types.h:169
@ BINARY
Definition nest_types.h:168
@ NONE
Definition nest_types.h:166
constexpr uint8_t NUM_BITS_MARKER_SPIKE_DATA
Definition nest_types.h:85
constexpr targetindex invalid_targetindex
Definition nest_types.h:125
constexpr size_t invalid_port
Value for invalid connection port number.
Definition nest_types.h:141
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
constexpr long delay_max
Definition nest_types.h:147
constexpr uint8_t NUM_BITS_LAG
Definition nest_types.h:87
constexpr uint64_t MAX_LCID
Definition nest_types.h:93
constexpr uint8_t NUM_BITS_NODE_ID
Definition nest_types.h:89