2019-08-07 12:58:28 +08:00
|
|
|
/*
|
2023-12-01 22:35:38 +08:00
|
|
|
* Copyright (C) 2020-2023 Intel Corporation
|
2019-08-07 12:58:28 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/utilities/cpuintrinsics.h"
|
2019-08-07 12:58:28 +08:00
|
|
|
|
2023-12-01 22:35:38 +08:00
|
|
|
#if defined(_WIN32)
|
2023-12-13 20:22:24 +08:00
|
|
|
#include <immintrin.h>
|
2023-12-01 22:35:38 +08:00
|
|
|
#include <intrin.h>
|
2023-12-13 20:22:24 +08:00
|
|
|
#pragma intrinsic(__rdtsc)
|
2023-12-01 22:35:38 +08:00
|
|
|
#else
|
2023-12-13 20:22:24 +08:00
|
|
|
#include <immintrin.h>
|
2023-12-01 22:35:38 +08:00
|
|
|
#include <x86intrin.h>
|
|
|
|
#endif
|
|
|
|
|
2021-09-03 05:25:03 +08:00
|
|
|
#if defined(__ARM_ARCH)
|
|
|
|
#include <sse2neon.h>
|
|
|
|
#else
|
2019-08-07 12:58:28 +08:00
|
|
|
#include <emmintrin.h>
|
2021-09-03 05:25:03 +08:00
|
|
|
#endif
|
2019-08-07 12:58:28 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
namespace CpuIntrinsics {
|
|
|
|
|
|
|
|
void clFlush(void const *ptr) {
|
|
|
|
_mm_clflush(ptr);
|
|
|
|
}
|
|
|
|
|
2023-12-01 22:35:38 +08:00
|
|
|
void clFlushOpt(void *ptr) {
|
|
|
|
#ifdef SUPPORTS_CLFLUSHOPT
|
|
|
|
_mm_clflushopt(ptr);
|
|
|
|
#else
|
|
|
|
_mm_clflush(ptr);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-04-01 19:47:24 +08:00
|
|
|
void sfence() {
|
|
|
|
_mm_sfence();
|
|
|
|
}
|
|
|
|
|
2020-01-14 20:52:06 +08:00
|
|
|
void pause() {
|
|
|
|
_mm_pause();
|
|
|
|
}
|
|
|
|
|
2023-12-13 20:22:24 +08:00
|
|
|
unsigned char umwait(unsigned int ctrl, uint64_t counter) {
|
|
|
|
#ifdef SUPPORTS_WAITPKG
|
|
|
|
return _umwait(ctrl, counter);
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void umonitor(void *a) {
|
|
|
|
#ifdef SUPPORTS_WAITPKG
|
|
|
|
_umonitor(a);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t rdtsc() {
|
|
|
|
return __rdtsc();
|
|
|
|
}
|
|
|
|
|
2019-08-07 12:58:28 +08:00
|
|
|
} // namespace CpuIntrinsics
|
|
|
|
} // namespace NEO
|