2 #include "libbenchmark_topology_internal.h"
8 /****************************************************************************/
9 int libbenchmark_topology_init( struct libbenchmark_topology_state *ts, struct libshared_memory_state *ms )
18 struct lfds710_btree_au_element
21 struct libbenchmark_topology_lp_printing_offset
24 struct libbenchmark_topology_node_state
27 LFDS710_PAL_ASSERT( ts != NULL );
28 LFDS710_PAL_ASSERT( ms != NULL );
30 lfds710_btree_au_init_valid_on_current_logical_core( &ts->topology_tree, libbenchmark_topology_node_compare_nodes_function, LFDS710_BTREE_AU_EXISTING_KEY_FAIL, NULL );
32 rv = libbenchmark_porting_abstraction_layer_populate_topology( ts, ms );
34 lfds710_btree_au_get_by_absolute_position( &ts->topology_tree, &baue, LFDS710_BTREE_AU_ABSOLUTE_POSITION_LARGEST_IN_TREE );
35 lp_count = count_of_logical_processors_below_node( baue );
36 ts->line_width = (int) ( lp_count * 3 + lp_count - 1 );
38 // TRD : now form up the printing offset tree
39 lfds710_btree_au_init_valid_on_current_logical_core( &ts->lp_printing_offset_lookup_tree, libbenchmark_topology_compare_lp_printing_offsets_function, LFDS710_BTREE_AU_EXISTING_KEY_FAIL, NULL );
43 while( lfds710_btree_au_get_by_absolute_position_and_then_by_relative_position(&ts->topology_tree, &baue, LFDS710_BTREE_AU_ABSOLUTE_POSITION_LARGEST_IN_TREE, LFDS710_BTREE_AU_RELATIVE_POSITION_NEXT_SMALLER_ELEMENT_IN_ENTIRE_TREE) )
45 tns = LFDS710_BTREE_AU_GET_KEY_FROM_ELEMENT( *baue );
47 if( tns->type == LIBBENCHMARK_TOPOLOGY_NODE_TYPE_LOGICAL_PROCESSOR )
49 tlpo = libshared_memory_alloc_from_most_free_space_node( ms, sizeof(struct libbenchmark_topology_lp_printing_offset), LFDS710_PAL_ATOMIC_ISOLATION_IN_BYTES );
52 tlpo->offset = offset;
54 LFDS710_BTREE_AU_SET_KEY_IN_ELEMENT( tlpo->baue, tlpo );
55 LFDS710_BTREE_AU_SET_VALUE_IN_ELEMENT( tlpo->baue, tlpo );
57 lfds710_btree_au_insert( &ts->lp_printing_offset_lookup_tree, &tlpo->baue, NULL );