Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.2.2] -D_GLIBCXX_ASSERTIONS unit test crash + performance issues #917

Closed
sanjayankur31 opened this issue Dec 8, 2019 · 18 comments · Fixed by #919
Closed

[0.2.2] -D_GLIBCXX_ASSERTIONS unit test crash + performance issues #917

sanjayankur31 opened this issue Dec 8, 2019 · 18 comments · Fixed by #919
Assignees
Labels
bug code quality packaging Installation from source and production of distro packages, python packages.

Comments

@sanjayankur31
Copy link

I'm seeing a crash while running the unit tests:

+ LD_LIBRARY_PATH=:./lib/
+ ./bin/unit
[==========] Running 697 tests from 116 test cases.
[----------] Global test environment set-up.
[----------] 14 tests from algorithms
[ RUN      ] algorithms.sum
[       OK ] algorithms.sum (0 ms)
[ RUN      ] algorithms.make_index
[       OK ] algorithms.make_index (0 ms)
[ RUN      ] algorithms.minimal_degree
[       OK ] algorithms.minimal_degree (0 ms)
[ RUN      ] algorithms.is_strictly_monotonic_increasing
[       OK ] algorithms.is_strictly_monotonic_increasing (0 ms)
[ RUN      ] algorithms.is_strictly_monotonic_decreasing
[       OK ] algorithms.is_strictly_monotonic_decreasing (0 ms)
[ RUN      ] algorithms.all_positive
[       OK ] algorithms.all_positive (0 ms)
[ RUN      ] algorithms.all_negative
[       OK ] algorithms.all_negative (0 ms)
[ RUN      ] algorithms.has_contiguous_compartments
[       OK ] algorithms.has_contiguous_compartments (0 ms)
[ RUN      ] algorithms.is_unique
[       OK ] algorithms.is_unique (0 ms)
[ RUN      ] algorithms.child_count
[       OK ] algorithms.child_count (0 ms)
[ RUN      ] algorithms.branches
[       OK ] algorithms.branches (0 ms)
[ RUN      ] algorithms.index_into
[       OK ] algorithms.index_into (0 ms)
[ RUN      ] algorithms.binary_find
[       OK ] algorithms.binary_find (0 ms)
[ RUN      ] algorithms.binary_find_convert
[       OK ] algorithms.binary_find_convert (0 ms)
[----------] 14 tests from algorithms (0 ms total)
[----------] 12 tests from any
[ RUN      ] any.copy_construction
[       OK ] any.copy_construction (0 ms)
[ RUN      ] any.move_construction
[       OK ] any.move_construction (0 ms)
[ RUN      ] any.type
[       OK ] any.type (0 ms)
[ RUN      ] any.swap
[       OK ] any.swap (0 ms)
[ RUN      ] any.any_cast_ptr
[       OK ] any.any_cast_ptr (0 ms)
[ RUN      ] any.any_cast_ref
[       OK ] any.any_cast_ref (0 ms)
[ RUN      ] any.any_cast_rvalue
[       OK ] any.any_cast_rvalue (0 ms)
[ RUN      ] any.std_swap
[       OK ] any.std_swap (0 ms)
[ RUN      ] any.assignment_from_lvalue
[       OK ] any.assignment_from_lvalue (0 ms)
[ RUN      ] any.assignment_from_rvalue
[       OK ] any.assignment_from_rvalue (0 ms)
[ RUN      ] any.assignment_from_value
[       OK ] any.assignment_from_value (0 ms)
[ RUN      ] any.make_any
[       OK ] any.make_any (0 ms)
[----------] 12 tests from any (0 ms total)
[----------] 4 tests from any_ptr
[ RUN      ] any_ptr.ctor_and_assign
[       OK ] any_ptr.ctor_and_assign (0 ms)
[ RUN      ] any_ptr.ordering
[       OK ] any_ptr.ordering (0 ms)
[ RUN      ] any_ptr.as_and_type
[       OK ] any_ptr.as_and_type (0 ms)
[ RUN      ] any_ptr.any_cast
[       OK ] any_ptr.any_cast (0 ms)
[----------] 4 tests from any_ptr (0 ms total)
[----------] 1 test from backends
[ RUN      ] backends.gpu_test
[       OK ] backends.gpu_test (0 ms)
[----------] 1 test from backends (0 ms total)
[----------] 3 tests from double_buffer
[ RUN      ] double_buffer.exchange_and_get
[       OK ] double_buffer.exchange_and_get (0 ms)
[ RUN      ] double_buffer.assign_get_other
[       OK ] double_buffer.assign_get_other (0 ms)
[ RUN      ] double_buffer.non_pod
[       OK ] double_buffer.non_pod (0 ms)
[----------] 3 tests from double_buffer (0 ms total)
[----------] 6 tests from dry_run_context
[ RUN      ] dry_run_context.construct_distributed_context
[       OK ] dry_run_context.construct_distributed_context (0 ms)
[ RUN      ] dry_run_context.size_rank
[       OK ] dry_run_context.size_rank (0 ms)
[ RUN      ] dry_run_context.minmax
[       OK ] dry_run_context.minmax (0 ms)
[ RUN      ] dry_run_context.sum
[       OK ] dry_run_context.sum (0 ms)
[ RUN      ] dry_run_context.gather_spikes
[       OK ] dry_run_context.gather_spikes (0 ms)
[ RUN      ] dry_run_context.gather_gids
[       OK ] dry_run_context.gather_gids (0 ms)
[----------] 6 tests from dry_run_context (0 ms total)
[----------] 3 tests from compartments
[ RUN      ] compartments.div_ends
[       OK ] compartments.div_ends (0 ms)
[ RUN      ] compartments.div_sample
[       OK ] compartments.div_sample (1 ms)
[ RUN      ] compartments.div_integrator
[       OK ] compartments.div_integrator (0 ms)
[----------] 3 tests from compartments (1 ms total)
[----------] 5 tests from int_types/counter_test/0, where TypeParam = signed char
[ RUN      ] int_types/counter_test/0.value
[       OK ] int_types/counter_test/0.value (0 ms)
[ RUN      ] int_types/counter_test/0.compare
[       OK ] int_types/counter_test/0.compare (0 ms)
[ RUN      ] int_types/counter_test/0.arithmetic
[       OK ] int_types/counter_test/0.arithmetic (0 ms)
[ RUN      ] int_types/counter_test/0.iterator_traits
[       OK ] int_types/counter_test/0.iterator_traits (0 ms)
[ RUN      ] int_types/counter_test/0.iterator_functions
[       OK ] int_types/counter_test/0.iterator_functions (0 ms)
[----------] 5 tests from int_types/counter_test/0 (0 ms total)
[----------] 5 tests from int_types/counter_test/1, where TypeParam = unsigned char
[ RUN      ] int_types/counter_test/1.value
[       OK ] int_types/counter_test/1.value (0 ms)
[ RUN      ] int_types/counter_test/1.compare
[       OK ] int_types/counter_test/1.compare (0 ms)
[ RUN      ] int_types/counter_test/1.arithmetic
[       OK ] int_types/counter_test/1.arithmetic (0 ms)
[ RUN      ] int_types/counter_test/1.iterator_traits
[       OK ] int_types/counter_test/1.iterator_traits (0 ms)
[ RUN      ] int_types/counter_test/1.iterator_functions
[       OK ] int_types/counter_test/1.iterator_functions (0 ms)
[----------] 5 tests from int_types/counter_test/1 (0 ms total)
[----------] 5 tests from int_types/counter_test/2, where TypeParam = short
[ RUN      ] int_types/counter_test/2.value
[       OK ] int_types/counter_test/2.value (0 ms)
[ RUN      ] int_types/counter_test/2.compare
[       OK ] int_types/counter_test/2.compare (0 ms)
[ RUN      ] int_types/counter_test/2.arithmetic
[       OK ] int_types/counter_test/2.arithmetic (0 ms)
[ RUN      ] int_types/counter_test/2.iterator_traits
[       OK ] int_types/counter_test/2.iterator_traits (0 ms)
[ RUN      ] int_types/counter_test/2.iterator_functions
[       OK ] int_types/counter_test/2.iterator_functions (0 ms)
[----------] 5 tests from int_types/counter_test/2 (0 ms total)
[----------] 5 tests from int_types/counter_test/3, where TypeParam = unsigned short
[ RUN      ] int_types/counter_test/3.value
[       OK ] int_types/counter_test/3.value (0 ms)
[ RUN      ] int_types/counter_test/3.compare
[       OK ] int_types/counter_test/3.compare (0 ms)
[ RUN      ] int_types/counter_test/3.arithmetic
[       OK ] int_types/counter_test/3.arithmetic (0 ms)
[ RUN      ] int_types/counter_test/3.iterator_traits
[       OK ] int_types/counter_test/3.iterator_traits (0 ms)
[ RUN      ] int_types/counter_test/3.iterator_functions
[       OK ] int_types/counter_test/3.iterator_functions (0 ms)
[----------] 5 tests from int_types/counter_test/3 (0 ms total)
[----------] 5 tests from int_types/counter_test/4, where TypeParam = int
[ RUN      ] int_types/counter_test/4.value
[       OK ] int_types/counter_test/4.value (0 ms)
[ RUN      ] int_types/counter_test/4.compare
[       OK ] int_types/counter_test/4.compare (0 ms)
[ RUN      ] int_types/counter_test/4.arithmetic
[       OK ] int_types/counter_test/4.arithmetic (0 ms)
[ RUN      ] int_types/counter_test/4.iterator_traits
[       OK ] int_types/counter_test/4.iterator_traits (0 ms)
[ RUN      ] int_types/counter_test/4.iterator_functions
[       OK ] int_types/counter_test/4.iterator_functions (0 ms)
[----------] 5 tests from int_types/counter_test/4 (0 ms total)
[----------] 5 tests from int_types/counter_test/5, where TypeParam = unsigned int
[ RUN      ] int_types/counter_test/5.value
[       OK ] int_types/counter_test/5.value (0 ms)
[ RUN      ] int_types/counter_test/5.compare
[       OK ] int_types/counter_test/5.compare (0 ms)
[ RUN      ] int_types/counter_test/5.arithmetic
[       OK ] int_types/counter_test/5.arithmetic (0 ms)
[ RUN      ] int_types/counter_test/5.iterator_traits
[       OK ] int_types/counter_test/5.iterator_traits (0 ms)
[ RUN      ] int_types/counter_test/5.iterator_functions
[       OK ] int_types/counter_test/5.iterator_functions (0 ms)
[----------] 5 tests from int_types/counter_test/5 (0 ms total)
[----------] 5 tests from int_types/counter_test/6, where TypeParam = unsigned long
[ RUN      ] int_types/counter_test/6.value
[       OK ] int_types/counter_test/6.value (0 ms)
[ RUN      ] int_types/counter_test/6.compare
[       OK ] int_types/counter_test/6.compare (0 ms)
[ RUN      ] int_types/counter_test/6.arithmetic
[       OK ] int_types/counter_test/6.arithmetic (0 ms)
[ RUN      ] int_types/counter_test/6.iterator_traits
[       OK ] int_types/counter_test/6.iterator_traits (0 ms)
[ RUN      ] int_types/counter_test/6.iterator_functions
[       OK ] int_types/counter_test/6.iterator_functions (0 ms)
[----------] 5 tests from int_types/counter_test/6 (0 ms total)
[----------] 5 tests from int_types/counter_test/7, where TypeParam = long
[ RUN      ] int_types/counter_test/7.value
[       OK ] int_types/counter_test/7.value (0 ms)
[ RUN      ] int_types/counter_test/7.compare
[       OK ] int_types/counter_test/7.compare (0 ms)
[ RUN      ] int_types/counter_test/7.arithmetic
[       OK ] int_types/counter_test/7.arithmetic (0 ms)
[ RUN      ] int_types/counter_test/7.iterator_traits
[       OK ] int_types/counter_test/7.iterator_traits (0 ms)
[ RUN      ] int_types/counter_test/7.iterator_functions
[       OK ] int_types/counter_test/7.iterator_functions (0 ms)
[----------] 5 tests from int_types/counter_test/7 (0 ms total)
[----------] 7 tests from cycle_iterator
[ RUN      ] cycle_iterator.construct
[       OK ] cycle_iterator.construct (0 ms)
[ RUN      ] cycle_iterator.increment
[       OK ] cycle_iterator.increment (0 ms)
[ RUN      ] cycle_iterator.decrement
[       OK ] cycle_iterator.decrement (0 ms)
[ RUN      ] cycle_iterator.carray
[       OK ] cycle_iterator.carray (0 ms)
[ RUN      ] cycle_iterator.sentinel
[       OK ] cycle_iterator.sentinel (0 ms)
[ RUN      ] cycle_iterator.difference
[       OK ] cycle_iterator.difference (0 ms)
[ RUN      ] cycle_iterator.order
[       OK ] cycle_iterator.order (0 ms)
[----------] 7 tests from cycle_iterator (0 ms total)
[----------] 3 tests from cycle
[ RUN      ] cycle.cyclic_view
[       OK ] cycle.cyclic_view (0 ms)
[ RUN      ] cycle.cyclic_view_initlist
[       OK ] cycle.cyclic_view_initlist (0 ms)
[ RUN      ] cycle.cyclic_view_sentinel
[       OK ] cycle.cyclic_view_sentinel (0 ms)
[----------] 3 tests from cycle (0 ms total)
[----------] 4 tests from domain_decomposition
[ RUN      ] domain_decomposition.homogenous_population
[       OK ] domain_decomposition.homogenous_population (1 ms)
[ RUN      ] domain_decomposition.heterogenous_population
[       OK ] domain_decomposition.heterogenous_population (0 ms)
[ RUN      ] domain_decomposition.hints
[       OK ] domain_decomposition.hints (0 ms)
[ RUN      ] domain_decomposition.compulsory_groups
[       OK ] domain_decomposition.compulsory_groups (0 ms)
[----------] 4 tests from domain_decomposition (1 ms total)
[----------] 2 tests from either
[ RUN      ] either.basic
[       OK ] either.basic (0 ms)
[ RUN      ] either.no_copy
[       OK ] either.no_copy (0 ms)
[----------] 2 tests from either (0 ms total)
[----------] 1 test from event_binner
[ RUN      ] event_binner.with_min
[       OK ] event_binner.with_min (0 ms)
[----------] 1 test from event_binner (0 ms total)
[----------] 3 tests from mc_event_delivery
[ RUN      ] mc_event_delivery.one_cell_per_group
[       OK ] mc_event_delivery.one_cell_per_group (1 ms)
[ RUN      ] mc_event_delivery.two_interleaved_groups
[       OK ] mc_event_delivery.two_interleaved_groups (0 ms)
[ RUN      ] mc_event_delivery.gj_reordered
[       OK ] mc_event_delivery.gj_reordered (0 ms)
[----------] 3 tests from mc_event_delivery (1 ms total)
[----------] 3 tests from event_generators
[ RUN      ] event_generators.regular
[       OK ] event_generators.regular (0 ms)
[ RUN      ] event_generators.seq
[       OK ] event_generators.seq (0 ms)
[ RUN      ] event_generators.poisson
[       OK ] event_generators.poisson (0 ms)
[----------] 3 tests from event_generators (0 ms total)
[----------] 4 tests from event_queue
[ RUN      ] event_queue.push
[       OK ] event_queue.push (0 ms)
[ RUN      ] event_queue.pop_if_before
[       OK ] event_queue.pop_if_before (0 ms)
[ RUN      ] event_queue.pop_if_not_after
[       OK ] event_queue.pop_if_not_after (0 ms)
[ RUN      ] event_queue.minimal_event_impl
[       OK ] event_queue.minimal_event_impl (0 ms)
[----------] 4 tests from event_queue (0 ms total)
[----------] 5 tests from filter
[ RUN      ] filter.const_regular
[       OK ] filter.const_regular (0 ms)
[ RUN      ] filter.const_sentinel
[       OK ] filter.const_sentinel (0 ms)
[ RUN      ] filter.modify_regular
[       OK ] filter.modify_regular (0 ms)
[ RUN      ] filter.modify_sentinel
[       OK ] filter.modify_sentinel (0 ms)
[ RUN      ] filter.laziness
[       OK ] filter.laziness (0 ms)
[----------] 5 tests from filter (0 ms total)
[----------] 9 tests from fvm_layout
[ RUN      ] fvm_layout.topology
[       OK ] fvm_layout.topology (0 ms)
[ RUN      ] fvm_layout.area
[       OK ] fvm_layout.area (0 ms)
[ RUN      ] fvm_layout.mech_index
[       OK ] fvm_layout.mech_index (0 ms)
[ RUN      ] fvm_layout.coalescing_synapses
[       OK ] fvm_layout.coalescing_synapses (1 ms)
[ RUN      ] fvm_layout.synapse_targets
[       OK ] fvm_layout.synapse_targets (0 ms)
[ RUN      ] fvm_layout.density_norm_area
[       OK ] fvm_layout.density_norm_area (0 ms)
[ RUN      ] fvm_layout.valence_verify
[       OK ] fvm_layout.valence_verify (0 ms)
[ RUN      ] fvm_layout.ion_weights
[       OK ] fvm_layout.ion_weights (0 ms)
[ RUN      ] fvm_layout.revpot
[       OK ] fvm_layout.revpot (0 ms)
[----------] 9 tests from fvm_layout (1 ms total)
[----------] 12 tests from fvm_lowered
[ RUN      ] fvm_lowered.matrix_init
[       OK ] fvm_lowered.matrix_init (0 ms)
[ RUN      ] fvm_lowered.target_handles
[       OK ] fvm_lowered.target_handles (1 ms)
[ RUN      ] fvm_lowered.stimulus
[       OK ] fvm_lowered.stimulus (0 ms)
[ RUN      ] fvm_lowered.derived_mechs
[       OK ] fvm_lowered.derived_mechs (30 ms)
[ RUN      ] fvm_lowered.read_valence
[       OK ] fvm_lowered.read_valence (0 ms)
[ RUN      ] fvm_lowered.ionic_currents
[       OK ] fvm_lowered.ionic_currents (0 ms)
[ RUN      ] fvm_lowered.point_ionic_current
[       OK ] fvm_lowered.point_ionic_current (0 ms)
[ RUN      ] fvm_lowered.weighted_write_ion
[       OK ] fvm_lowered.weighted_write_ion (0 ms)
[ RUN      ] fvm_lowered.gj_coords_simple
[       OK ] fvm_lowered.gj_coords_simple (0 ms)
[ RUN      ] fvm_lowered.gj_coords_complex
[       OK ] fvm_lowered.gj_coords_complex (0 ms)
[ RUN      ] fvm_lowered.cell_group_gj
[       OK ] fvm_lowered.cell_group_gj (0 ms)
[ RUN      ] fvm_lowered.integration_domains
[       OK ] fvm_lowered.integration_domains (0 ms)
[----------] 12 tests from fvm_lowered (32 ms total)
[----------] 5 tests from glob
[ RUN      ] glob.pattern
[       OK ] glob.pattern (0 ms)
[ RUN      ] glob.simple_patterns
[       OK ] glob.simple_patterns (0 ms)
[ RUN      ] glob.literals
[       OK ] glob.literals (0 ms)
[ RUN      ] glob.multidir
[       OK ] glob.multidir (0 ms)
[ RUN      ] glob.dots
[       OK ] glob.dots (0 ms)
[----------] 5 tests from glob (0 ms total)
[----------] 3 tests from mc_cell_group
[ RUN      ] mc_cell_group.get_kind
[       OK ] mc_cell_group.get_kind (0 ms)
[ RUN      ] mc_cell_group.test
[       OK ] mc_cell_group.test (20 ms)
[ RUN      ] mc_cell_group.sources
[       OK ] mc_cell_group.sources (0 ms)
[----------] 3 tests from mc_cell_group (20 ms total)
[----------] 2 tests from mech_kinetic
[ RUN      ] mech_kinetic.kintetic_1_conserve
[       OK ] mech_kinetic.kintetic_1_conserve (0 ms)
[ RUN      ] mech_kinetic.kintetic_2_conserve
[       OK ] mech_kinetic.kintetic_2_conserve (0 ms)
[----------] 2 tests from mech_kinetic (0 ms total)
[----------] 1 test from mech_linear
[ RUN      ] mech_linear.linear
[       OK ] mech_linear.linear (1 ms)
[----------] 1 test from mech_linear (1 ms total)
[----------] 4 tests from lexcmp_def
[ RUN      ] lexcmp_def.one
[       OK ] lexcmp_def.one (0 ms)
[ RUN      ] lexcmp_def.three
[       OK ] lexcmp_def.three (0 ms)
[ RUN      ] lexcmp_def.refmemfn
[       OK ] lexcmp_def.refmemfn (0 ms)
[ RUN      ] lexcmp_def.proxy
[       OK ] lexcmp_def.proxy (0 ms)
[----------] 4 tests from lexcmp_def (0 ms total)
[----------] 3 tests from lif_cell_group
[ RUN      ] lif_cell_group.recipe
[       OK ] lif_cell_group.recipe (0 ms)
[ RUN      ] lif_cell_group.spikes
[       OK ] lif_cell_group.spikes (2 ms)
[ RUN      ] lif_cell_group.ring
[       OK ] lif_cell_group.ring (6 ms)
[----------] 3 tests from lif_cell_group (8 ms total)
[----------] 5 tests from maputil
[ RUN      ] maputil.keys
[       OK ] maputil.keys (0 ms)
[ RUN      ] maputil.is_assoc
[       OK ] maputil.is_assoc (0 ms)
[ RUN      ] maputil.value_by_key_map
[       OK ] maputil.value_by_key_map (0 ms)
[ RUN      ] maputil.value_by_key_sequence
[       OK ] maputil.value_by_key_sequence (0 ms)
[ RUN      ] maputil.binary_search_index
[       OK ] maputil.binary_search_index (0 ms)
[----------] 5 tests from maputil (0 ms total)
[----------] 4 tests from mask_stream
[ RUN      ] mask_stream.nomask
[       OK ] mask_stream.nomask (0 ms)
[ RUN      ] mask_stream.mask
[       OK ] mask_stream.mask (0 ms)
[ RUN      ] mask_stream.mask_multi
[       OK ] mask_stream.mask_multi (0 ms)
[ RUN      ] mask_stream.fmt
[       OK ] mask_stream.fmt (0 ms)
[----------] 4 tests from mask_stream (0 ms total)
[----------] 8 tests from math
[ RUN      ] math.pi
[       OK ] math.pi (0 ms)
[ RUN      ] math.lerp
[       OK ] math.lerp (0 ms)
[ RUN      ] math.frustrum
[       OK ] math.frustrum (0 ms)
[ RUN      ] math.infinity
[       OK ] math.infinity (0 ms)
[ RUN      ] math.signum
[       OK ] math.signum (0 ms)
[ RUN      ] math.next_pow2
[       OK ] math.next_pow2 (0 ms)
[ RUN      ] math.round_up
[       OK ] math.round_up (0 ms)
[ RUN      ] math.exprelr
[       OK ] math.exprelr (0 ms)
[----------] 8 tests from math (0 ms total)
[----------] 7 tests from quaternion
[ RUN      ] quaternion.ctor
[       OK ] quaternion.ctor (0 ms)
[ RUN      ] quaternion.assign
[       OK ] quaternion.assign (0 ms)
[ RUN      ] quaternion.equality
[       OK ] quaternion.equality (0 ms)
[ RUN      ] quaternion.unaryop
[       OK ] quaternion.unaryop (0 ms)
[ RUN      ] quaternion.binop
[       OK ] quaternion.binop (0 ms)
[ RUN      ] quaternion.assignop
[       OK ] quaternion.assignop (0 ms)
[ RUN      ] quaternion.rotate
[       OK ] quaternion.rotate (0 ms)
[----------] 7 tests from quaternion (0 ms total)
[----------] 4 tests from matrix
[ RUN      ] matrix.construct_from_parent_only
[       OK ] matrix.construct_from_parent_only (0 ms)
[ RUN      ] matrix.solve_host
[       OK ] matrix.solve_host (17 ms)
[ RUN      ] matrix.zero_diagonal
[       OK ] matrix.zero_diagonal (0 ms)
[ RUN      ] matrix.zero_diagonal_assembled
[       OK ] matrix.zero_diagonal_assembled (0 ms)
[----------] 4 tests from matrix (17 ms total)
[----------] 6 tests from cable_cell
[ RUN      ] cable_cell.soma
[       OK ] cable_cell.soma (0 ms)
[ RUN      ] cable_cell.add_segment
[       OK ] cable_cell.add_segment (0 ms)
[ RUN      ] cable_cell.multiple_cables
[       OK ] cable_cell.multiple_cables (0 ms)
[ RUN      ] cable_cell.unbranched_chain
[       OK ] cable_cell.unbranched_chain (0 ms)
[ RUN      ] cable_cell.clone
[       OK ] cable_cell.clone (0 ms)
[ RUN      ] cable_cell.get_kind
[       OK ] cable_cell.get_kind (0 ms)
[----------] 6 tests from cable_cell (0 ms total)
[----------] 1 test from mech_temperature
[ RUN      ] mech_temperature.celsius
[       OK ] mech_temperature.celsius (0 ms)
[----------] 1 test from mech_temperature (0 ms total)
[----------] 9 tests from mechcat
[ RUN      ] mechcat.fingerprint
[       OK ] mechcat.fingerprint (0 ms)
[ RUN      ] mechcat.derived_info
[       OK ] mechcat.derived_info (0 ms)
[ RUN      ] mechcat.queries
[       OK ] mechcat.queries (0 ms)
[ RUN      ] mechcat.remove
[       OK ] mechcat.remove (0 ms)
[ RUN      ] mechcat.instance
[       OK ] mechcat.instance (0 ms)
[ RUN      ] mechcat.instantiate
[       OK ] mechcat.instantiate (0 ms)
[ RUN      ] mechcat.bad_ion_rename
[       OK ] mechcat.bad_ion_rename (0 ms)
[ RUN      ] mechcat.implicit_deriv
[       OK ] mechcat.implicit_deriv (0 ms)
[ RUN      ] mechcat.copy
[       OK ] mechcat.copy (0 ms)
[----------] 9 tests from mechcat (0 ms total)
[----------] 6 tests from merge_events
[ RUN      ] merge_events.empty
[       OK ] merge_events.empty (0 ms)
[ RUN      ] merge_events.no_overlap
[       OK ] merge_events.no_overlap (0 ms)
[ RUN      ] merge_events.overlap
[       OK ] merge_events.overlap (0 ms)
[ RUN      ] merge_events.X
[       OK ] merge_events.X (0 ms)
[ RUN      ] merge_events.tourney_seq
[       OK ] merge_events.tourney_seq (0 ms)
[ RUN      ] merge_events.tourney_poisson
[       OK ] merge_events.tourney_poisson (4 ms)
[----------] 6 tests from merge_events (4 ms total)
[----------] 3 tests from multi_event_stream
[ RUN      ] multi_event_stream.init
[       OK ] multi_event_stream.init (0 ms)
[ RUN      ] multi_event_stream.mark
[       OK ] multi_event_stream.mark (0 ms)
[ RUN      ] multi_event_stream.time_if_before
[       OK ] multi_event_stream.time_if_before (0 ms)
[----------] 3 tests from multi_event_stream (0 ms total)
[----------] 15 tests from optional
[ RUN      ] optional.ctors
[       OK ] optional.ctors (0 ms)
[ RUN      ] optional.unset_throw
[       OK ] optional.unset_throw (0 ms)
[ RUN      ] optional.deref
[       OK ] optional.deref (0 ms)
[ RUN      ] optional.ctor_conv
[       OK ] optional.ctor_conv (0 ms)
[ RUN      ] optional.ctor_ref
[       OK ] optional.ctor_ref (0 ms)
[ RUN      ] optional.assign_returns
[       OK ] optional.assign_returns (0 ms)
[ RUN      ] optional.assign_reference
[       OK ] optional.assign_reference (0 ms)
[ RUN      ] optional.ctor_nomove
[       OK ] optional.ctor_nomove (0 ms)
[ RUN      ] optional.ctor_nocopy
[       OK ] optional.ctor_nocopy (0 ms)
[ RUN      ] optional.value_or
[       OK ] optional.value_or (0 ms)
[ RUN      ] optional.ref_value_or
[       OK ] optional.ref_value_or (0 ms)
[ RUN      ] optional.void
[       OK ] optional.void (0 ms)
[ RUN      ] optional.conversion
[       OK ] optional.conversion (0 ms)
[ RUN      ] optional.just
[       OK ] optional.just (0 ms)
[ RUN      ] optional.emplace
[       OK ] optional.emplace (0 ms)
[----------] 15 tests from optional (0 ms total)
[----------] 1 test from mechanism_desc
[ RUN      ] mechanism_desc.setting
[       OK ] mechanism_desc.setting (0 ms)
[----------] 1 test from mechanism_desc (0 ms total)
[----------] 5 tests from morphology
[ RUN      ] morphology.point_props
[       OK ] morphology.point_props (0 ms)
[ RUN      ] morphology.branches_from_parent_index
[       OK ] morphology.branches_from_parent_index (0 ms)
[ RUN      ] morphology.construction
[       OK ] morphology.construction (0 ms)
[ RUN      ] morphology.branches
[       OK ] morphology.branches (0 ms)
[ RUN      ] morphology.swc
[       OK ] morphology.swc (2 ms)
[----------] 5 tests from morphology (2 ms total)
[----------] 1 test from sample_tree
[ RUN      ] sample_tree.properties
[       OK ] sample_tree.properties (0 ms)
[----------] 1 test from sample_tree (0 ms total)
[----------] 4 tests from padded_vector
[ RUN      ] padded_vector.alignment
[       OK ] padded_vector.alignment (0 ms)
[ RUN      ] padded_vector.allocator_constraints
[       OK ] padded_vector.allocator_constraints (0 ms)
[ RUN      ] padded_vector.allocator_propagation
[       OK ] padded_vector.allocator_propagation (0 ms)
[ RUN      ] padded_vector.instrumented
[       OK ] padded_vector.instrumented (0 ms)
[----------] 4 tests from padded_vector (0 ms total)
[----------] 7 tests from partition
[ RUN      ] partition.partition_view
[       OK ] partition.partition_view (0 ms)
[ RUN      ] partition.short_partition_view
[       OK ] partition.short_partition_view (0 ms)
[ RUN      ] partition.check_monotonicity
[       OK ] partition.check_monotonicity (0 ms)
[ RUN      ] partition.partition_view_find
[       OK ] partition.partition_view_find (0 ms)
[ RUN      ] partition.partition_view_non_numeric
[       OK ] partition.partition_view_non_numeric (0 ms)
[ RUN      ] partition.make_partition_in_place
[       OK ] partition.make_partition_in_place (0 ms)
[ RUN      ] partition.make_partition
[       OK ] partition.make_partition (0 ms)
[----------] 7 tests from partition (0 ms total)
[----------] 5 tests from partition_by_constraint
[ RUN      ] partition_by_constraint.partition_contiguous
[       OK ] partition_by_constraint.partition_contiguous (0 ms)
[ RUN      ] partition_by_constraint.partition_constant
[       OK ] partition_by_constraint.partition_constant (0 ms)
[ RUN      ] partition_by_constraint.partition_independent
[       OK ] partition_by_constraint.partition_independent (0 ms)
[ RUN      ] partition_by_constraint.partition_none
[       OK ] partition_by_constraint.partition_none (0 ms)
[ RUN      ] partition_by_constraint.partition_random
[       OK ] partition_by_constraint.partition_random (0 ms)
[----------] 5 tests from partition_by_constraint (0 ms total)
[----------] 17 tests from path
[ RUN      ] path.posix_ctor
[       OK ] path.posix_ctor (0 ms)
[ RUN      ] path.posix_native
[       OK ] path.posix_native (0 ms)
[ RUN      ] path.posix_generic
[       OK ] path.posix_generic (0 ms)
[ RUN      ] path.posix_append
[       OK ] path.posix_append (0 ms)
[ RUN      ] path.compare
[       OK ] path.compare (0 ms)
[ RUN      ] path.posix_concat
[       OK ] path.posix_concat (0 ms)
[ RUN      ] path.posix_absrel_query
[       OK ] path.posix_absrel_query (0 ms)
[ RUN      ] path.posix_swap
[       OK ] path.posix_swap (0 ms)
[ RUN      ] path.filename
[       OK ] path.filename (0 ms)
[ RUN      ] path.parent_path
[       OK ] path.parent_path (0 ms)
[ RUN      ] path.posix_iostream
[       OK ] path.posix_iostream (0 ms)
[ RUN      ] path.filesystem_error
[       OK ] path.filesystem_error (0 ms)
[ RUN      ] path.posix_status
[       OK ] path.posix_status (2 ms)
[ RUN      ] path.is_wrappers
[       OK ] path.is_wrappers (0 ms)
[ RUN      ] path.permissions
[       OK ] path.permissions (0 ms)
[ RUN      ] path.posix_status_perms
[       OK ] path.posix_status_perms (0 ms)
[ RUN      ] path.posix_directory_iterators
[       OK ] path.posix_directory_iterators (0 ms)
[----------] 17 tests from path (2 ms total)
[----------] 7 tests from point
[ RUN      ] point.construction
[       OK ] point.construction (0 ms)
[ RUN      ] point.constexpr
[       OK ] point.constexpr (0 ms)
[ RUN      ] point.addition
[       OK ] point.addition (0 ms)
[ RUN      ] point.subtraction
[       OK ] point.subtraction (0 ms)
[ RUN      ] point.scalar_prod
[       OK ] point.scalar_prod (0 ms)
[ RUN      ] point.norm
[       OK ] point.norm (0 ms)
[ RUN      ] point.dot
[       OK ] point.dot (0 ms)
[----------] 7 tests from point (0 ms total)
[----------] 1 test from probe
[ RUN      ] probe.fvm_lowered_cell
[       OK ] probe.fvm_lowered_cell (0 ms)
[----------] 1 test from probe (0 ms total)
[----------] 25 tests from range
[ RUN      ] range.list_iterator
[       OK ] range.list_iterator (0 ms)
[ RUN      ] range.pointer
[       OK ] range.pointer (0 ms)
[ RUN      ] range.empty
[       OK ] range.empty (0 ms)
[ RUN      ] range.size_implementation
[       OK ] range.size_implementation (0 ms)
[ RUN      ] range.input_iterator
[       OK ] range.input_iterator (0 ms)
[ RUN      ] range.const_iterator
[       OK ] range.const_iterator (0 ms)
[ RUN      ] range.view
[       OK ] range.view (0 ms)
[ RUN      ] range.sentinel
[       OK ] range.sentinel (0 ms)
[ RUN      ] range.strictify
[       OK ] range.strictify (0 ms)
[ RUN      ] range.range_view
[       OK ] range.range_view (0 ms)
[ RUN      ] range.range_pointer_view
[       OK ] range.range_pointer_view (0 ms)
[ RUN      ] range.subrange
[       OK ] range.subrange (0 ms)
[ RUN      ] range.max_element_by
[       OK ] range.max_element_by (0 ms)
[ RUN      ] range.max_value
[       OK ] range.max_value (0 ms)
[ RUN      ] range.minmax_value
[       OK ] range.minmax_value (0 ms)
[ RUN      ] range.assign
[       OK ] range.assign (0 ms)
[ RUN      ] range.fill
[       OK ] range.fill (0 ms)
[ RUN      ] range.assign_from
[       OK ] range.assign_from (0 ms)
[ RUN      ] range.sort
[       OK ] range.sort (0 ms)
[ RUN      ] range.sum_by
[       OK ] range.sum_by (0 ms)
[ RUN      ] range.is_sequence
[       OK ] range.is_sequence (0 ms)
[ RUN      ] range.all_of_any_of
[       OK ] range.all_of_any_of (0 ms)
[ RUN      ] range.is_sorted
[       OK ] range.is_sorted (0 ms)
[ RUN      ] range.is_sorted_by
[       OK ] range.is_sorted_by (0 ms)
[ RUN      ] range.reverse
[       OK ] range.reverse (0 ms)
[----------] 25 tests from range (0 ms total)
[----------] 5 tests from int_types/counter_range/0, where TypeParam = signed char
[ RUN      ] int_types/counter_range/0.max_size
[       OK ] int_types/counter_range/0.max_size (0 ms)
[ RUN      ] int_types/counter_range/0.extreme_size
[       OK ] int_types/counter_range/0.extreme_size (0 ms)
[ RUN      ] int_types/counter_range/0.size
[       OK ] int_types/counter_range/0.size (0 ms)
[ RUN      ] int_types/counter_range/0.at
[       OK ] int_types/counter_range/0.at (0 ms)
[ RUN      ] int_types/counter_range/0.iteration
[       OK ] int_types/counter_range/0.iteration (0 ms)
[----------] 5 tests from int_types/counter_range/0 (0 ms total)
[----------] 5 tests from int_types/counter_range/1, where TypeParam = unsigned char
[ RUN      ] int_types/counter_range/1.max_size
[       OK ] int_types/counter_range/1.max_size (0 ms)
[ RUN      ] int_types/counter_range/1.extreme_size
[       OK ] int_types/counter_range/1.extreme_size (0 ms)
[ RUN      ] int_types/counter_range/1.size
[       OK ] int_types/counter_range/1.size (0 ms)
[ RUN      ] int_types/counter_range/1.at
[       OK ] int_types/counter_range/1.at (0 ms)
[ RUN      ] int_types/counter_range/1.iteration
[       OK ] int_types/counter_range/1.iteration (0 ms)
[----------] 5 tests from int_types/counter_range/1 (0 ms total)
[----------] 5 tests from int_types/counter_range/2, where TypeParam = short
[ RUN      ] int_types/counter_range/2.max_size
[       OK ] int_types/counter_range/2.max_size (0 ms)
[ RUN      ] int_types/counter_range/2.extreme_size
[       OK ] int_types/counter_range/2.extreme_size (0 ms)
[ RUN      ] int_types/counter_range/2.size
[       OK ] int_types/counter_range/2.size (0 ms)
[ RUN      ] int_types/counter_range/2.at
[       OK ] int_types/counter_range/2.at (0 ms)
[ RUN      ] int_types/counter_range/2.iteration
[       OK ] int_types/counter_range/2.iteration (0 ms)
[----------] 5 tests from int_types/counter_range/2 (0 ms total)
[----------] 5 tests from int_types/counter_range/3, where TypeParam = unsigned short
[ RUN      ] int_types/counter_range/3.max_size
[       OK ] int_types/counter_range/3.max_size (0 ms)
[ RUN      ] int_types/counter_range/3.extreme_size
[       OK ] int_types/counter_range/3.extreme_size (0 ms)
[ RUN      ] int_types/counter_range/3.size
[       OK ] int_types/counter_range/3.size (0 ms)
[ RUN      ] int_types/counter_range/3.at
[       OK ] int_types/counter_range/3.at (0 ms)
[ RUN      ] int_types/counter_range/3.iteration
[       OK ] int_types/counter_range/3.iteration (0 ms)
[----------] 5 tests from int_types/counter_range/3 (0 ms total)
[----------] 5 tests from int_types/counter_range/4, where TypeParam = int
[ RUN      ] int_types/counter_range/4.max_size
[       OK ] int_types/counter_range/4.max_size (0 ms)
[ RUN      ] int_types/counter_range/4.extreme_size
[       OK ] int_types/counter_range/4.extreme_size (0 ms)
[ RUN      ] int_types/counter_range/4.size
[       OK ] int_types/counter_range/4.size (0 ms)
[ RUN      ] int_types/counter_range/4.at
[       OK ] int_types/counter_range/4.at (0 ms)
[ RUN      ] int_types/counter_range/4.iteration
[       OK ] int_types/counter_range/4.iteration (0 ms)
[----------] 5 tests from int_types/counter_range/4 (0 ms total)
[----------] 5 tests from int_types/counter_range/5, where TypeParam = unsigned int
[ RUN      ] int_types/counter_range/5.max_size
[       OK ] int_types/counter_range/5.max_size (0 ms)
[ RUN      ] int_types/counter_range/5.extreme_size
[       OK ] int_types/counter_range/5.extreme_size (0 ms)
[ RUN      ] int_types/counter_range/5.size
[       OK ] int_types/counter_range/5.size (0 ms)
[ RUN      ] int_types/counter_range/5.at
[       OK ] int_types/counter_range/5.at (0 ms)
[ RUN      ] int_types/counter_range/5.iteration
[       OK ] int_types/counter_range/5.iteration (0 ms)
[----------] 5 tests from int_types/counter_range/5 (0 ms total)
[----------] 5 tests from int_types/counter_range/6, where TypeParam = long
[ RUN      ] int_types/counter_range/6.max_size
[       OK ] int_types/counter_range/6.max_size (0 ms)
[ RUN      ] int_types/counter_range/6.extreme_size
[       OK ] int_types/counter_range/6.extreme_size (0 ms)
[ RUN      ] int_types/counter_range/6.size
[       OK ] int_types/counter_range/6.size (0 ms)
[ RUN      ] int_types/counter_range/6.at
[       OK ] int_types/counter_range/6.at (0 ms)
[ RUN      ] int_types/counter_range/6.iteration
[       OK ] int_types/counter_range/6.iteration (0 ms)
[----------] 5 tests from int_types/counter_range/6 (1 ms total)
[----------] 5 tests from int_types/counter_range/7, where TypeParam = unsigned long
[ RUN      ] int_types/counter_range/7.max_size
[       OK ] int_types/counter_range/7.max_size (0 ms)
[ RUN      ] int_types/counter_range/7.extreme_size
[       OK ] int_types/counter_range/7.extreme_size (0 ms)
[ RUN      ] int_types/counter_range/7.size
[       OK ] int_types/counter_range/7.size (0 ms)
[ RUN      ] int_types/counter_range/7.at
[       OK ] int_types/counter_range/7.at (0 ms)
[ RUN      ] int_types/counter_range/7.iteration
[       OK ] int_types/counter_range/7.iteration (0 ms)
[----------] 5 tests from int_types/counter_range/7 (0 ms total)
[----------] 5 tests from int_types/counter_range/8, where TypeParam = long
[ RUN      ] int_types/counter_range/8.max_size
[       OK ] int_types/counter_range/8.max_size (0 ms)
[ RUN      ] int_types/counter_range/8.extreme_size
[       OK ] int_types/counter_range/8.extreme_size (0 ms)
[ RUN      ] int_types/counter_range/8.size
[       OK ] int_types/counter_range/8.size (0 ms)
[ RUN      ] int_types/counter_range/8.at
[       OK ] int_types/counter_range/8.at (0 ms)
[ RUN      ] int_types/counter_range/8.iteration
[       OK ] int_types/counter_range/8.iteration (0 ms)
[----------] 5 tests from int_types/counter_range/8 (0 ms total)
[----------] 1 test from segment
[ RUN      ] segment.kinfs
[       OK ] segment.kinfs (0 ms)
[----------] 1 test from segment (0 ms total)
[----------] 13 tests from schedule
[ RUN      ] schedule.regular
[       OK ] schedule.regular (0 ms)
[ RUN      ] schedule.regular_invariants
/var/tmp/rpm-tmp.wMLONn: line 35: 4084816 Aborted                 (core dumped) LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib/ ./bin/unit

