![]() |
NEURON
|
A view into a set of mechanism instances. More...
#include <nrnoc_ml.h>
Public Member Functions | |
Memb_list ()=default | |
Construct a null Memb_list that does not refer to any thread/type. More... | |
Memb_list (int type) | |
Construct a Memb_list that knows its type + underlying storage. More... | |
~Memb_list () noexcept | |
Uninitialize, freeing any allocated mem for nodes. More... | |
Memb_list (Memb_list &&) noexcept | |
Memb_list & | operator= (Memb_list &&) noexcept |
void | nodes_alloc (int node_count, bool also_pdata) |
Allocate memory for node_count nodes. More... | |
void | nodes_free () |
Free memory allocated for nodes (with nodes_alloc) More... | |
std::vector< double * > | data () |
Get a vector of double* representing the model data. More... | |
template<std::size_t variable> | |
double & | fpfield (std::size_t instance) |
template<std::size_t variable> | |
double * | dptr_field (std::size_t instance) |
neuron::container::data_handle< double > | data_handle (std::size_t instance, neuron::container::field_index field) const |
int | get_array_dims (int variable) const |
Get the array_dims of field variable . More... | |
int const * | get_array_dims () const |
Get the array_dims of field variable . More... | |
int | get_array_prefix_sums (int variable) const |
Get the array_dims of field variable . More... | |
int const * | get_array_prefix_sums () const |
Get the array_dims of field variable . More... | |
std::ptrdiff_t | legacy_index (double const *ptr) const |
Calculate a legacy index of the given pointer in this mechanism data. More... | |
std::ptrdiff_t | legacy_index (neuron::container::data_handle< double > const &dh) const |
Calculate a legacy index from a data handle. More... | |
std::size_t | get_storage_offset () const |
Get the offset of this Memb_list into global storage for this type. More... | |
void | set_storage_offset (std::size_t offset) |
Set the offset of this Memb_list into global storage for this type. More... | |
void | set_storage_pointer (neuron::container::Mechanism::storage *storage) |
Set the pointer to the underlying data container. More... | |
int | type () const |
Get the mechanism type. More... | |
int | _type () const |
Public Attributes | |
Node ** | nodelist {} |
int * | nodeindices {} |
Datum ** | pdata {} |
Prop ** | prop {} |
Datum * | _thread {} |
int | nodecount {} |
Private Member Functions | |
Memb_list (const Memb_list &)=delete | |
Memb_list & | operator= (const Memb_list &)=default |
Private Attributes | |
neuron::container::Mechanism::storage * | m_storage {} |
Pointer to the global mechanism data structure for this mech type. More... | |
std::size_t | m_storage_offset {neuron::container::invalid_row} |
Offset of this thread+mechanism into the global mechanism data. More... | |
bool | m_owns_nodes {false} |
Whether this memlist owns its nodes memory or whether we are a view Has implications on memory management. More... | |
A view into a set of mechanism instances.
This is a view to a set of mechanism instances that are contiguous in the underlying storage. This is inherently something that only makes sense if the underlying data are sorted. In this case, Memb_list essentially contains a pointer to the underlying storage struct and a single offset into it. This covers use-cases like Memb_list inside NrnThread – the data are partitioned by NrnThread in nrn_sort_mech_data so all the instances of a particular mechanism in a particular thread are next to each other in the storage.
Because this type is passed from NEURON library code into code generated from MOD files, it is prone to ABI issues – particularly when dealing with Python wheels.
Definition at line 34 of file nrnoc_ml.h.
|
default |
Construct a null Memb_list that does not refer to any thread/type.
|
explicit |
Construct a Memb_list that knows its type + underlying storage.
Defined in .cpp to hide neuron::container::Mechanism::storage layout from translated MOD file code.
Definition at line 14 of file memblist.cpp.
|
noexcept |
Uninitialize, freeing any allocated mem for nodes.
Definition at line 58 of file memblist.cpp.
|
noexcept |
Other should not be used. But if it is, fine, but not the memory owner anymore
Definition at line 46 of file memblist.cpp.
|
privatedelete |
|
inline |
Definition at line 233 of file nrnoc_ml.h.
std::vector< double * > Memb_list::data | ( | ) |
Get a vector of double* representing the model data.
Calling .data() on the return value yields a double** that is similar to the old _data member, with the key difference that its indices are transposed. Now, the first index corresponds to the variable and the second index corresponds to the instance of the mechanism. This method is useful for interfacing with CoreNEURON but should be deprecated and removed along with the translation layer between NEURON and CoreNEURON.
Defined in .cpp to hide neuron::container::Mechanism::storage layout from translated MOD file code.
Definition at line 64 of file memblist.cpp.
neuron::container::data_handle< double > Memb_list::data_handle | ( | std::size_t | instance, |
neuron::container::field_index | field | ||
) | const |
Definition at line 76 of file memblist.cpp.
|
inline |
Definition at line 100 of file nrnoc_ml.h.
|
inline |
Definition at line 95 of file nrnoc_ml.h.
int const * Memb_list::get_array_dims | ( | ) | const |
Get the array_dims of field variable
.
Definition at line 115 of file memblist.cpp.
int Memb_list::get_array_dims | ( | int | variable | ) | const |
Get the array_dims of field variable
.
Definition at line 110 of file memblist.cpp.
int const * Memb_list::get_array_prefix_sums | ( | ) | const |
Get the array_dims of field variable
.
Definition at line 125 of file memblist.cpp.
int Memb_list::get_array_prefix_sums | ( | int | variable | ) | const |
Get the array_dims of field variable
.
Definition at line 120 of file memblist.cpp.
|
inline |
Get the offset of this Memb_list into global storage for this type.
In the simplest case then this Memb_list represents all instances of a particular type in a particular thread, which are contiguous because the data have been sorted by a call like auto const cache_token = nrn_ensure_model_data_are_sorted() and this offset has been set to be cache_token.thread_cache(thread_id).mechanism_offset.at(mechanism_type) so that the first argument to data(i, j) is an offset inside this thread, not the global structure.
Definition at line 195 of file nrnoc_ml.h.
std::ptrdiff_t Memb_list::legacy_index | ( | double const * | ptr | ) | const |
Calculate a legacy index of the given pointer in this mechanism data.
This used to be defined as ptr - ml->_data[0] if ptr belonged to the given mechanism, i.e. an offset from the zeroth element of the zeroth mechanism. This is useful when interfacing with CoreNEURON and for parameter exchange with other MPI ranks.
Defined in .cpp to hide neuron::container::Mechanism::storage layout from translated MOD file code.
Definition at line 131 of file memblist.cpp.
|
inline |
Calculate a legacy index from a data handle.
Definition at line 178 of file nrnoc_ml.h.
void Memb_list::nodes_alloc | ( | int | node_count, |
bool | also_pdata | ||
) |
Allocate memory for node_count nodes.
also_pdata | Allocate also pdata Datum's |
Definition at line 19 of file memblist.cpp.
void Memb_list::nodes_free | ( | ) |
Free memory allocated for nodes (with nodes_alloc)
Definition at line 36 of file memblist.cpp.
Definition at line 52 of file memblist.cpp.
|
inline |
Set the offset of this Memb_list into global storage for this type.
See the documentation for get_storage_offset.
Definition at line 210 of file nrnoc_ml.h.
|
inline |
Set the pointer to the underlying data container.
This is a quasi-private method that you should think twice before calling. Normally m_storage would automatically be set by the constructor taking an integer mechanism type.
Definition at line 221 of file nrnoc_ml.h.
int Memb_list::type | ( | ) | const |
Get the mechanism type.
Defined in .cpp to hide neuron::container::Mechanism::storage layout from translated MOD file code.
Definition at line 177 of file memblist.cpp.
Datum* Memb_list::_thread {} |
Definition at line 77 of file nrnoc_ml.h.
|
private |
Whether this memlist owns its nodes memory or whether we are a view Has implications on memory management.
Definition at line 257 of file nrnoc_ml.h.
|
private |
Pointer to the global mechanism data structure for this mech type.
Definition at line 241 of file nrnoc_ml.h.
|
private |
Offset of this thread+mechanism into the global mechanism data.
This is locally a piece of "cache" information like node_data_offset – the question is whether Memb_list itself is also considered a transient/cache type, in which case this is fine, or if it's considered permanent...in which case this value should probably not live here.
Definition at line 251 of file nrnoc_ml.h.
int Memb_list::nodecount {} |
Definition at line 78 of file nrnoc_ml.h.
int* Memb_list::nodeindices {} |
Definition at line 74 of file nrnoc_ml.h.
Node** Memb_list::nodelist {} |
Definition at line 68 of file nrnoc_ml.h.
Datum** Memb_list::pdata {} |
Definition at line 75 of file nrnoc_ml.h.
Prop** Memb_list::prop {} |
Definition at line 76 of file nrnoc_ml.h.