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

Commit 1e3a3a2

Browse files
author
Nicolas Cornu
authored
Removing NRNSTATS and ifdef OPENMP (#385)
* Clean netcon / netpar implementation * Remove NRNSTATS * Clean macros needed for OMPMutex by providing empty implementation * Put override on overrided methods
1 parent 18f35f6 commit 1e3a3a2

File tree

7 files changed

+77
-207
lines changed

7 files changed

+77
-207
lines changed

coreneuron/io/nrn_setup.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ void (*nrn2core_all_weights_return_)(std::vector<double*>& weights);
164164
namespace coreneuron {
165165
extern corenrn_parameters corenrn_param;
166166

167-
#ifdef _OPENMP
168167
static OMP_Mutex mut;
169-
#endif
170168

171169
static size_t model_size(void);
172170

@@ -479,13 +477,7 @@ void nrn_setup(const char* filesdat,
479477
Phase1 p1;
480478
p1.read_direct(n->id);
481479
NrnThread& nt = *n;
482-
{
483-
#ifdef _OPENMP
484-
p1.populate(nt, mut);
485-
#else
486-
p1.populate(nt);
487-
#endif
488-
}
480+
p1.populate(nt, mut);
489481
});
490482
}
491483

@@ -538,9 +530,7 @@ void setup_ThreadData(NrnThread& nt) {
538530
ml->_thread = (ThreadDatum*)ecalloc_align(mf.thread_size_, sizeof(ThreadDatum));
539531
if (mf.thread_mem_init_) {
540532
{
541-
#ifdef _OPENMP
542533
const std::lock_guard<OMP_Mutex> lock(mut);
543-
#endif
544534
(*mf.thread_mem_init_)(ml->_thread);
545535
}
546536
}
@@ -860,13 +850,8 @@ void read_phase1(NrnThread& nt, UserParams& userParams) {
860850
Phase1 p1;
861851
p1.read_file(userParams.file_reader[nt.id]);
862852

863-
{ // Protect gid2in, gid2out and neg_gid2out
864-
#ifdef _OPENMP
865-
p1.populate(nt, mut);
866-
#else
867-
p1.populate(nt);
868-
#endif
869-
}
853+
// Protect gid2in, gid2out and neg_gid2out
854+
p1.populate(nt, mut);
870855
}
871856

872857
void read_phase2(NrnThread& nt, UserParams& userParams) {

coreneuron/io/output_spikes.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,23 @@ namespace coreneuron {
6565
std::vector<double> spikevec_time;
6666
std::vector<int> spikevec_gid;
6767

68-
#ifdef _OPENMP
69-
static MUTDEC
70-
#endif
68+
static OMP_Mutex mut;
7169

72-
void
73-
mk_spikevec_buffer(int sz) {
70+
void mk_spikevec_buffer(int sz) {
7471
try {
7572
spikevec_time.reserve(sz);
7673
spikevec_gid.reserve(sz);
7774
} catch (const std::length_error& le) {
7875
std::cerr << "Lenght error" << le.what() << std::endl;
7976
}
80-
if (!MUTCONSTRUCTED) {
81-
MUTCONSTRUCT(1);
82-
}
8377
}
8478

8579
void spikevec_lock() {
86-
MUTLOCK
80+
mut.lock();
8781
}
8882

8983
void spikevec_unlock() {
90-
MUTUNLOCK
84+
mut.unlock();
9185
}
9286

9387
void local_spikevec_sort(std::vector<double>& isvect,

coreneuron/io/phase1.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ void Phase1::read_direct(int thread_id) {
4343
delete[] netcon_srcgid;
4444
}
4545

46-
#ifdef _OPENMP
4746
void Phase1::populate(NrnThread& nt, OMP_Mutex& mut) {
48-
#else
49-
void Phase1::populate(NrnThread& nt) {
50-
#endif
5147
nt.n_presyn = this->output_gids.size();
5248
nt.n_netcon = this->netcon_srcgids.size();
5349

@@ -68,9 +64,7 @@ void Phase1::populate(NrnThread& nt) {
6864
}
6965

7066
{
71-
#ifdef _OPENMP
7267
const std::lock_guard<OMP_Mutex> lock(mut);
73-
#endif
7468
// Note that the negative (type, index)
7569
// coded information goes into the neg_gid2out[tid] hash table.
7670
// See netpar.cpp for the netpar_tid_... function implementations.

coreneuron/io/phase1.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ class Phase1 {
1313
public:
1414
void read_file(FileHandler& F);
1515
void read_direct(int thread_id);
16-
#ifdef _OPENMP
1716
void populate(NrnThread& nt, OMP_Mutex& mut);
18-
#else
19-
void populate(NrnThread& nt);
20-
#endif
2117

2218
private:
2319
std::vector<int> output_gids;

coreneuron/network/netcon.hpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class DiscreteEvent {
5757
virtual ~DiscreteEvent();
5858
virtual void send(double deliverytime, NetCvode*, NrnThread*);
5959
virtual void deliver(double t, NetCvode*, NrnThread*);
60-
virtual int type() {
60+
virtual int type() const {
6161
return DiscreteEventType;
6262
}
6363
virtual bool require_checkpoint() {
@@ -81,12 +81,12 @@ class NetCon : public DiscreteEvent {
8181

8282
NetCon();
8383
virtual ~NetCon();
84-
virtual void send(double sendtime, NetCvode*, NrnThread*);
85-
virtual void deliver(double, NetCvode* ns, NrnThread*);
86-
virtual int type() {
84+
virtual void send(double sendtime, NetCvode*, NrnThread*) override;
85+
virtual void deliver(double, NetCvode* ns, NrnThread*) override;
86+
virtual int type() const override {
8787
return NetConType;
8888
}
89-
virtual void pr(const char*, double t, NetCvode*);
89+
virtual void pr(const char*, double t, NetCvode*) override;
9090
};
9191

9292
class SelfEvent : public DiscreteEvent {
@@ -98,12 +98,12 @@ class SelfEvent : public DiscreteEvent {
9898

9999
SelfEvent();
100100
virtual ~SelfEvent();
101-
virtual void deliver(double, NetCvode*, NrnThread*);
102-
virtual int type() {
101+
virtual void deliver(double, NetCvode*, NrnThread*) override;
102+
virtual int type() const override {
103103
return SelfEventType;
104104
}
105105

106-
virtual void pr(const char*, double t, NetCvode*);
106+
virtual void pr(const char*, double t, NetCvode*) override;
107107

108108
private:
109109
void call_net_receive(NetCvode*);
@@ -138,13 +138,13 @@ class PreSyn : public ConditionEvent {
138138

139139
PreSyn();
140140
virtual ~PreSyn();
141-
virtual void send(double sendtime, NetCvode*, NrnThread*);
142-
virtual void deliver(double, NetCvode*, NrnThread*);
143-
virtual int type() {
141+
virtual void send(double sendtime, NetCvode*, NrnThread*) override;
142+
virtual void deliver(double, NetCvode*, NrnThread*) override;
143+
virtual int type() const override {
144144
return PreSynType;
145145
}
146146

147-
virtual double value(NrnThread*);
147+
virtual double value(NrnThread*) override;
148148
void record(double t);
149149
#if NRN_MULTISEND
150150
int multisend_index_;
@@ -158,9 +158,9 @@ class InputPreSyn : public DiscreteEvent {
158158

159159
InputPreSyn();
160160
virtual ~InputPreSyn();
161-
virtual void send(double sendtime, NetCvode*, NrnThread*);
162-
virtual void deliver(double, NetCvode*, NrnThread*);
163-
virtual int type() {
161+
virtual void send(double sendtime, NetCvode*, NrnThread*) override;
162+
virtual void deliver(double, NetCvode*, NrnThread*) override;
163+
virtual int type() const override {
164164
return InputPreSynType;
165165
}
166166
#if NRN_MULTISEND
@@ -174,14 +174,14 @@ class NetParEvent : public DiscreteEvent {
174174
double wx_, ws_; // exchange time and "spikes to Presyn" time
175175

176176
NetParEvent();
177-
virtual ~NetParEvent();
178-
virtual void send(double, NetCvode*, NrnThread*);
179-
virtual void deliver(double, NetCvode*, NrnThread*);
180-
virtual int type() {
177+
virtual ~NetParEvent() = default;
178+
virtual void send(double, NetCvode*, NrnThread*) override;
179+
virtual void deliver(double, NetCvode*, NrnThread*) override;
180+
virtual int type() const override {
181181
return NetParEventType;
182182
}
183183

184-
virtual void pr(const char*, double t, NetCvode*);
184+
virtual void pr(const char*, double t, NetCvode*) override;
185185
};
186186
} // namespace coreneuron
187187
#endif

0 commit comments

Comments
 (0)