Hardware information:

Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   46 bits physical, 48 bits virtual

Compiler:

gcc-9.2.1

Complete list of packages attached. The complete build log is also attached:

arbor-build-log.txt
arbor-root-log.txt

Additional question: is libarborsup.so meant to be a public library for use? It isn't installed in /usr/lib64 etc, but is required by unit to run the tests. Here, I've specified LD_LIBRARY_PATH to ensure it is found.

Thanks,

@halfflat
Copy link
Contributor

halfflat commented Dec 8, 2019

Hi! Thanks for the detailed info in the report!

I'll look further into this a little later in the week, but as noted in #916, we haven't tested or attempted to support installing Arbor as a shared library. libarborsup is only for internal use as things stand — when built as a static library (which it would normally do by default), the unit test executable will be statically linked against it.

@sanjayankur31
Copy link
Author

sanjayankur31 commented Dec 8, 2019

The tests crash even with a static library build. Logs attached:

arbor-static-build-log.txt

@jamesjer
Copy link

jamesjer commented Dec 9, 2019

The crash is actually an assertion failure, because Fedora builds with -D_GLIBCXX_ASSERTIONS to find misuses of the C++ STL classes. This particular assertion failure means a vector access specified an index that is >= the size of the vector. I've seen this happen in a lot of projects. Most often it is because the code attempted to access element 0 of an empty vector. That is the case here. The problem is this code in arbor/include/arbor/schedule.hpp:

