NEURON
neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields > Struct Template Reference

Version of Memb_list for use in performance-critical code. More...

#include <mechanism_range.hpp>

Inheritance diagram for neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >:
neuron::cache::MechanismInstance< NumFloatingPointFields, NumDatumFields >

Public Member Functions

 MechanismRange (neuron::model_sorted_token const &cache_token, Memb_list &ml)
 Construct a MechanismRange from sorted model data. More...
 
 MechanismRange (neuron::model_sorted_token const &cache_token, NrnThread &, Memb_list &ml, int type)
 Deprecated. More...
 
template<int variable, int array_size>
double * data_array (std::size_t instance)
 Get the range of values for an array RANGE variable. More...
 
template<int variable, int array_size>
double * data_array_ptr ()
 
template<int variable>
double & fpfield (std::size_t instance)
 Get a RANGE variable value. More...
 
template<int variable>
double * fpfield_ptr ()
 
double & data (std::size_t instance, container::field_index ind)
 Get a RANGE variable value. More...
 
template<int variable>
double * dptr_field (std::size_t instance)
 Get a POINTER variable. More...
 
template<int variable>
double *const * dptr_field_ptr ()
 

Protected Member Functions

 MechanismRange (int mech_type, std::size_t offset)
 Calls MechanismRange(mech_type, offset, offset). More...
 
 MechanismRange (int mech_type, std::size_t data_offset, std::size_t dptr_offset)
 Sets up the pointers for data (not pdata) and the offsets. More...
 

Protected Attributes

double *const * m_data_ptrs {}
 Pointer to a range of pointers to the start of RANGE variable storage. More...
 
int const * m_data_array_dims {}
 Pointer to a range of array dimensions for the RANGE variables in this mechanism. More...
 
double *const *const * m_pdata_ptrs {}
 Pointer to a range of pointers to the start of POINTER variable caches. More...
 
std::size_t m_data_offset {}
 Offset of this contiguous range of mechanism instances into the global range. More...
 
std::size_t m_dptr_offset {}
 

Detailed Description

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
struct neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >

Version of Memb_list for use in performance-critical code.

Unlike Memb_list, this requires that the number of fields is known at compile time. This is typically only true in translated MOD file code. The idea is that an instance of this class will be created outside a loop over the data vectors and then used inside the loop.

Warning
It is the responsibility of the caller to ensure that the model remains sorted beyond the lifetime of the MechanismRange instance.

Definition at line 42 of file mechanism_range.hpp.

Constructor & Destructor Documentation

◆ MechanismRange() [1/4]

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::MechanismRange ( neuron::model_sorted_token const &  cache_token,
Memb_list ml 
)
inline

Construct a MechanismRange from sorted model data.

Parameters
cache_tokenToken showing the model data are sorted.
mlRange of mechanisms this MechanismRange refers to.

This mirrors the signature of the functions (nrn_state, nrn_cur, nrn_init...) that are generated in C++ from MOD files. Typically those generated functions immediately create an instance of MechanismRange using this constructor.

Definition at line 52 of file mechanism_range.hpp.

◆ MechanismRange() [2/4]

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::MechanismRange ( neuron::model_sorted_token const &  cache_token,
NrnThread ,
Memb_list ml,
int  type 
)
inline

Deprecated.

Definition at line 60 of file mechanism_range.hpp.

◆ MechanismRange() [3/4]

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::MechanismRange ( int  mech_type,
std::size_t  offset 
)
inlineprotected

Calls MechanismRange(mech_type, offset, offset).

Definition at line 72 of file mechanism_range.hpp.

◆ MechanismRange() [4/4]

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::MechanismRange ( int  mech_type,
std::size_t  data_offset,
std::size_t  dptr_offset 
)
inlineprotected

Sets up the pointers for data (not pdata) and the offsets.

Parameters
data_offsetthe offset for data (not pdata).
dptr_offsetthe offset for pdata.

Definition at line 81 of file mechanism_range.hpp.

Member Function Documentation

◆ data()

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
double& neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::data ( std::size_t  instance,
container::field_index  ind 
)
inline

Get a RANGE variable value.

