Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit ba64cfa

Browse files
authored
Bug fix in parallel spike sorting and memory leak fixes (#120)
1 parent d247fe6 commit ba64cfa

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

coreneuron/nrniv/nrn_setup.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,9 @@ void setup_ThreadData(NrnThread& nt) {
805805
MUTLOCK (*mf.thread_mem_init_)(ml->_thread);
806806
MUTUNLOCK
807807
}
808-
} else
808+
} else {
809809
ml->_thread = NULL;
810+
}
810811
}
811812
}
812813

@@ -972,6 +973,11 @@ void nrn_cleanup(bool clean_ion_global_map) {
972973
ml->_permute = NULL;
973974
}
974975

976+
if (ml->_thread) {
977+
free (ml->_thread);
978+
ml->_thread = NULL;
979+
}
980+
975981
NetReceiveBuffer_t* nrb = ml->_net_receive_buffer;
976982
if (nrb) {
977983
if (nrb->_size) {

coreneuron/nrniv/output_spikes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ void sort_spikes(std::vector<double>& spikevec_time, std::vector<int>& spikevec_
103103
std::vector<int> rcv_dsps(nrnmpi_numprocs);
104104

105105
double bin_t = (max_time - min_time) / nrnmpi_numprocs;
106+
bin_t = bin_t ? bin_t : 1;
106107
// first find number of spikes in each time window
107108
for (const auto& st : spikevec_time) {
108109
int idx = (int)(st - min_time) / bin_t;
@@ -199,6 +200,7 @@ void output_spikes_parallel(const char* outpath) {
199200
}
200201

201202
MPI_File_close(&fh);
203+
free(spike_data);
202204
}
203205
#endif
204206

coreneuron/nrnmpi/nrnmpi.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ void nrnmpi_finalize(void) {
131131
int flag = 0;
132132
MPI_Initialized(&flag);
133133
if (flag) {
134+
MPI_Comm_free(&nrnmpi_world_comm);
135+
MPI_Comm_free(&nrnmpi_comm);
136+
MPI_Comm_free(&nrn_bbs_comm);
134137
MPI_Finalize();
135138
}
136139
}

0 commit comments

Comments
 (0)