inline time_event_span as_time_event_span(const std::vector<time_type>& v) {
    return {&v[0], &v[0]+v.size()};
}

That can be called with an empty vector v. Index 0 is invalid in that case.

@halfflat
Copy link
Contributor

halfflat commented Dec 9, 2019

Thank you for the diagnosis, @jamesjer!

@bcumming
Copy link
Member

bcumming commented Dec 9, 2019

That analysis is spot on. You can see why this doesn't cause any runtime errors, but it is highly dubious behaviour.
@halfflat, the best solution would be to use std::vector::data? The standard says it may or may not return nullptr when size()==0, but whatever the pointer it returns, it should work?

@bcumming
Copy link
Member

bcumming commented Dec 9, 2019

We test regularly with valgrind and address sanitizer, and they didn't flag this as an issue.

For the release, would you consider compiling with that flag turned off, because it will hurt performance. Some quick tests on my laptop show at least a 25% slow down.

@jamesjer
Copy link

jamesjer commented Dec 9, 2019

That's a big impact! That flag has been in use since Fedora 28. You can see the writeup on it here: https://fedoraproject.org/wiki/Changes/HardeningFlags28. Note that the proposers referred to "cheap" range checks. I would not call a 25% slow down cheap. @sanjayankur31 perhaps we should bring this up on fedora-devel-list.

