From 34fd14036c5542f1566657dab1143d855e4154d2 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Mon, 15 Apr 2024 23:59:44 +0200 Subject: [PATCH] Add preliminary implementation of WhereAmI() --- common_arm64.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common_arm64.h b/common_arm64.h index 6ae6a35a30..2ab34686ec 100644 --- a/common_arm64.h +++ b/common_arm64.h @@ -55,6 +55,18 @@ 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" + ); + if (ret > MAX_CPU_NUMBER) ret = MAX_CPU_NUMBER; + return (int)ret; +} + static __inline void blas_lock(volatile BLASULONG *address){ BLASULONG ret;