Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coreneuron/coreneuron.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
* Includes all headers required to communicate and run all methods
* described in CoreNeuron, neurox, and mod2c C-generated mechanisms
* functions.
**/
**/

#ifndef CORENEURON_H
#define CORENEURON_H
Expand Down
4 changes: 1 addition & 3 deletions coreneuron/nrniv/multisend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ of spikes sent is equal to the number of spikes sent.
// which has the greatest amount of overlap between computation
// and communication.


int use_multisend_;
int use_phase2_;
int n_multisend_interval = 2;
Expand Down Expand Up @@ -104,7 +103,6 @@ class Multisend_ReceiveBuffer {
Phase2Buffer* phase2_buffer_;
};


#define MULTISEND_INTERVAL 2
static Multisend_ReceiveBuffer* multisend_receive_buffer[MULTISEND_INTERVAL];
static int current_rbuf, next_rbuf;
Expand Down Expand Up @@ -468,4 +466,4 @@ void nrn_multisend_setup() {
#endif
}

#endif //NRN_MULTISEND
#endif // NRN_MULTISEND
2 changes: 1 addition & 1 deletion coreneuron/nrniv/multisend_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,4 +703,4 @@ static int setup_target_lists(int use_phase2, int** r_return) {
return sz;
}

#endif //NRN_MULTISEND
#endif // NRN_MULTISEND
26 changes: 13 additions & 13 deletions coreneuron/nrniv/output_spikes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
#include <sstream>
#include <string.h>
#include <stdexcept> // std::lenght_error
#include <stdexcept> // std::lenght_error
#include <vector>
#include "coreneuron/nrnconf.h"
#include "coreneuron/nrniv/nrniv_decl.h"
Expand All @@ -47,10 +47,10 @@ static MUTDEC
void
mk_spikevec_buffer(int sz) {
try {
spikevec_time.reserve(sz);
spikevec_gid.reserve(sz);
spikevec_time.reserve(sz);
spikevec_gid.reserve(sz);
} catch (const std::length_error& le) {
std::cerr << "Lenght error" << le.what() << std::endl;
std::cerr << "Lenght error" << le.what() << std::endl;
}
MUTCONSTRUCT(1);
}
Expand All @@ -74,7 +74,7 @@ void output_spikes_parallel(const char* outpath) {
std::string fname = ss.str();

// remove if file already exist
if(nrnmpi_myid == 0) {
if (nrnmpi_myid == 0) {
remove(fname.c_str());
}
nrnmpi_barrier();
Expand All @@ -83,9 +83,9 @@ void output_spikes_parallel(const char* outpath) {
const int SPIKE_RECORD_LEN = 64;
unsigned num_spikes = spikevec_gid.size();
unsigned num_bytes = (sizeof(char) * num_spikes * SPIKE_RECORD_LEN);
char *spike_data = (char*) malloc(num_bytes);
char* spike_data = (char*)malloc(num_bytes);

if(spike_data == NULL) {
if (spike_data == NULL) {
printf("Error while writing spikes due to memory allocation\n");
return;
}
Expand All @@ -95,7 +95,7 @@ void output_spikes_parallel(const char* outpath) {

// populate buffer with all spike entries
char spike_entry[SPIKE_RECORD_LEN];
for(unsigned i = 0; i < num_spikes; i++) {
for (unsigned i = 0; i < num_spikes; i++) {
snprintf(spike_entry, 64, "%.8g\t%d\n", spikevec_time[i], spikevec_gid[i]);
strcat(spike_data, spike_entry);
}
Expand All @@ -113,14 +113,15 @@ void output_spikes_parallel(const char* outpath) {
MPI_Status status;

// ibm mpi (bg-q) expects char* instead of const char* (even though it's standard)
int op_status = MPI_File_open(MPI_COMM_WORLD, (char*) fname.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
if(op_status != MPI_SUCCESS && nrnmpi_myid == 0) {
int op_status = MPI_File_open(MPI_COMM_WORLD, (char*)fname.c_str(),
MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);
if (op_status != MPI_SUCCESS && nrnmpi_myid == 0) {
std::cerr << "Error while opening spike output file " << fname << std::endl;
abort();
}

op_status = MPI_File_write_at_all(fh, offset, spike_data, num_chars, MPI_BYTE, &status);
if(op_status != MPI_SUCCESS && nrnmpi_myid == 0) {
if (op_status != MPI_SUCCESS && nrnmpi_myid == 0) {
std::cerr << "Error while writing spike output " << std::endl;
abort();
}
Expand Down Expand Up @@ -152,7 +153,7 @@ void output_spikes_serial(const char* outpath) {

void output_spikes(const char* outpath) {
#if NRNMPI
if(nrnmpi_initialized()) {
if (nrnmpi_initialized()) {
output_spikes_parallel(outpath);
} else {
output_spikes_serial(outpath);
Expand All @@ -162,7 +163,6 @@ void output_spikes(const char* outpath) {
#endif
}


void validation(std::vector<std::pair<double, int> >& res) {
for (unsigned i = 0; i < spikevec_gid.size(); ++i)
if (spikevec_gid[i] > -1)
Expand Down
14 changes: 7 additions & 7 deletions coreneuron/nrniv/patternstim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void nrn_mkPatternStim(const char* fname) {
}

// if there is empty thread then return, don't need patternstim
if(nrn_threads == NULL || nrn_threads->ncell == 0) {
if (nrn_threads == NULL || nrn_threads->ncell == 0) {
return;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ void nrn_mkPatternStim(const char* fname) {
// comparator to sort spikes based on time
typedef std::pair<double, int> spike_type;
static bool spike_comparator(const spike_type& l, const spike_type& r) {
return l.first < r.first;
return l.first < r.first;
}

size_t read_raster_file(const char* fname, double** tvec, int** gidvec) {
Expand All @@ -146,15 +146,15 @@ size_t read_raster_file(const char* fname, double** tvec, int** gidvec) {
// pattern.mod expects sorted spike raster (this is to avoid
// injecting all events at the begining of the simulation).
// sort spikes according to time
std::sort(spikes.begin(), spikes.end(), spike_comparator);
std::sort(spikes.begin(), spikes.end(), spike_comparator);

// fill gid and time vectors
*tvec = (double*)emalloc(spikes.size() * sizeof(double));
*gidvec = (int*)emalloc(spikes.size() * sizeof(int));

for(size_t i = 0; i < spikes.size(); i++) {
(*tvec)[i] = spikes[i].first;
(*gidvec)[i] = spikes[i].second;
for (size_t i = 0; i < spikes.size(); i++) {
(*tvec)[i] = spikes[i].first;
(*gidvec)[i] = spikes[i].second;
}

return spikes.size();
Expand All @@ -171,7 +171,7 @@ Point_process* nrn_artcell_instantiate(const char* mechname) {
int type = nrn_get_mechtype(mechname);
NrnThread* nt = nrn_threads + 0;

//printf("nrn_artcell_instantiate %s type=%d\n", mechname, type);
// printf("nrn_artcell_instantiate %s type=%d\n", mechname, type);

// see nrn_setup.cpp:read_phase2 for how it creates NrnThreadMembList instances.
// create and append to nt.tml
Expand Down
11 changes: 7 additions & 4 deletions coreneuron/nrnoc/solve_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ THE POSSIBILITY OF SUCH DAMAGE.

int use_solve_interleave;

static void triang(NrnThread *), bksub(NrnThread *);
static void triang(NrnThread*), bksub(NrnThread*);

/* solve the matrix equation */
void nrn_solve_minimal(NrnThread* _nt) {
Expand Down Expand Up @@ -63,9 +63,12 @@ static void triang(NrnThread* _nt) {
#endif

/** @todo: just for benchmarking, otherwise produces wrong results */
#pragma acc parallel loop seq present( \
vec_a[0 : i3], vec_b[0 : i3], vec_d[0 : i3], vec_rhs[0 : i3], parent_index[0 : i3]) \
async(stream_id) if (_nt->compute_gpu)
// clang-format off
#pragma acc parallel loop seq present( \
vec_a[0:i3], vec_b[0:i3], vec_d[0:i3], \
vec_rhs[0:i3], parent_index[0:i3]) \
async(stream_id) if (_nt->compute_gpu)
// clang-format on
for (i = i3 - 1; i >= i2; --i) {
p = vec_a[i] / vec_d[i];
vec_d[parent_index[i]] -= p * vec_b[i];
Expand Down
7 changes: 3 additions & 4 deletions coreneuron/scopmath_core/dimplic.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* time.
* \todo: eulerfun/difun are legacy macros and can be replaced with
* actual steer function for euler/derivimplicit methods.
*/
*/

#include "coreneuron/mech/cfile/scoplib.h"
#include "coreneuron/mech/mod2c_core_thread.h"
Expand Down Expand Up @@ -44,16 +44,15 @@ int nrn_kinetic_steer(int fun, SparseObj* so, double* rhs, _threadargsproto_) {
// derived from nrn/src/scopmath/euler.c
// updated for aos/soa layout index
int euler_thread(int neqn, int* var, int* der, DIFUN fun, _threadargsproto_) {

double dt = _nt->_dt;
int i;

/* calculate the derivatives */
eulerfun(fun);
eulerfun(fun);

/* update dependent variables */
for (i = 0; i < neqn; i++)
_p[var[i]*_STRIDE] += dt * (_p[der[i]*_STRIDE]);
_p[var[i] * _STRIDE] += dt * (_p[der[i] * _STRIDE]);

return 0;
}