@halfflat
Copy link
Contributor

Just to confirm, I believe using std::vector::data() is correct in this context. I'll make a PR!

halfflat added a commit to halfflat/arbor that referenced this issue Dec 10, 2019
Fixes arbor-sim#917.

* Avoid use of empty ranges determined by expressions `&vector[i]` where i equals vector.size(). Replace with expressions using `vector.data()` or subrange views.
@halfflat halfflat self-assigned this Dec 10, 2019
@halfflat halfflat added the bug label Dec 10, 2019
@sanjayankur31
Copy link
Author

That's a big impact! That flag has been in use since Fedora 28. You can see the writeup on it here: https://fedoraproject.org/wiki/Changes/HardeningFlags28. Note that the proposers referred to "cheap" range checks. I would not call a 25% slow down cheap. @sanjayankur31 perhaps we should bring this up on fedora-devel-list.

I've started a thread now: Performance penalties caused by -D_GLIBCXX_ASSERTIONS - devel - Fedora Mailing-Lists

Let's see how that goes, and we'll report back here :)

bcumming pushed a commit that referenced this issue Dec 10, 2019
Avoid use of empty ranges determined by expressions `&vector[i]` where i equals vector.size(). Replace with expressions using `vector.data()` or subrange views.

Fixes #917.
@bcumming bcumming reopened this Dec 10, 2019
@bcumming
Copy link
Member

