Skip to content
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

Build fails on Ubuntu 20.04 aarch64 with undefined reference to 'WhereAmI' #4623

Closed
SurvivorNo1 opened this issue Apr 10, 2024 · 9 comments · Fixed by #4648
Closed

Build fails on Ubuntu 20.04 aarch64 with undefined reference to 'WhereAmI' #4623

SurvivorNo1 opened this issue Apr 10, 2024 · 9 comments · Fixed by #4648

Comments

@SurvivorNo1
Copy link

SurvivorNo1 commented Apr 10, 2024

Environment

- version: OpenBLAS-0.3.7
- OS: Ubuntu 20.04.2 LTS (Focal Fossa)
- CPU details:
Architecture: aarch64
CPU op-mode(s): 64-bit
Byte Order: Little Endian
CPU(s): 64
On-line CPU(s) list: 0-63
Thread(s) per core: 1
Core(s) per socket: 64
Socket(s): 1
NUMA node(s): 8
Vendor ID: 0x70
Model: 2
Stepping: 0x1
BogoMIPS: 100.00
L1d cache: 2 MiB
L1i cache: 2 MiB
L2 cache: 256 MiB
NUMA node0 CPU(s): 0-7
NUMA node1 CPU(s): 8-15
NUMA node2 CPU(s): 16-23
NUMA node3 CPU(s): 24-31
NUMA node4 CPU(s): 32-39
NUMA node5 CPU(s): 40-47
NUMA node6 CPU(s): 48-55
NUMA node7 CPU(s): 56-63
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1: Mitigation; __user pointer sanitization
Vulnerability Spectre v2: Vulnerable
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: fp asimd evtstrm crc32 cpuid

Issue description

Encountered a build error when compiling OpenBLAS on aarch64 architecture. The specific error message is

/usr/bin/ld: ../libopenblas_armv8p-r0.3.7.a(init.o): in function `gotoblas_set_affinity':
init.c:(.text+0xf8): undefined reference to `WhereAmI'
/usr/bin/ld: ../libopenblas_armv8p-r0.3.7.a(init.o): in function `get_node':
init.c:(.text+0x14c): undefined reference to `WhereAmI'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:146: zblat1] Error 1
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: ../libopenblas_armv8p-r0.3.7.a(init.o): in function `gotoblas_set_affinity':
init.c:(.text+0xf8): undefined reference to `WhereAmI'
/usr/bin/ld: ../libopenblas_armv8p-r0.3.7.a(init.o): in function `get_node':
init.c:(.text+0x14c): undefined reference to `WhereAmI'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:143: cblat1] Error 1

Steps to Reproduce

  1. Set the following configuration in Makefile.rule:
    NUM_THREADS = 64
    USE_OPENMP = 1
    NO_AFFINITY = 0
    
  2. Run the following build command:
    nohup make NO_AFFINITY=0 -j32 &> makelog &
    

Error Message

The build fails with the following output:

undefined reference to 'WhereAmI'

Log Files and output

see the attachment

@martin-frbg
Copy link
Collaborator

do you really need to build a version from almost five years ago ?

@brada4
Copy link
Contributor

brada4 commented Apr 11, 2024

set affinity with omp is absolutely unnecessary. Omp does manage affinity by itself. You need newer openblas, release from here or at least build dsc/dpkg from later/st ubuntu code.
I remember time I cleaned whereami, likely some aarch64 branch caried it back in rarely used patameter combo. Id assume it is long cleaned up.

@SurvivorNo1
Copy link
Author

Thank you both for your input! I understand your points, but I need to maintain consistency with the environment described in a particular research paper. Therefore, I do need to build a version from almost five years ago. However, I will also try the latest version as suggested. I appreciate your and will close this issue.

@brada4
Copy link
Contributor

brada4 commented Apr 11, 2024

You need slow netlib lapack for consistency, openblas like any other accelerated library will diverge few bits precision from reference.

@martin-frbg
Copy link
Collaborator

Hmm, this is interesting. I suspect this problem persists in the current codebase, but is only triggered by NO_AFFINITY=0

@martin-frbg martin-frbg reopened this Apr 11, 2024
@brada4
Copy link
Contributor

brada4 commented Apr 11, 2024

IMO something following this?
2601cd5

@martin-frbg
Copy link
Collaborator

martin-frbg commented Apr 12, 2024

@brada4 no, not directly related to that. Setting up for handling affinity requires fetching the numerical ID of the cores each thread is running on, which is what WhereAmI is supposed to deliver. Unfortunately I'm not quite clear on how to parse the MPIDR_EL1 output on aarch64, a quick kludge would be to put the following function in common_arm64.h
somewhere below the #ifndef ASSEMBLER line

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;
}

or just make it

static inline int WhereAmI(void){
return (sched_getcpu());
}

if you are on Linux with a fairly recent glibc

@brada4
Copy link
Contributor

brada4 commented Apr 12, 2024

Or noop it...

@martin-frbg
Copy link
Collaborator

Or noop it...

strange suggestion when compiling with NO_AFFINITY=0 on purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants