-
Notifications
You must be signed in to change notification settings - Fork 41
Drop MUT* macros and C support. #685
Conversation
If this is true in the current code then need to look at recent refactoring PRs. I am (pretty) sure that queues are not thread-safe and hence need mutex locks. And CI may not be revealing the issue because most/all tests are today in pure MPI mode (without use of heavy thread usage, long pending #292) |
|
OK..there is a non-macro mutex that lives alongside the queue instance here: CoreNeuron/coreneuron/network/netcvode.hpp Lines 49 to 51 in 61f3714
CoreNeuron/coreneuron/network/netcvode.cpp Lines 136 to 147 in 61f3714
It may well be the case that there are supposed to be more locks, but I don't think this PR actually removes any. |
|
Logfiles from GitLab pipeline #22353 (:white_check_mark:) have been uploaded here! Status and direct links:
|
|
Not straightforward to see which mutexes are enabled or not. In NEURON I debugged with some prints: neuronsimulator/nrntest#13 (comment) |
|
The origin of / changes to tqueue are bit older (than when I started) but I looked into the history bit - CoreNeuron/coreneuron/network/tqueue.ipp Line 34 in d2f4d3d
Not sure why coreneuron has just I don't think I have understood details with certainty yet but there needs further clarity in order to be confident about this change. We can resume on this next week. |
|
Should we not anyway redo those queues completely using stdlib queues and a proper C++ implementation? Also, probably a stupid question, but would running some tests with ThreadSanitizer help here? |
|
Logfiles from GitLab pipeline #23622 (:no_entry:) have been uploaded here! Status and direct links:
|
The MUT* macros were only used in one place, and the 0 in MUTCONSTRUCT(0) meant that the mutex was never actually used.
61f3714 to
b8e4766
Compare
|
Logfiles from GitLab pipeline #23825 (:white_check_mark:) have been uploaded here! Status and direct links:
|
I was wrong with the above comment - the TQueue implementation is derived from nrncvode/sptbinq.cpp which has locks. The issue / inconsistency in CoreNEURON was that the mutex was never constructed ( template <container C>
TQueue<C>::TQueue() {
MUTCONSTRUCT(0)
nshift_ = 0;whereas neuron has constructor with a default argument class TQueue {
public:
TQueue(TQItemPool*, int mkmut = 0);
....
TQueue::TQueue(TQItemPool* tp, int mkmut) {
MUTCONSTRUCT(mkmut)
tpool_ = tp;In the neuron source tree I don't see any TQueue instantiation with kumbhar@bbpv1:~/.../nrn/src$ grep -r "new TQueue" *
nrncvode/netcvode.cpp: tqe_ = new TQueue(tpool_, 0);
nrncvode/netcvode.cpp: d.tq_ = new TQueue(d.tpool_);
nrncvode/netcvode.cpp: p.lcv_[i].neosim_self_events_ = new TQueue();
nrncvode/netcvode.cpp: d.tqe_ = new TQueue(p[i].tpool_);
nrncvode/tqueue.cpp: TQueue* q = new TQueue(0);Does this mean we can remove all There was one more thing where I saw $ grep -r TQItemPool *
....
nrncvode/netcvode.h: TQItemPool* tpool_;
nrncvode/netcvode.cpp: tpool_ = new TQItemPool(1000, 1);
nrncvode/tqueue.h:declarePool(TQItemPool, TQItem)
# and in nrncvode/pool.h
#define declarePool(Pool,T) \
class Pool { \
public: \
Pool(long count, int mkmut = 0); \
but this doesn't interact with With above summary, I had quick call with @nrnhines to verify the origin of mutex macros and if the removal of those is safe to do. He pointed out that the next/newer iteration of original per queue mutex was This also explains why coreneuron always had In summary, the merge of this PR is safe.
I believe so and this was what attempted by Tim already with the use of std::priority_queue. This implementation is not supporting moving events which is used by
It would but such test is missing. I am creating ticket in neuron to adapt tqperf model with threads so that it can be used for such validations. |
The MUT* macros were only used in one place, and the 0 in MUTCONSTRUCT(0) meant that the mutex was never actually used. CoreNEURON Repo SHA: BlueBrain/CoreNeuron@ff93a93
Description
The
MUT*macros were only used in one place, and I believe the 0 inMUTCONSTRUCT(0)meant that the mutex was never actually used.This is partly motivated by having been led on a wild goose chase by these macros when debugging another issue...
Use certain branches for the SimulationStack CI
CI_BRANCHES:NEURON_BRANCH=master,