The time measurements I gave quite high level: the total time taken in the time stepping loop.
I will dig a bit deeper, to see which part of the code is taking the perf. hit.

@halfflat
Copy link
Contributor

halfflat commented Dec 10, 2019

I did find a link describing the sort of optimization issue that Florian mentions in the reply on the mailing list: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85929

@bcumming
Copy link
Member

We did some digging, and found that some key loops are up to 3x slower with the flag enabled.

There are two scenarios where the compiler can't hoist or remove the bounds checks.
The first is when the compiler can't determine indirect indexing.

void foo(std::vector<double>& a, const std::vector<int>& idx) {
    for (size_t i=0; i<idx.size(); ++i) {
        a[idx[i]] += 42.;
    }
}

The second is when we access multiple std::vector inside the same loop.
For example, the compiler generates the same code with and without the flag for the following:

using vec = std::vector<double>;

void foo(vec& a) {
    for (size_t i=0; i<a.size(); ++i) {
        a[i] += 42.;
    }
}

The compiler generates less efficient code.

// Compiler generates different code
// without vectorization and with bounds checks.
void foo(vec& a, vec& b) {
    for (size_t i=0; i<a.size(); ++i) {
        a[i] += 42.;
        b[i] += 42.;
    }
}

We verified that this was "fixed" in the code by rewriting the equivalent to the second loop as follows:

