MCPcopy Create free account
hub / github.com/F-Stack/f-stack / plock_test1_lcore

Function plock_test1_lcore

dpdk/app/test/test_barrier.c:130–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130static int
131plock_test1_lcore(void *data)
132{
133 uint64_t tm;
134 uint32_t lc, ln;
135 uint64_t i, n;
136 struct lcore_plock_test *lpt;
137
138 lpt = data;
139 lc = rte_lcore_id();
140
141 /* find lcore_plock_test struct for given lcore */
142 for (ln = rte_lcore_count(); ln != 0 && lpt->lc != lc; lpt++, ln--)
143 ;
144
145 if (ln == 0) {
146 printf("%s(%u) error at init\n", __func__, lc);
147 return -1;
148 }
149
150 n = rte_rand() % ADD_MAX;
151 tm = rte_get_timer_cycles();
152
153 /*
154 * for each iteration:
155 * - update shared, locked protected data in a safe manner
156 * - update local copy of the shared data
157 */
158 for (i = 0; i != lpt->iter; i++) {
159
160 plock_add(lpt->pt[0], 0, n);
161 plock_add(lpt->pt[1], 1, n);
162
163 lpt->sum[0] += n;
164 lpt->sum[1] += n;
165
166 n = (n + 1) % ADD_MAX;
167 }
168
169 tm = rte_get_timer_cycles() - tm;
170
171 printf("%s(%u): %" PRIu64 " iterations finished, in %" PRIu64
172 " cycles, %#Lf cycles/iteration, "
173 "local sum={%" PRIu64 ", %" PRIu64 "}\n",
174 __func__, lc, i, tm, (long double)tm / i,
175 lpt->sum[0], lpt->sum[1]);
176 return 0;
177}
178
179/*
180 * For N active lcores we allocate N+1 lcore_plock_test structures.

Callers

nothing calls this directly

Calls 5

rte_lcore_idFunction · 0.85
rte_lcore_countFunction · 0.85
rte_randFunction · 0.85
plock_addFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected