MCPcopy Create free account
hub / github.com/apache/trafficserver / setup_test_case_1

Function setup_test_case_1

tools/benchmark/benchmark_FreeList.cc:121–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121void
122setup_test_case_1(const int64_t n)
123{
124 ink_thread list[n];
125
126#if TS_USE_HWLOC
127 // ThreadAffinityInitializer::set_affinity mimics
128 const hwloc_obj_type_t obj_type = thread_affinity();
129 const int obj_count = hwloc_get_nbobjs_by_type(ink_get_topology(), obj_type);
130
131 assert(obj_count > 0);
132
133 for (int i = 0; i < n; i++) {
134 ink_thread_create(&list[i], test_case_1, (void *)(static_cast<intptr_t>(i)), 0, 0, nullptr);
135
136 int dst = i;
137 if (thread_assiging_order == 1) {
138 // Assign threads one side of siblings first
139 dst = i * 2;
140 if (dst >= obj_count) {
141 dst = (i * 2 - obj_count) + 1;
142 }
143 }
144
145 hwloc_obj_t obj = hwloc_get_obj_by_type(ink_get_topology(), obj_type, dst % obj_count);
146 hwloc_set_thread_cpubind(ink_get_topology(), list[i], obj->cpuset, HWLOC_CPUBIND_STRICT);
147
148 if (debug_enabled) {
149 int cpu_mask_len = hwloc_bitmap_snprintf(nullptr, 0, obj->cpuset) + 1;
150 char *cpu_mask = static_cast<char *>(alloca(cpu_mask_len));
151 hwloc_bitmap_snprintf(cpu_mask, cpu_mask_len, obj->cpuset);
152
153 std::cout << "tid=" << list[i] << " obj->logical_index=" << obj->logical_index << " cpu_mask=" << cpu_mask << std::endl;
154 }
155 }
156#else
157 for (int i = 0; i < n; i++) {
158 ink_thread_create(&list[i], test_case_1, (void *)((intptr_t)i), 0, 0, nullptr);
159 }
160#endif
161
162 for (int i = 0; i < n; i++) {
163 ink_thread_join(list[i]);
164 }
165}
166
167TEST_CASE("simple new and free", "")
168{

Callers 1

BENCHMARKFunction · 0.85

Calls 4

thread_affinityFunction · 0.85
ink_get_topologyFunction · 0.85
ink_thread_createFunction · 0.85
ink_thread_joinFunction · 0.85

Tested by

no test coverage detected