// Compiler generates optimized code with the flag set
void foo(vec& a, vec& b) {
    double* _a = a.data();
    double* _b = a.data();
    for (size_t i=0; i<a.size(); ++i) {
        _a[i] += 42.;
        _b[i] += 42.;
    }
}

For this reason we don't recommend compiling with this flag for release builds, but it is a good idea to use when compiling and running tests (we will add it to our Travis builds!).

c.f. the following GodBolt example:
https://godbolt.org/z/bKTn3-

@halfflat
Copy link
Contributor

Just as an addendum, it turns out that the check also breaks auto-vectorization when iterating over a sub-range, e.g. the size check is not hoisted in code like the following:

void foo(std::vector<double>& a, std::size_t b, std::size_t e) {
    for (std::size_t i = b; i<e; ++i) a[i] += 3.;
}

https://godbolt.org/z/tjAfKH

@jreiser
Copy link

jreiser commented Dec 11, 2019

In the code of #917 (comment) (bcumming, here about 12 hours ago) there are no const or __restrict__ type qualifiers, so things like .size() and .data() might change during the loop, particularly when multiple threads are involved. The source must say const in the right places in order to enable important optimizations of the assertion code.
The source with two vectors a and b says nothing about b having the same .size() as a, so any check of indexing a[.] gives no information about indexing b[.].

