Ejemplo n.º 1
0
void nrn2ncs_outputevent(int gid, double firetime) {
    if (!active_) {
        return;
    }
    MUTLOCK
    if (use_compress_) {
        nout_++;
        int i = idxout_;
        idxout_ += 1 + localgid_size_;
        if (idxout_ >= spfixout_capacity_) {
            spfixout_capacity_ *= 2;
            spfixout_ =
                (unsigned char*)erealloc(spfixout_, spfixout_capacity_ * sizeof(unsigned char));
        }
        // printf("%d nrnncs_outputevent %d %.20g %.20g %d\n", nrnmpi_myid, gid, firetime,
        // t_exchange_,
        //(int)((unsigned char)((firetime - t_exchange_)*dt1_ + .5)));
        spfixout_[i++] = (unsigned char)((firetime - t_exchange_) * dt1_ + .5);
        // printf("%d idx=%d firetime=%g t_exchange_=%g spfixout=%d\n", nrnmpi_myid, i, firetime,
        // t_exchange_, (int)spfixout_[i-1]);
        sppk(spfixout_ + i, gid);
        // printf("%d idx=%d gid=%d spupk=%d\n", nrnmpi_myid, i, gid, spupk(spfixout_+i));
    } else {
#if nrn_spikebuf_size == 0
        int i = nout_++;
        if (i >= ocapacity_) {
            ocapacity_ *= 2;
            spikeout_ = (NRNMPI_Spike*)erealloc(spikeout_, ocapacity_ * sizeof(NRNMPI_Spike));
        }
        // printf("%d cell %d in slot %d fired at %g\n", nrnmpi_myid, gid, i, firetime);
        spikeout_[i].gid = gid;
        spikeout_[i].spiketime = firetime;
#else
        int i = nout_++;
        if (i >= nrn_spikebuf_size) {
            i -= nrn_spikebuf_size;
            if (i >= ocapacity_) {
                ocapacity_ *= 2;
                spikeout_ =
                    (NRNMPI_Spike*)hoc_Erealloc(spikeout_, ocapacity_ * sizeof(NRNMPI_Spike));
                hoc_malchk();
            }
            spikeout_[i].gid = gid;
            spikeout_[i].spiketime = firetime;
        } else {
            spbufout_->gid[i] = gid;
            spbufout_->spiketime[i] = firetime;
        }
#endif
    }
    MUTUNLOCK
    // printf("%d cell %d in slot %d fired at %g\n", nrnmpi_myid, gid, i, firetime);
}
Ejemplo n.º 2
0
Archivo: cprop.c Proyecto: nrnhines/nrn
Datum* nrn_prop_datum_alloc(int type, int count, Prop* p) {
	Datum* ppd = (Datum*)hoc_Ecalloc(count, sizeof(Datum)); hoc_malchk();
	return ppd;
}
Ejemplo n.º 3
0
Archivo: cprop.c Proyecto: nrnhines/nrn
double* nrn_prop_data_alloc(int type, int count, Prop* p) {
	double* pd = (double*)hoc_Ecalloc(count, sizeof(double)); hoc_malchk();
	return pd;
}
Ejemplo n.º 4
0
int nrnmpi_spike_exchange() {
	int i, n;
#if nrn_spikebuf_size > 0
	int n1, novfl;
#endif
	if (!displs) {
		np = nrnmpi_numprocs;
		displs = (int*)emalloc(np*sizeof(int));
		displs[0] = 0;
#if nrn_spikebuf_size > 0		
		make_spikebuf_type();
#endif
	}
#if nrn_spikebuf_size == 0
	MPI_Allgather(&nout_, 1, MPI_INT, nin_, 1, MPI_INT, nrnmpi_comm);
	n = nin_[0];
	for (i=1; i < np; ++i) {
		displs[i] = n;
		n += nin_[i];
	}
	if (n) {
		if (icapacity_ < n) {
			icapacity_ = n + 10;
			free(spikein_);
			spikein_ = (NRNMPI_Spike*)emalloc(icapacity_ * sizeof(NRNMPI_Spike));
		}
		MPI_Allgatherv(spikeout_, nout_, spike_type, spikein_, nin_, displs, spike_type, nrnmpi_comm);
	}
#else
	MPI_Allgather(spbufout_, 1, spikebuf_type, spbufin_, 1, spikebuf_type, nrnmpi_comm);
	novfl = 0;
	n = spbufin_[0].nspike;
	if (n > nrn_spikebuf_size) {
		nin_[0] = n - nrn_spikebuf_size;
		novfl += nin_[0];
	}else{
		nin_[0] = 0;
	}
	for (i=1; i < np; ++i) {
		displs[i] = novfl;
		n1 = spbufin_[i].nspike;
		n += n1;
		if (n1 > nrn_spikebuf_size) {
			nin_[i] = n1 - nrn_spikebuf_size;
			novfl += nin_[i];
		}else{
			nin_[i] = 0;
		}
	}
	if (novfl) {
		if (icapacity_ < novfl) {
			icapacity_ = novfl + 10;
			free(spikein_);
			spikein_ = (NRNMPI_Spike*)hoc_Emalloc(icapacity_ * sizeof(NRNMPI_Spike)); hoc_malchk();
		}
		n1 = (nout_ > nrn_spikebuf_size) ? nout_ - nrn_spikebuf_size : 0;
		MPI_Allgatherv(spikeout_, n1, spike_type, spikein_, nin_, displs, spike_type, nrnmpi_comm);
	}
	ovfl_ = novfl;
#endif
	return n;
}
Ejemplo n.º 5
0
void *_graphgetmem(unsigned size) {
	char *p;
	p= hoc_Emalloc(size), hoc_malchk() ;
	return p;
}