nest-simulator icon indicating copy to clipboard operation
nest-simulator copied to clipboard

Correct errors in slicing of node collections

Open heplesser opened this issue 11 months ago • 9 comments

This PR fixes #3108 by providing correct NodeCollection::{rank,thread}_local_begin(() implementations for composite node collections.

To do:

  • [x] Improve documentation of algorithm for selection of first nc entry
  • [x] Extend set of tests
  • [x] Move slice_positions_if_sliced_nc() code to more suitable location

I removed the ConnBuilder refactoring (see #3106) from this PR to reduce complexity and ensure we can integrate this bug-fixing PR asap. The refactoring can then following in a later PR.

heplesser avatar Mar 04 '24 14:03 heplesser

@mlober @gtrensch This PR is ready for review now. I have reduced the scope by postponing the refactoring of ConnBuilders to use local iterators. So this is a pure bugfix PR and would be nice to get into NEST 3.7.

@diesmann You may want to check the documentation in numerics.h/cpp.

heplesser avatar Mar 07 '24 15:03 heplesser

Switching temporarily to draft again since I discovered that the "spatial" property of a layer will be returned without "position" entry if no nodes on a rank. An empty positions tuple should be returned. I will fix this shortly, the underlying algorithm is not concerned, so @gtrensch you can proceed with the review.

heplesser avatar Mar 14 '24 14:03 heplesser

@jstapmanns @gtrensch It turned out that there was a corner case I had overlooked, namely when the step was a multiple of the period or the other way around. There were both technical errors (returning invalid_index and operating on it before testing) as well as and a logical error (not using lcm(step, period) in a place that needed it). While working on fixing this, I discovered slight possiblities for simplification, and I improved documentation. I also introduced local variables in one place to make the code more explicit and hopefully more readable. The tests in test_issue_3108 are much extended and are now run for 1, 3 and 4 MPI processes.

heplesser avatar Mar 15 '24 10:03 heplesser

@heplesser I have run some tests. Unfortunately, there is still a problem when using a mask:

nest.lib.hl_api_exceptions.Invalid NodeCollection iterator (composite element beyond specified end element): Invalid NodeCollection iterator (composite element beyond specified end element) in SLI function GetMetadata_g:

The problem occurs in the first test case of Miriam's test script when running with 3 MPI processes.

gtrensch avatar Mar 18 '24 18:03 gtrensch

@heplesser I have run some tests. Unfortunately, there is still a problem when using a mask:

nest.lib.hl_api_exceptions.Invalid NodeCollection iterator (composite element beyond specified end element): Invalid NodeCollection iterator (composite element beyond specified end element) in SLI function GetMetadata_g:

The problem occurs in the first test case of Miriam's test script when running with 3 MPI processes.

@gtrensch Ignore my previous (now edited) post, I can reproduce the problem now.

heplesser avatar Mar 18 '24 22:03 heplesser

@gtrensch I understood the problem now. The problem is that parts_[pix].size() here returns the full size of the underlying node collection (before picking out the one node), instead of 1. I am currently evaluating how to solve this, hope to have a solution over lunch.

heplesser avatar Mar 19 '24 09:03 heplesser

Making progress, but some problems remain, so back to draft.

heplesser avatar Mar 21 '24 12:03 heplesser

@gtrensch @jstapmanns @diesmann After much hard work, I believe I have solved all problems now and that the testsuite is broad enough to cover all eventualities. Kindly review the new version of the PR. I suggest you start with the documentation near the beginning of node_collection.h.

heplesser avatar Apr 19 '24 13:04 heplesser

@gtrensch @jstapmanns Ping!

heplesser avatar May 06 '24 09:05 heplesser

The author of the original model with which the problem was originally discovered has reported that the full model now works perfectly!

gtrensch avatar May 16 '24 10:05 gtrensch