@bcumming
Copy link
Member

bcumming commented Dec 11, 2019

@jresler, these are all good points, however the circumstances in which the compiler can hoist/eliminate the check using std::vector::operator[] are very limited, even with appropriate usage of const.

The examples I gave all used const where appropriate, and we can't apply __restrict__ to a std::vector. Using a const to store the value of size() doesn't help either:

    const std::size_t n = a.size();
    // compiler can't assert that n==b.size(), so no hoisting of check.
    for (size_t i=0; i<n; ++i) {
        a[i] += 42.;
        b[i] += 42.;
    }

Multhreading doesn't change the compiler's behavior when we pass a vector by const& to the function.

To get optimizations to work, we would have to extract raw pointers using vector::data, which is quite an elaborate work around for a non-standard extension to the language that is enabled with an optional flag.

For reference, the function where we observed 3x slowdown is below. We fixed it with the flag enabled by using pointers:
https://github.com/arbor-sim/arbor/blob/master/arbor/backends/multicore/matrix_state.hpp#L91

The workaround is to either take the performance hit, or use raw pointers, which ironically would make compiling with -D_GLIBCXX_ASSERTIONS not test for out of bounds accesses.

@halfflat
Copy link
Contributor

In the code of #917 (comment) (bcumming, here about 12 hours ago) there are no const or __restrict__ type qualifiers, so things like .size() and .data() might change during the loop, particularly when multiple threads are involved. The source must say const in the right places in order to enable important optimizations of the assertion code.

