From c57f9326d65a7d2044ef80aa5cf0ecb93e317a7f Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 17 Apr 2024 08:25:17 +0200 Subject: [PATCH] Add implementation of WhereAmI() to support NO_AFFINITY=0 on ARM64 (#4648) * Add preliminary implementation of WhereAmI() --- common_arm64.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common_arm64.h b/common_arm64.h index 6ae6a35a3..d80b9e434 100644 --- a/common_arm64.h +++ b/common_arm64.h @@ -55,6 +55,19 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSEMBLER +static __inline int WhereAmI(void){ + uint64_t ret; + __asm__ volatile ( + " mrs x0, mpidr_el1 \n" + " and x0, x0, 0xff \n" + :"=r" (ret) + :: "memory" + ); + ret +=1; + if ((int)ret <0) ret = 0; + return (int)ret; +} + static __inline void blas_lock(volatile BLASULONG *address){ BLASULONG ret;