5 #include "caffe2/core/logging.h" 6 #include "caffe2/utils/bench_utils.h" 10 uint32_t wipe_cache() {
11 static uint32_t* wipe_buffer =
nullptr;
12 static size_t wipe_size = 0;
14 if (wipe_buffer ==
nullptr) {
15 CAFFE_ENFORCE(cpuinfo_initialize(),
"failed to initialize cpuinfo");
16 const cpuinfo_processor* processor = cpuinfo_get_processor(0);
17 if (processor->cache.l4 !=
nullptr) {
18 wipe_size = processor->cache.l4->size;
19 }
else if (processor->cache.l3 !=
nullptr) {
20 wipe_size = processor->cache.l3->size;
21 }
else if (processor->cache.l2 !=
nullptr) {
22 wipe_size = processor->cache.l2->size;
24 wipe_size = processor->cache.l1d->size;
26 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64 31 switch (processor->core->uarch) {
32 case cpuinfo_uarch_cortex_a5:
33 wipe_size = 512 * 1024;
35 case cpuinfo_uarch_cortex_a7:
36 wipe_size = 1024 * 1024;
38 case cpuinfo_uarch_cortex_a8:
39 wipe_size = 1024 * 1024;
41 case cpuinfo_uarch_cortex_a9:
42 wipe_size = 1024 * 1024;
44 case cpuinfo_uarch_cortex_a12:
45 case cpuinfo_uarch_cortex_a17:
46 wipe_size = 8 * 1024 * 1024;
48 case cpuinfo_uarch_cortex_a15:
49 wipe_size = 4 * 1024 * 1024;
51 case cpuinfo_uarch_cortex_a35:
52 wipe_size = 1024 * 1024;
54 case cpuinfo_uarch_cortex_a53:
55 wipe_size = 2 * 1024 * 1024;
57 case cpuinfo_uarch_cortex_a57:
58 wipe_size = 2 * 1024 * 1024;
60 case cpuinfo_uarch_cortex_a72:
61 wipe_size = 4 * 1024 * 1024;
63 case cpuinfo_uarch_cortex_a73:
64 wipe_size = 8 * 1024 * 1024;
66 case cpuinfo_uarch_cortex_a55:
67 case cpuinfo_uarch_cortex_a75:
68 case cpuinfo_uarch_meerkat_m3:
69 wipe_size = 4 * 1024 * 1024;
72 wipe_size = 60 * 1024 * 1024;
76 LOG(INFO) <<
"Allocating cache wipe buffer of size " << wipe_size;
77 wipe_buffer =
static_cast<uint32_t*
>(malloc(wipe_size));
78 CAFFE_ENFORCE(wipe_buffer !=
nullptr);
81 for (uint32_t i = 0; i *
sizeof(uint32_t) < wipe_size; i += 8) {
82 hash ^= wipe_buffer[i];
83 wipe_buffer[i] = hash;
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...