13 #include "../../liblfds700/inc/liblfds700.h"
14 #include "test_porting_abstraction_layer_operating_system.h"
22 #define BITS_PER_BYTE 8
24 #define TEST_DURATION_IN_SECONDS 5
25 #define TIME_LOOP_COUNT 10000
26 #define REDUCED_TIME_LOOP_COUNT 1000
27 #define NUMBER_OF_NANOSECONDS_IN_ONE_SECOND 1000000000LLU
28 #define ONE_MEGABYTE_IN_BYTES (1024 * 1024)
29 #define DEFAULT_TEST_MEMORY_IN_MEGABYTES 512U
30 #define TEST_PAL_DEFAULT_NUMA_NODE_ID 0
31 #define LFDS700_TEST_VERSION_STRING "7.0.0"
32 #define LFDS700_TEST_VERSION_INTEGER 700
34 #if( defined _KERNEL_MODE )
35 #define MODE_TYPE_STRING "kernel-mode"
38 #if( !defined _KERNEL_MODE )
39 #define MODE_TYPE_STRING "user-mode"
42 #if( defined NDEBUG && !defined COVERAGE && !defined TSAN )
43 #define BUILD_TYPE_STRING "release"
46 #if( !defined NDEBUG && !defined COVERAGE && !defined TSAN )
47 #define BUILD_TYPE_STRING "debug"
50 #if( !defined NDEBUG && defined COVERAGE && !defined TSAN )
51 #define BUILD_TYPE_STRING "coverage"
54 #if( !defined NDEBUG && !defined COVERAGE && defined TSAN )
55 #define BUILD_TYPE_STRING "threadsanitizer"
66 struct test_pal_logical_processor
69 logical_processor_number,
70 windows_logical_processor_group_number;
72 struct lfds700_list_asu_element
76 /***** prototypes *****/
77 int main( int argc, char **argv );
79 void internal_display_test_name( char *format_string, ... );
80 void internal_display_test_result( lfds700_pal_uint_t number_name_dvs_pairs, ... );
81 void internal_display_data_structure_validity( enum lfds700_misc_validity dvs );
82 void internal_show_version( void );
83 void internal_logical_core_id_element_cleanup_callback( struct lfds700_list_asu_state *lasus, struct lfds700_list_asu_element *lasue );
85 int test_pal_thread_start( test_pal_thread_state_t *thread_state, struct test_pal_logical_processor *lp, test_pal_thread_return_t (TEST_PAL_CALLING_CONVENTION *thread_function)(void *thread_user_state), void *thread_user_state );
86 void test_pal_thread_wait( test_pal_thread_state_t thread_state );
87 void test_pal_get_logical_core_ids( struct lfds700_list_asu_state *lasus );
89 void test_lfds700_pal_atomic( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
90 void test_lfds700_pal_atomic_cas( struct lfds700_list_asu_state *list_of_logical_processors );
91 void test_lfds700_pal_atomic_dwcas( struct lfds700_list_asu_state *list_of_logical_processors );
92 void test_lfds700_pal_atomic_exchange( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
94 void test_lfds700_hash_a( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
95 void test_lfds700_hash_a_alignment( void );
96 void test_lfds700_hash_a_fail_and_overwrite_on_existing_key( void );
97 void test_lfds700_hash_a_random_adds_fail_on_existing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
98 void test_lfds700_hash_a_random_adds_overwrite_on_existing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
99 void test_lfds700_hash_a_iterate( void );
101 void test_lfds700_list_aos( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
102 void test_lfds700_list_aos_alignment( void );
103 void test_lfds700_list_aos_new_ordered( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
104 void test_lfds700_list_aos_new_ordered_with_cursor( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
106 void test_lfds700_list_asu( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
107 void test_lfds700_list_asu_alignment( void );
108 void test_lfds700_list_asu_new_start( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
109 void test_lfds700_list_asu_new_end( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
110 void test_lfds700_list_asu_new_after( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
112 void test_lfds700_btree_au( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
113 void test_lfds700_btree_au_alignment( void );
114 void test_lfds700_btree_au_fail_and_overwrite_on_existing_key( void );
115 void test_lfds700_btree_au_random_adds_fail_on_existing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
116 void test_lfds700_btree_au_random_adds_overwrite_on_existing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
118 void test_lfds700_freelist( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
119 void test_lfds700_freelist_alignment( void );
120 void test_lfds700_freelist_popping( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
121 void test_lfds700_freelist_pushing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
122 void test_lfds700_freelist_popping_and_pushing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
123 void test_lfds700_freelist_rapid_popping_and_pushing( struct lfds700_list_asu_state *list_of_logical_processors );
124 void test_lfds700_freelist_pushing_array( void );
126 void test_lfds700_queue( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
127 void test_lfds700_queue_alignment( void );
128 void test_lfds700_queue_enqueuing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
129 void test_lfds700_queue_dequeuing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
130 void test_lfds700_queue_enqueuing_and_dequeuing( struct lfds700_list_asu_state *list_of_logical_processors );
131 void test_lfds700_queue_rapid_enqueuing_and_dequeuing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
132 void test_lfds700_queue_enqueuing_and_dequeuing_with_free( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
133 void test_lfds700_queue_enqueuing_with_malloc_and_dequeuing_with_free( struct lfds700_list_asu_state *list_of_logical_processors );
135 void test_lfds700_queue_bss( struct lfds700_list_asu_state *list_of_logical_processors );
136 void test_lfds700_queue_bss_enqueuing( void );
137 void test_lfds700_queue_bss_dequeuing( void );
138 void test_lfds700_queue_bss_enqueuing_and_dequeuing( struct lfds700_list_asu_state *list_of_logical_processors );
140 void test_lfds700_ringbuffer( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
141 void test_lfds700_ringbuffer_reading( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
142 void test_lfds700_ringbuffer_reading_and_writing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
143 void test_lfds700_ringbuffer_writing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
145 void test_lfds700_stack( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
146 void test_lfds700_stack_alignment( void );
147 void test_lfds700_stack_pushing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
148 void test_lfds700_stack_popping( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
149 void test_lfds700_stack_popping_and_pushing( struct lfds700_list_asu_state *list_of_logical_processors, lfds700_pal_uint_t memory_in_megabytes );
150 void test_lfds700_stack_rapid_popping_and_pushing( struct lfds700_list_asu_state *list_of_logical_processors );
151 void test_lfds700_stack_pushing_array( void );
153 /***** late includes *****/
154 #include "util_cmdline.h"
155 #include "util_memory_helpers.h"
156 #include "util_thread_starter.h"