* test case to time the number of cycles to round-trip a cache line between * two cores and back again. */
| 60 | * two cores and back again. |
| 61 | */ |
| 62 | static void |
| 63 | time_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 |
no test coverage detected