Strong aliasing guarantees allow us (and the compiler) not to have to worry about this happening in this circumstance unless the vectors were over e.g. char.

The source with two vectors a and b says nothing about b having the same .size() as a, so any check of indexing a[.] gives no information about indexing b[.].

In principle there is enough information for the compiler to optimize the-D_GLIBCXX_ASSERTIONS-enabled size bounds checks by splitting the loop in two, the first up to the minimum of the vector sizes, the second with the tails that have to be checked. In practice, this is a bit too much to ask, and it's not surprising that the code with assertions enabled does not hoist the checks.

@jreiser
Copy link

jreiser commented Dec 13, 2019

@bcumming As written, the subroutine with two vectors has a bug, and the bug directly inhibits optimization of the assertion checks. Fixing the bug gives the compiler enough hints to optimize the assertions. @halfflat Strong aliasing restrictions do inhibit problems due to the code of the function itself, but still allow a separate thread to interfere.

When I compile this modified code (using __restrict__, and checking that b is at least as long as a) using g++ (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1) from either Fedora 31 or Fedora-Workstation-Live-x86_64-Rawhide-20191209.n.0.iso, using command-line flags -S -O -D_GLIBCXX_ASSERTIONS:

#include <vector>
void foo(std::vector<double>& __restrict__ a, std::vector<double> & __restrict__ b) {
    if (a.size() <= b.size())  // avoid overrunning b[]
    for (size_t i=0; i<a.size(); ++i) {
        a[i] += 42.;
        b[i] += 42.;
    }
}

then I get the following code in which the compiler has done moderately well at hoisting the assertion checking:

	.file	"github-issue917.cpp"
	.text
	.section	.rodata.str1.8,"aMS",@progbits,1
	.align 8
.LC1:
	.string	"__builtin_expect(__n < this->size(), true)"
	.align 8
.LC2:
	.ascii	"std::vecto"
	.string	"r<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = double; _Alloc = std::allocator<double>; std::vector<_Tp, _Alloc>::reference = double&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]"
	.align 8
.LC3:
	.string	"/usr/include/c++/9/bits/stl_vector.h"
	.align 8
.LC4:
	.string	"%s:%d: %s: Assertion '%s' failed.\n"
	.text
	.globl	_Z3fooRSt6vectorIdSaIdEES2_
	.type	_Z3fooRSt6vectorIdSaIdEES2_, @function
_Z3fooRSt6vectorIdSaIdEES2_:
.LFB854:
	.cfi_startproc
	.cfi_personality 0x3,__gxx_personality_v0
	.cfi_lsda 0x3,.LLSDA854
	movq	(%rdi), %rcx
	movq	8(%rdi), %rax
	subq	%rcx, %rax
	sarq	$3, %rax
	movq	(%rsi), %rdi
	movq	8(%rsi), %rdx
	subq	%rdi, %rdx
	sarq	$3, %rdx
	cmpq	%rax, %rdx
	jb	.L1
	movq	%rax, %r8
	movq	%rdx, %rsi
	testq	%rax, %rax
	je	.L1
	movsd	.LC0(%rip), %xmm0
	addsd	(%rcx), %xmm0
	movsd	%xmm0, (%rcx)
	testq	%rdx, %rdx
	je	.L3
	movl	$0, %eax
	movsd	.LC0(%rip), %xmm1
	movapd	%xmm1, %xmm2
.L4:
	movapd	%xmm1, %xmm0
	addsd	(%rdi,%rax,8), %xmm0
	movsd	%xmm0, (%rdi,%rax,8)
	addq	$1, %rax
	cmpq	%r8, %rax
	je	.L1
	movapd	%xmm2, %xmm0
	addsd	(%rcx,%rax,8), %xmm0
	movsd	%xmm0, (%rcx,%rax,8)
	cmpq	%rsi, %rax
	jne	.L4
.L3:
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movl	$.LC1, %r8d
	movl	$.LC2, %ecx
	movl	$1042, %edx
	movl	$.LC3, %esi
	movl	$.LC4, %edi
	movl	$0, %eax
	call	printf
	call	abort
.L1:
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE854:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA854:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE854-.LLSDACSB854
.LLSDACSB854:
.LLSDACSE854:
	.text
	.size	_Z3fooRSt6vectorIdSaIdEES2_, .-_Z3fooRSt6vectorIdSaIdEES2_
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1078263808
	.ident	"GCC: (GNU) 9.2.1 20190827 (Red Hat 9.2.1-1)"
	.section	.note.GNU-stack,"",@progbits

@halfflat halfflat changed the title [0.2.2] test crash [0.2.2] test crash / -D_GLIBCXX_ASSERTIONS performance Dec 13, 2019
@halfflat halfflat changed the title [0.2.2] test crash / -D_GLIBCXX_ASSERTIONS performance [0.2.2] -D_GLIBCXX_ASSERTIONS unit test crash + performance issues Dec 13, 2019
@halfflat
Copy link
Contributor

I'm going to open a new issue for the -D_GLIBCXX_ASSERTIONS performance discussion; the crashing bug has been fixed.

@halfflat halfflat added the packaging Installation from source and production of distro packages, python packages. label Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug code quality packaging Installation from source and production of distro packages, python packages.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants