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

Function time_cache_line_switch

dpdk/app/test/test_distributor_perf.c:62–92  ·  view source on GitHub ↗

* test case to time the number of cycles to round-trip a cache line between * two cores and back again. */

Source from the content-addressed store, hash-verified

60 * two cores and back again.
61 */
62static void
63time_cache_line_switch(void)
64{
65 /* allocate a full cache line for data, we use only first byte of it */
66 uint64_t data[RTE_CACHE_LINE_SIZE*3 / sizeof(uint64_t)];
67
68 unsigned int i, workerid = rte_get_next_lcore(rte_lcore_id(), 0, 0);
69 volatile uint64_t *pdata = &data[0];
70 *pdata = 1;
71 rte_eal_remote_launch((lcore_function_t *)flip_bit, &data[0], workerid);
72 while (*pdata)
73 rte_pause();
74
75 const uint64_t start_time = rte_rdtsc();
76 for (i = 0; i < (1 << ITER_POWER_CL); i++) {
77 while (*pdata)
78 rte_pause();
79 *pdata = 1;
80 }
81 const uint64_t end_time = rte_rdtsc();
82
83 while (*pdata)
84 rte_pause();
85 *pdata = 2;
86 rte_eal_wait_lcore(workerid);
87 printf("==== Cache line switch test ===\n");
88 printf("Time for %u iterations = %"PRIu64" ticks\n", (1<<ITER_POWER_CL),
89 end_time-start_time);
90 printf("Ticks per iteration = %"PRIu64"\n\n",
91 (end_time-start_time) >> ITER_POWER_CL);
92}
93
94/*
95 * returns the total count of the number of packets handled by the worker

Callers 1

test_distributor_perfFunction · 0.85

Calls 7

rte_get_next_lcoreFunction · 0.85
rte_lcore_idFunction · 0.85
rte_eal_remote_launchFunction · 0.85
rte_eal_wait_lcoreFunction · 0.85
rte_pauseFunction · 0.50
rte_rdtscFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected