Skip to content

Replace typedef'ed types with C++ PODs #2541

@heplesser

Description

@heplesser

This issue is a follow-up to #2215.

After a thorough discussion during the Hackathon we came to the following conclusions:

  1. Typedefs (except weight and partially delay) are only used to index into containers. Therefore, size_t is the suitable POD where currently typedefs index, thread, port, rport, ... are used.
  2. Typedefs do not provide any type safety in C++.
  3. Where we use signed types through typedefs today (int, long), we only use value -1 from the negative range, wasting value range. Use of size_t would avoid this.
  4. Named type solutions seem too complicated, as do implementing our own classes for, e.g., Thread, Delay, ....
  5. We therefore concluded that we will explore replacing all typedefed types with PODs, using unsigned PODs throughout.
  6. For marking invalid values, three approaches can be used, as suitable in the situation
    1. Return a std::pair<> combining the value and a boolean flag indicating validity.
    2. Use std::numeric_limits<POD>::max() as the invalid value.
    3. Raise exceptions instead of returning invalid values.
  7. Certain quantities have implicitly limited value ranges because they need to be transmitted in bitfields of limited size in MPI communication (
    #if TARGET_BITS_SPLIT == TARGET_BITS_SPLIT_STANDARD
    constexpr uint8_t NUM_BITS_RANK = 18U;
    constexpr uint8_t NUM_BITS_TID = 9U;
    constexpr uint8_t NUM_BITS_SYN_ID = 9U;
    #elif TARGET_BITS_SPLIT == TARGET_BITS_SPLIT_HPC
    constexpr uint8_t NUM_BITS_RANK = 20U;
    constexpr uint8_t NUM_BITS_TID = 10U;
    constexpr uint8_t NUM_BITS_SYN_ID = 6U;
    #endif
    constexpr uint8_t NUM_BITS_LCID = 27U;
    constexpr uint8_t NUM_BITS_PROCESSED_FLAG = 1U;
    constexpr uint8_t NUM_BITS_MARKER_SPIKE_DATA = 2U;
    constexpr uint8_t NUM_BITS_LAG = 14U;
    constexpr uint8_t NUM_BITS_DELAY = 21U;
    constexpr uint8_t NUM_BITS_NODE_ID = 62U;
    /*
    * Maximally allowed values for bitfields
    */
    constexpr uint64_t MAX_LCID = generate_max_value( NUM_BITS_LCID );
    constexpr int64_t MAX_RANK = generate_max_value( NUM_BITS_RANK );
    constexpr int64_t MAX_TID = generate_max_value( NUM_BITS_TID );
    constexpr uint64_t MAX_SYN_ID = generate_max_value( NUM_BITS_SYN_ID );
    constexpr uint64_t DISABLED_NODE_ID = generate_max_value( NUM_BITS_NODE_ID );
    constexpr uint64_t MAX_NODE_ID = DISABLED_NODE_ID - 1;
    ). Where these values are set (e.g., when the number of threads is changed or new synapse models are created), we need to check if new values are in the permissible range.

Metadata

Metadata

Assignees

Labels

I: Internal APIChanges were introduced in basic internal workings of the simulator that developers need to knowS: NormalHandle this with default priorityT: EnhancementNew functionality, model or documentationstaleAutomatic marker for inactivity, please have another look here

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions