1 #include <../../nrnconf.h>
11 #if defined(HAVE_STDINT_H)
17 #include <unordered_map>
23 extern void sgid_alltoallv(
sgid_t* s,
int* scnt,
int* sdispl,
sgid_t* r,
int* rcnt,
int* rdispl) {
25 nrnmpi_long_alltoallv_sparse(s, scnt, sdispl, r, rcnt, rdispl);
27 nrnmpi_long_alltoallv(s, scnt, sdispl, r, rcnt, rdispl);
33 extern void sgid_alltoallv(
sgid_t* s,
int* scnt,
int* sdispl,
sgid_t* r,
int* rcnt,
int* rdispl) {
35 nrnmpi_int_alltoallv_sparse(s, scnt, sdispl, r, rcnt, rdispl);
137 extern double nrnmpi_transfer_wait_;
141 extern void sgid_alltoallv(
sgid_t*,
int*,
int*,
sgid_t*,
int*,
int*);
144 extern void nrnmpi_dbl_alltoallv_sparse(
double*,
int*,
int*,
double*,
int*,
int*);
170 #define PPList partrans_PPList
171 typedef std::vector<Point_process*>
PPList;
228 if (
pv >=
p->param &&
pv < (
p->param +
p->param_size)) {
240 if (
type ==
p->type) {
241 return p->param + ix;
244 hoc_execerr_ext(
"partrans update: could not find parameter index %d of %s",
263 for (
int i = 0;
i <
sec->nnode; ++
i) {
284 hoc_execerr_ext(
"source var sgid %lld already in use.", (
long long) sgid);
308 for (
int i = 0;
i <
n; ++
i) {
312 "Do not know the POINT_PROCESS target for source id %zd (Hint: insert target "
313 "instance of the target ref as the first argument.",
335 double x = *
getarg(iarg++);
337 hoc_execerr_ext(
"target_var sgid must be >= 0: arg %d is %g\n", iarg - 1, x);
429 NonVSrcUpdateInfo::iterator it;
448 svib.
val =
new double[svib.
cnt];
457 int tid = nd->
_nt->
id;
459 svib.
nd[svib.
cnt] = nd;
473 for (
int i = 0;
i < svib.
cnt; ++
i) {
475 (*ndvi2pd)[nd] = svib.
val +
i;
483 auto search = ndvi2pd->find(nd);
484 nrn_assert(ndvi2pd->find(nd) != ndvi2pd->end());
514 for (
i = 0;
i <
n; ++
i) {
519 "Do not know the POINT_PROCESS target for source id %lld\n"
520 "For multiple threads, the target pointer must reference a range variable\n"
521 "of a POINT_PROCESS. Note that even for a single thread, it is\n"
522 "fastest to supply a reference to the POINT_PROCESS as the first arg.",
535 for (
i = 0;
i <
n; ++
i) {
545 ttd.
tv =
new double*[ttd.
cnt];
546 ttd.
sv =
new double*[ttd.
cnt];
551 for (
i = 0;
i <
n; ++
i) {
573 auto search = ndvi2pd->find(nd);
575 ttd.
sv[
j] = search->second;
587 hoc_execerr_ext(
"No source_var for target_var sid = %lld\n", (
long long) sid);
605 for (
int i = 0;
i < svb.
cnt; ++
i) {
617 for (
i = 0;
i <
n; ++
i) {
624 nrnmpi_dbl_alltoallv_sparse(
639 hoc_execerror(
"ParallelContext.setup_transfer()",
"needs to be called.");
667 for (
int i = 0;
i < ttd.
cnt; ++
i) {
668 *(ttd.
tv[
i]) = *(ttd.
sv[
i]);
686 #define HAVEWANT_t sgid_t
687 #define HAVEWANT_alltoallv sgid_alltoallv
688 #define HAVEWANT2Int MapSgid2Int
697 "To use ParallelContext.setup_transfer when nhost > 1, NEURON must be configured with "
786 szalloc = szalloc ? szalloc : 1;
797 needsrc[needsrc_cnt++] = sid;
805 for (
size_t i = 0;
i <
sgids_.size(); ++
i) {
811 int *send_to_want_cnt, *send_to_want_displ;
813 int *recv_from_have_cnt, *recv_from_have_displ;
824 recv_from_have_displ,
828 int n = send_to_want_displ[
nhost];
830 for (
int i=0;
i <
n; ++
i) {
837 n = recv_from_have_displ[
nhost];
838 for (
int i = 0;
i <
n; ++
i) {
839 sgid_t sgid = recv_from_have[
i];
847 delete[] recv_from_have;
865 NonVSrcUpdateInfo::iterator it;
877 delete[] send_to_want;
953 "For impedance, pc.target_var requires that its first arg be a reference "
954 "to the POINT_PROCESS",
992 "number of gap junctions, %zd, not equal to number of pc.transfer_var, %zd",
1006 if (ttd && ttd->
cnt) {
1013 for (
int i = 0;
i < ttd->
cnt; ++
i) {
1021 for (
int i = 0;
i < ttd->
cnt; ++
i) {
1059 for (
int i = 0;
i < _nt->
end; ++
i) {
1073 for (
int i = 0;
i < _nt->
end; ++
i) {
1125 if (gi ==
nullptr) {
1133 if (
g.src_sid.empty() &&
g.tar_sid.empty()) {
1144 int ntar = int(
g.tar_sid.size());
1145 int nsrc = int(
g.src_sid.size());
1146 fprintf(f,
"%d ntar\n", ntar);
1147 fprintf(f,
"%d nsrc\n", nsrc);
1150 #define CHKPNT fprintf(f, "chkpnt %d\n", chkpnt++);
1152 if (!
g.src_sid.empty()) {
1154 CHKPNT fwrite(
g.src_type.data(), nsrc,
sizeof(
int), f);
1155 CHKPNT fwrite(
g.src_index.data(), nsrc,
sizeof(
int), f);
1158 if (!
g.tar_sid.empty()) {
1160 CHKPNT fwrite(
g.tar_type.data(), ntar,
sizeof(
int), f);
1161 CHKPNT fwrite(
g.tar_index.data(), ntar,
sizeof(
int), f);
1184 int tid = nt ? nt->
id : 0;
1190 g.tar_sid.push_back(sid);
1191 g.tar_type.push_back(
type);
1192 g.tar_index.push_back(ix);
1198 for (
size_t i = 0;
i <
sgids_.size(); ++
i) {
1201 int tid = nd->
_nt ? nd->
_nt->
id : 0;
1206 type = it->second.first;
1207 ix = it->second.second;
1213 ix = d - ml.
data[0];
1221 g.src_sid.push_back(sid);
1222 g.src_type.push_back(
type);
1223 g.src_index.push_back(ix);
static void nrnmpi_int_alltoallv(int *s, int *scnt, int *sdispl, int *r, int *rcnt, int *rdispl)
static void nrnmpi_dbl_alltoallv(double *s, int *scnt, int *sdispl, double *r, int *rcnt, int *rdispl)
static void nrnmpi_int_allgather(int *s, int *r, int n)
static void nrnmpi_barrier()
static int nrnmpi_int_allmax(int x)
const char * secname(Section *sec)
Section * chk_access(void)
Point_process * ob2pntproc(Object *)
sprintf(buf, " if (secondorder) {\n" " int _i;\n" " for (_i = 0; _i < %d; ++_i) {\n" " _p[_slist%d[_i]] += dt*_p[_dlist%d[_i]];\n" " }}\n", numeqn, listnum, listnum)
void hoc_execerror(const char *, const char *)
int hoc_is_object_arg(int narg)
void hoc_execerr_ext(const char *fmt,...)
printf style specification of hoc_execerror message.
char * hoc_object_name(Object *ob)
double * hoc_pgetarg(int narg)
static void have_to_want(HAVEWANT_t *have, int have_size, HAVEWANT_t *want, int want_size, HAVEWANT_t *&send_to_want, int *&send_to_want_cnt, int *&send_to_want_displ, HAVEWANT_t *&recv_from_have, int *&recv_from_have_cnt, int *&recv_from_have_displ, int(*rendezvous_rank)(HAVEWANT_t))
static int default_rendezvous(HAVEWANT_t key)
Object ** hoc_objgetarg(int)
static double nrnmpi_wtime()
int const size_t const size_t n
static philox4x32_key_t k
static double nhost(void *v)
void nrn_partrans_clear()
static Memb_list ** imped_current_ml_
static MapSgid2Int sgid2srcindex_
static int target_ptr_update_cnt_
static Node * pv2node(sgid_t ssid, double *pv)
void pargap_jacobi_rhs(double *b, double *x)
size_t nrnbbcore_gap_write(const char *path, int *group_ids)
void(* nrnthread_v_transfer_)(NrnThread *)
void pargap_jacobi_setup(int mode)
static void thread_vi_compute(NrnThread *)
static SourceViBuf * source_vi_buf_
static int n_transfer_thread_data_
int nrn_node_ptr_change_cnt_
static int * imped_current_type_
static double * non_vsrc_update(Node *nd, int type, int ix)
static int imped_current_type_count_
std::vector< double * > DblPList
static NodePList visources_
void nrn_partrans_update_ptrs()
double * nrn_recalc_ptr(double *)
static SgidList sgid2targets_
static void delete_imped_info()
static SetupTransferInfo * nrncore_transfer_info(int)
std::vector< Node * > NodePList
static int compute_parray_index(Point_process *pp, double *ptv)
static IntList target_parray_index_
std::unordered_map< sgid_t, int > MapSgid2Int
static void mpi_transfer()
std::vector< double * > DblPVec
std::vector< sgid_t > SgidList
static TransferThreadData * transfer_thread_data_
static int n_source_vi_buf_
static NonVSrcUpdateInfo non_vsrc_update_info_
static PPList target_pntlist_
static int outsrc_buf_size_
std::vector< int > IntList
static int * poutsrc_indices_
static int vptr_change_cnt_
static double ** poutsrc_
static double * tar_ptr(Point_process *pp, int index)
void(* nrnthread_vi_compute_)(NrnThread *)
static int imped_change_cnt
std::unordered_map< Node *, double * > MapNode2PDbl
static double * outsrc_buf_
void nrnmpi_setup_transfer()
static MapNode2PDbl * mk_svibuf()
static void target_ptr_update()
static void thread_transfer(NrnThread *)
std::map< sgid_t, std::pair< int, int > > NonVSrcUpdateInfo
std::vector< Point_process * > PPList
const char * bbcore_write_version
static MapSgid2Int sid2insrc_
static int target_ptr_need_update_cnt_
static int insrc_buf_size_
static double * insrc_buf_
SetupTransferInfo * nrn_get_partrans_setup_info(int ngroup, int cn_nthread, size_t cn_sidt_sz)
void(* nrnmpi_v_transfer_)()
static bool non_vsrc_setinfo(sgid_t ssid, Node *nd, double *pv)
void(* nrn_mk_transfer_thread_data_)()
Represent main neuron object computed by single thread.
struct NrnThreadMembList * next
static const char * fname(const char *name)