22 #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 hoc_execerror(
"NEURON model for CoreNEURON requires cvode.cache_efficient(1)",
NULL);
59 "NEURON model internal structures for CoreNEURON are out of date. Make sure call to "
60 "finitialize(...) is after cvode.cache_efficient(1))",
72 std::vector<double>
v;
74 std::sort(
v.begin(),
v.end());
91 int gid = *hoc_getarg(1);
94 std::string
name = std::string(hoc_gargstr(2));
107 std::cout <<
"Error: Section and Segment mapping vectors should have same size!\n";
115 smap->
sections.assign(sections, sections + nseg);
116 smap->
segments.assign(segments, segments + nseg);
124 std::ifstream f(path.c_str());
155 if (pd >= ml1->
data[0] && pd < (ml1->
data[0] + nn)) {
162 return type == 0 ? 1 : 0;
166 #if defined(HAVE_DLFCN_H)
172 bool is_coreneuron_loaded() {
173 bool is_loaded =
false;
177 void* fn =
dlsym(handle,
"corenrn_embedded_run");
178 is_loaded = fn ==
NULL ? false :
true;
186 void* get_handle_for_lib(
const char* path) {
191 hoc_execerror(
"Could not dlopen CoreNEURON mechanism library : ", path);
197 void* get_coreneuron_handle() {
199 if (is_coreneuron_loaded()) {
204 const char* corenrn_lib =
getenv(
"CORENEURONLIB");
206 return get_handle_for_lib(corenrn_lib);
211 std::string corenrn_mechlib_name(
"libcorenrnmech.dll");
212 #elif defined(DARWIN)
213 std::string corenrn_mechlib_name(
"libcorenrnmech.dylib");
215 std::string corenrn_mechlib_name(
"libcorenrnmech.so");
220 char pwd[FILENAME_MAX];
221 if (getcwd(pwd, FILENAME_MAX) ==
NULL) {
224 std::stringstream s_path;
225 s_path << pwd <<
"/" << NRNHOSTCPU <<
"/" << corenrn_mechlib_name;
226 std::string path = s_path.str();
229 return get_handle_for_lib(path.c_str());
235 s_path <<
neuron_home <<
"/lib/" << corenrn_mechlib_name;
237 s_path <<
neuron_home <<
"/../../lib/" << corenrn_mechlib_name;
246 return get_handle_for_lib(path.c_str());
250 void check_coreneuron_compatibility(
void* handle) {
252 void* cn_version_sym =
dlsym(handle,
"corenrn_version");
253 if (!cn_version_sym) {
257 const char* cn_bbcore_read_version = (*(
const char* (*) ()) cn_version_sym)();
261 std::stringstream s_path;
263 hoc_execerror(
"Incompatible NEURON and CoreNEURON versions :", s_path.str().c_str());
269 void* cn_nrnunit_use_legacy_sym =
dlsym(handle,
"corenrn_units_use_legacy");
270 if (!cn_nrnunit_use_legacy_sym) {
271 hoc_execerror(
"Could not get symbol corenrn_units_use_legacy from CoreNEURON",
NULL);
273 bool cn_nrnunit_use_legacy = (*(bool (*)()) cn_nrnunit_use_legacy_sym)();
275 hoc_execerror(
"nrnunit_use_legacy() inconsistent with CORENRN_ENABLE_LEGACY_UNITS",
NULL);
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)
void hoc_execerror(const char *, const char *)
int vector_capacity(Vect *v)
double * vector_vec(Vect *v)
char * getenv(const char *s)
int * nrn_prop_param_size_
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.
const char * bbcore_write_version
bool file_exist(const std::string &path)
Check if file with given path exist.
NrnMappingInfo mapinfo
mapping information
int nrn_dblpntr2nrncore(double *pd, NrnThread &nt, int &type, int &index)
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.
_nrn_Fast_Imem * _nrn_fast_imem
struct NrnThreadMembList * next
Section to segment mapping.
std::vector< int > segments
list of segments
std::vector< int > sections
list sections associated with each segment