Skip to content

fix cache_evict on aarch64 #2287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bench/BenchUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ void llc_flush(std::vector<char>& llc) {
}
}

#ifdef __aarch64__
void aarch64_flush_cache_line(void* addr) {
asm volatile("dc civac, %0" ::"r"(addr) : "memory");
}
#endif // __aarch64__

int fbgemm_get_max_threads() {
#if defined(FBGEMM_MEASURE_TIME_BREAKDOWN) || !defined(_OPENMP)
return 1;
Expand Down
6 changes: 6 additions & 0 deletions bench/BenchUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ void randFill(aligned_vector<T>& vec, T low, T high);

void llc_flush(std::vector<char>& llc);

#ifdef __aarch64__
void aarch64_flush_cache_line(void* addr);
#endif // __aarch64__

// Same as omp_get_max_threads() when OpenMP is available, otherwise 1
int fbgemm_get_max_threads();
// Same as omp_get_num_threads() when OpenMP is available, otherwise 1
Expand Down Expand Up @@ -73,6 +77,8 @@ NOINLINE float cache_evict(const T& vec) {
#if defined(__x86_64__) || defined(__i386__) || \
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)))
_mm_clflush(&data[i]);
#elif defined(__aarch64__)
aarch64_flush_cache_line((char*)&data[i]);
#else
__builtin___clear_cache(
(char*)&data[i], (char*)(&data[i] + CACHE_LINE_SIZE));
Expand Down