Parameters
instanceWhich mechanism instance to access inside this MechanismRange.
indThe index of the RANGE variable in the mechanism. This includes both the index of the variable and the index into an array RANGE variable.

Definition at line 132 of file mechanism_range.hpp.

◆ data_array()

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
template<int variable, int array_size>
double* neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::data_array ( std::size_t  instance)
inline

Get the range of values for an array RANGE variable.

Template Parameters
variableThe index of the RANGE variable in the mechanism.
array_sizeThe array dimension of the RANGE variable.
Parameters
instanceWhich mechanism instance to access inside this mechanism range.

Definition at line 98 of file mechanism_range.hpp.

◆ data_array_ptr()

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
template<int variable, int array_size>
double* neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::data_array_ptr ( )
inline

Definition at line 105 of file mechanism_range.hpp.

◆ dptr_field()

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
template<int variable>
double* neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::dptr_field ( std::size_t  instance)
inline

Get a POINTER variable.

Template Parameters
variableThe index of the POINTER variable in the pdata/dparam entries of the mechanism.
Parameters
instanceWhich mechanism instance to access inside this mechanism range.

Definition at line 146 of file mechanism_range.hpp.

◆ dptr_field_ptr()

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
template<int variable>
double* const* neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::dptr_field_ptr ( )
inline

Definition at line 152 of file mechanism_range.hpp.

◆ fpfield()

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
template<int variable>
double& neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::fpfield ( std::size_t  instance)
inline

Get a RANGE variable value.

Template Parameters
variableThe index of the RANGE variable in the mechanism.
Parameters
instanceWhich mechanism instance to access inside this MechanismRange.

This is only intended for use with non-array RANGE variables, otherwise use data_array.

Definition at line 117 of file mechanism_range.hpp.

◆ fpfield_ptr()

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
template<int variable>
double* neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::fpfield_ptr ( )
inline

Definition at line 122 of file mechanism_range.hpp.

Member Data Documentation

◆ m_data_array_dims

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
int const* neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::m_data_array_dims {}
protected

Pointer to a range of array dimensions for the RANGE variables in this mechanism.

m_data_array_dims[i] is the array dimension of the \(\texttt{i}^{th}\) RANGE variable.

Definition at line 172 of file mechanism_range.hpp.

◆ m_data_offset

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
std::size_t neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::m_data_offset {}
protected

Offset of this contiguous range of mechanism instances into the global range.

Typically if there is more than one thread in the process then the instances of a particular mechanism type will be distributed across multiple NrnThread objects and processed by different threads, and the mechanism data will be permuted so that the instances owned by a given thread are contiguous. In that case the MechanismRange for the 0th thread would have an m_data_offset of zero, and the MechanismRange for the next thread would have an m_data_offset of the number of instances in the 0th thread.

See also
nrn_sort_mech_data.

Definition at line 195 of file mechanism_range.hpp.

◆ m_data_ptrs

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
double* const* neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::m_data_ptrs {}
protected

Pointer to a range of pointers to the start of RANGE variable storage.

m_data_ptrs[i] is a pointer to the start of the contiguous storage for the \(\texttt{i}^{th}\) RANGE variable.

See also
container::detail::field_data<Tag, true>::data_ptrs()

Definition at line 165 of file mechanism_range.hpp.

◆ m_dptr_offset

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
std::size_t neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::m_dptr_offset {}
protected

Definition at line 196 of file mechanism_range.hpp.

◆ m_pdata_ptrs

template<std::size_t NumFloatingPointFields, std::size_t NumDatumFields>
double* const* const* neuron::cache::MechanismRange< NumFloatingPointFields, NumDatumFields >::m_pdata_ptrs {}
protected

Pointer to a range of pointers to the start of POINTER variable caches.

m_pdata_ptrs[i][j] is the double* corresponding to the \(\texttt{i}^{th}\) pdata / dparam field and the \(\texttt{j}^{th}\) instance of the mechanism in the program.

See also
MechanismInstance::MechanismInstance(Prop*) and nrn_sort_mech_data.

Definition at line 181 of file mechanism_range.hpp.


The documentation for this struct was generated from the following file: