26 #define RTLD_NODELETE 0
40 "CoreNEURON cannot simulate a model that contains extra LinearMechanism or RxD "
46 "CoreNEURON cannot simulate a model that contains the extracellular mechanism",
NULL);
55 "NEURON model internal structures for CoreNEURON are out of date. Make sure call to "
68 std::vector<double>
v;
70 std::sort(
v.begin(),
v.end());
108 Printf(
"Error: Section and Segment mapping vectors should have same size!\n");
116 smap->
sections.assign(sections, sections + nseg);
117 smap->
segments.assign(segments, segments + nseg);
118 smap->
seglfp_factors.assign(seg_lfp_factors, seg_lfp_factors + nlfp);
153 auto*
const pd =
static_cast<double*
>(dh);
158 if (
auto const maybe_index = tml->ml->legacy_index(pd); maybe_index >= 0) {
164 return type == 0 ? 1 : 0;
168 #if defined(HAVE_DLFCN_H)
173 bool is_coreneuron_loaded() {
174 bool is_loaded =
false;
179 is_loaded = fn ==
NULL ? false :
true;
187 void* get_handle_for_lib(std::filesystem::path
const& path) {
193 hoc_execerror(
"Could not dlopen CoreNEURON mechanism library : ", path.string().c_str());
199 void* get_coreneuron_handle() {
201 if (is_coreneuron_loaded()) {
206 std::vector<std::filesystem::path> paths_tried;
207 paths_tried.reserve(3);
210 const char* corenrn_lib = std::getenv(
"CORENEURONLIB");
212 std::filesystem::path
const corenrn_lib_path{corenrn_lib};
213 paths_tried.push_back(corenrn_lib_path);
214 if (std::filesystem::exists(corenrn_lib_path)) {
215 return get_handle_for_lib(corenrn_lib_path);
219 auto const corenrn_lib_name = std::string{neuron::config::shared_library_prefix}
220 .append(
"corenrnmech")
221 .append(neuron::config::shared_library_suffix);
226 auto const corenrn_lib_path = std::filesystem::current_path() /
227 neuron::config::system_processor / corenrn_lib_name;
228 paths_tried.push_back(corenrn_lib_path);
229 if (std::filesystem::exists(corenrn_lib_path)) {
230 return get_handle_for_lib(corenrn_lib_path);
236 std::filesystem::path corenrn_lib_path{
neuron_home};
237 auto const corenrn_internal_lib_name = std::string{neuron::config::shared_library_prefix}
238 .append(
"corenrnmech_internal")
239 .append(neuron::config::shared_library_suffix);
241 (corenrn_lib_path /=
"..") /=
"..";
243 (corenrn_lib_path /=
"lib") /= corenrn_internal_lib_name;
244 paths_tried.push_back(corenrn_lib_path);
245 if (std::filesystem::exists(corenrn_lib_path)) {
246 return get_handle_for_lib(corenrn_lib_path);
249 std::ostringstream oss;
250 oss <<
"Could not find CoreNEURON library, tried:";
251 for (
auto const& path: paths_tried) {
254 throw std::runtime_error(oss.str());
258 void check_coreneuron_compatibility(
void*
handle) {
260 void* cn_version_sym =
dlsym(
handle,
"corenrn_version");
261 if (!cn_version_sym) {
265 const char* cn_bbcore_read_version = (*(
const char* (*) ()) cn_version_sym)();
269 std::stringstream s_path;
271 hoc_execerror(
"Incompatible NEURON and CoreNEURON versions :", s_path.str().c_str());
DLFCN_EXPORT void * dlopen(const char *file, int mode)
DLFCN_EXPORT char * dlerror(void)
DLFCN_EXPORT int dlclose(void *handle)
DLFCN_NOINLINE DLFCN_EXPORT void * dlsym(void *handle, const char *name)
double * hoc_getarg(int narg)
IvocVect * vector_arg(int i)
double * vector_vec(IvocVect *v)
void hoc_execerror(const char *s1, const char *s2)
int vector_capacity(IvocVect *v)
handle_interface< non_owning_identifier< storage > > handle
Non-owning handle to a Mechanism instance.
Model & model()
Access the global Model instance.
neuron::model_sorted_token nrn_ensure_model_data_are_sorted()
Ensure neuron::container::* data are sorted.
short * nrn_is_artificial_
void(* nrnthread_v_transfer_)(NrnThread *)
int count_distinct(double *data, int len)
Count number of unique elements in the array.
void nrnbbcore_register_mapping()
For BBP use case, we want to write section-segment mapping to gid_3.dat file.
int nrn_dblpntr2nrncore(neuron::container::data_handle< double > dh, NrnThread &nt, int &type, int &index)
const char * bbcore_write_version
NrnMappingInfo mapinfo
mapping information
int nrndae_list_is_empty()
static double unique(void *v)
Compartment mapping information for NrnThread.
void add_sec_mapping(int gid, SecMapping *s)
add section mapping information for given gid if cell is not peviously added, create new cell mapping...
Represent main neuron object computed by single thread.
struct NrnThreadMembList * next
Section to segment mapping.
int num_electrodes
Number of electrodes per segment.
std::vector< int > segments
list of segments
std::vector< double > seglfp_factors
list of lfp factors associated with each segment
std::vector< int > sections
list sections associated with each segment
container::Node::storage & node_data()
Access the structure containing the data of all Nodes.
Field for fast_imem calculation.
bool refers_to(Container const &container) const
Query whether this generic handle points to a value from the Tag field of the given container.
std::size_t current_row() const
Get the current logical row number.
int Printf(const char *fmt, Args... args)