N_Vector N_VNewEmpty_NrnThread(long int length, int nthread, long int* sizes) { int i; N_Vector v; N_Vector_Ops ops; N_VectorContent_NrnThread content; if (!MUTCONSTRUCTED) { MUTCONSTRUCT(1) } /* Create vector */ v = (N_Vector) malloc(sizeof *v); if (v == NULL) return(NULL); /* Create vector operation structure */ ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops)); if (ops == NULL) {free(v);return(NULL);} ops->nvclone = N_VClone_NrnThread; ops->nvdestroy = N_VDestroy_NrnThread; ops->nvspace = N_VSpace_NrnThread; ops->nvgetarraypointer = N_VGetArrayPointer_NrnThread; ops->nvsetarraypointer = N_VSetArrayPointer_NrnThread; ops->nvlinearsum = N_VLinearSum_NrnThread; ops->nvconst = N_VConst_NrnThread; ops->nvprod = N_VProd_NrnThread; ops->nvdiv = N_VDiv_NrnThread; ops->nvscale = N_VScale_NrnThread; ops->nvabs = N_VAbs_NrnThread; ops->nvinv = N_VInv_NrnThread; ops->nvaddconst = N_VAddConst_NrnThread; ops->nvdotprod = N_VDotProd_NrnThread; ops->nvmaxnorm = N_VMaxNorm_NrnThread; ops->nvwrmsnormmask = N_VWrmsNormMask_NrnThread; ops->nvwrmsnorm = N_VWrmsNorm_NrnThread; ops->nvmin = N_VMin_NrnThread; ops->nvwl2norm = N_VWL2Norm_NrnThread; ops->nvl1norm = N_VL1Norm_NrnThread; ops->nvcompare = N_VCompare_NrnThread; ops->nvinvtest = N_VInvTest_NrnThread; ops->nvconstrmask = N_VConstrMask_NrnThread; ops->nvminquotient = N_VMinQuotient_NrnThread; /* Create content */ content = (N_VectorContent_NrnThread) malloc(sizeof(struct _N_VectorContent_NrnThread)); if (content == NULL) {free(ops);free(v);return(NULL);} content->length = length; content->nt = nthread; content->own_data = FALSE; content->data = (N_Vector*) malloc(sizeof(N_Vector)*nthread); if (content->data == NULL) { free(ops); free(v); free(content); return(NULL);} for (i=0; i < nthread; ++i) { content->data[i] = NULL; } /* Attach content and ops */ v->content = content; v->ops = ops; return(v); }
VoidPQueue::VoidPQueue(int n) { MUTCONSTRUCT(1); head_ = 0; tail_ = 0; size_ = (n > 0) ? n : 10; q_ = new void*[size_]; type_ = new int[size_]; }
SelfQueue::SelfQueue(TQItemPool* tp, int mkmut) { MUTCONSTRUCT(mkmut) tpool_ = tp; head_ = nil; }
static MUTDEC void nrnran123_mutconstruct() { if (!mut_) { MUTCONSTRUCT(1); } }
void nrn_spike_exchange_init() { // printf("nrn_spike_exchange_init\n"); if (!nrn_need_npe()) { return; } alloc_mpi_space(); // printf("nrnmpi_use=%d active=%d\n", nrnmpi_use, active_); std::map<int, InputPreSyn*>::iterator gid2in_it; usable_mindelay_ = mindelay_; #if NRN_MULTISEND if (use_multisend_ && n_multisend_interval == 2) { usable_mindelay_ *= 0.5; } #endif if (nrn_nthread > 1) { usable_mindelay_ -= dt; } if ((usable_mindelay_ < 1e-9) || (usable_mindelay_ < dt)) { if (nrnmpi_myid == 0) { hoc_execerror("usable mindelay is 0", "(or less than dt for fixed step method)"); } else { return; } } #if TBUFSIZE itbuf_ = 0; #endif #if NRN_MULTISEND if (use_multisend_) { nrn_multisend_init(); } #endif if (n_npe_ != nrn_nthread) { if (npe_) { delete[] npe_; } npe_ = new NetParEvent[nrn_nthread]; n_npe_ = nrn_nthread; } for (int i = 0; i < nrn_nthread; ++i) { npe_[i].ithread_ = i; npe_[i].wx_ = 0.; npe_[i].ws_ = 0.; npe_[i].send(t, net_cvode_instance, nrn_threads + i); } #if NRNMPI if (use_compress_) { idxout_ = 2; t_exchange_ = t; dt1_ = rev_dt; usable_mindelay_ = floor(mindelay_ * dt1_ + 1e-9) * dt; assert(usable_mindelay_ >= dt && (usable_mindelay_ * dt1_) < 255); } else { #if nrn_spikebuf_size > 0 if (spbufout_) { spbufout_->nspike = 0; } #endif } nout_ = 0; nsend_ = nsendmax_ = nrecv_ = nrecv_useful_ = 0; if (nrnmpi_numprocs > 0) { if (nrn_nthread > 0) { #if defined(_OPENMP) if (!mut_) { MUTCONSTRUCT(1) } #endif } else { MUTDESTRUCT } }