diff options
author | Jordan Justen <jordan.l.justen@intel.com> | 2023-03-30 00:50:10 -0700 |
---|---|---|
committer | Jordan Justen <jordan.l.justen@intel.com> | 2023-04-06 18:55:53 -0400 |
commit | aa43ae0570d68b2ab1a2c7bd283ec78e88d2c5ed (patch) | |
tree | c7479d13c3781f58755b950796565f0f3f51244b | |
parent | 5879d39e4d2cd3c6d50b66c4f2ddab1044fb1eb3 (diff) |
intel/clflush: Add support for clflushopt instruction
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
-rw-r--r-- | src/intel/common/intel_clflush.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/intel/common/intel_clflush.h b/src/intel/common/intel_clflush.h index a4f33cbe1eb..2ce6bcbdbe0 100644 --- a/src/intel/common/intel_clflush.h +++ b/src/intel/common/intel_clflush.h @@ -24,18 +24,48 @@ #ifndef INTEL_CLFLUSH_H #define INTEL_CLFLUSH_H +#ifdef HAVE___BUILTIN_IA32_CLFLUSHOPT +#include "util/u_cpu_detect.h" +#endif + #define CACHELINE_SIZE 64 #define CACHELINE_MASK 63 #ifdef SUPPORT_INTEL_INTEGRATED_GPUS +static bool +intel_has_clflushopt(void) +{ +#ifdef HAVE___BUILTIN_IA32_CLFLUSHOPT + const struct util_cpu_caps_t *cpu_caps = util_get_cpu_caps(); + return cpu_caps->has_clflushopt; +#else + return false; +#endif +} + +static void +intel_clflushopt(void *p) +{ +#ifdef HAVE___BUILTIN_IA32_CLFLUSHOPT + __builtin_ia32_clflushopt(p); +#else + assert(!"clflushopt is not supported by this compiler!"); + __builtin_ia32_clflush(p); +#endif +} + static inline void intel_clflush_range(void *start, size_t size) { void *p = (void *) (((uintptr_t) start) & ~CACHELINE_MASK); void *end = start + size; + bool has_clflushopt = intel_has_clflushopt(); while (p < end) { - __builtin_ia32_clflush(p); + if (has_clflushopt) + intel_clflushopt(p); + else + __builtin_ia32_clflush(p); p += CACHELINE_SIZE; } } |