22 #define RTLD_NODELETE 0 24 extern void* dlopen_noerr(
const char*
name,
int mode);
25 #define dlopen dlopen_noerr 26 extern void*
dlsym(
void* handle,
const char*
name);
27 extern int dlclose(
void* handle);
31 #if defined(HAVE_DLFCN_H) 39 #define RTLD_NODELETE 0 56 hoc_execerror(
"CoreNEURON cannot simulate a model that contains extra LinearMechanism or RxD equations",
NULL);
59 hoc_execerror(
"CoreNEURON cannot simulate a model that contains the extracellular mechanism",
NULL);
68 hoc_execerror(
"NEURON model for CoreNEURON requires cvode.cache_efficient(1)",
NULL);
71 hoc_execerror(
"NEURON model internal structures for CoreNEURON are out of date. Make sure call to finitialize(...) is after cvode.cache_efficient(1))",
NULL);
82 std::vector<double>
v;
83 v.assign(data, data + len);
84 std::sort(v.begin(), v.end());
102 int gid = *hoc_getarg(1);
105 std::string
name = std::string(hoc_gargstr(2));
118 std::cout <<
"Error: Section and Segment mapping vectors should have same size!\n";
126 smap->
sections.assign(sections, sections+nseg);
127 smap->
segments.assign(segments, segments+nseg);
135 std::ifstream f(path.c_str());
163 if (pd >= ml1->
data[0] && pd < (ml1->
data[0] + nn)) {
165 index = pd - ml1->
data[0];
170 return type == 0 ? 1 : 0;
174 #if defined(HAVE_DLFCN_H) 180 bool is_coreneuron_loaded() {
181 bool is_loaded =
false;
185 void* fn =
dlsym(handle,
"corenrn_embedded_run");
186 is_loaded = fn ==
NULL ? false :
true;
194 void* get_handle_for_lib(
const char* path) {
199 hoc_execerror(
"Could not dlopen CoreNEURON mechanism library : ", path);
205 void* get_coreneuron_handle() {
207 if (is_coreneuron_loaded()) {
212 const char* corenrn_lib =
getenv(
"CORENEURONLIB");
214 return get_handle_for_lib(corenrn_lib);
219 std::string corenrn_mechlib_name(
"libcorenrnmech.dll");
220 #elif defined(DARWIN) 221 std::string corenrn_mechlib_name(
"libcorenrnmech.dylib");
223 std::string corenrn_mechlib_name(
"libcorenrnmech.so");
228 char pwd[FILENAME_MAX];
229 if (getcwd(pwd, FILENAME_MAX) ==
NULL) {
232 std::stringstream s_path;
233 s_path << pwd <<
"/" << NRNHOSTCPU <<
"/" << corenrn_mechlib_name;
234 std::string path = s_path.str();
237 return get_handle_for_lib(path.c_str());
243 s_path <<
neuron_home <<
"/lib/" << corenrn_mechlib_name;
245 s_path <<
neuron_home <<
"/../../lib/" << corenrn_mechlib_name;
254 return get_handle_for_lib(path.c_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());
277 void* cn_nrnunit_use_legacy_sym =
dlsym(handle,
"corenrn_units_use_legacy");
278 if (!cn_nrnunit_use_legacy_sym) {
279 hoc_execerror(
"Could not get symbol corenrn_units_use_legacy from CoreNEURON",
NULL);
281 bool cn_nrnunit_use_legacy = (*(bool(*)())cn_nrnunit_use_legacy_sym)();
283 hoc_execerror(
"nrnunit_use_legacy() inconsistent with CORENRN_ENABLE_LEGACY_UNITS",
NULL);
int count_distinct(double *data, int len)
Count number of unique elements in the array.
Section to segment mapping.
struct NrnThreadMembList * next
const char * dlerror(void)
int nrn_dblpntr2nrncore(double *pd, NrnThread &nt, int &type, int &index)
int nrndae_list_is_empty()
Represent main neuron object computed by single thread.
short * nrn_is_artificial_
int dlclose(void *handle)
NrnMappingInfo mapinfo
mapping information
_nrn_Fast_Imem * _nrn_fast_imem
void nrnbbcore_register_mapping()
For BBP use case, we want to write section-segment mapping to gid_3.dat file.
void hoc_execerror(const char *, const char *)
char * getenv(const char *s)
Compartment mapping information for NrnThread.
void * dlopen(const char *path, int mode)
int * nrn_prop_param_size_
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...
bool file_exist(const std::string &path)
Check if file with given path exist.
int vector_capacity(Vect *v)
static double unique(void *v)
double * vector_vec(Vect *v)
void * dlsym(void *handle, const char *symbol)
void(* nrnthread_v_transfer_)(NrnThread *)
std::vector< int > segments
list of segments
const char * bbcore_write_version
std::vector< int > sections
list sections associated with each segment