I need to build OpenBLAS
library of iOS
. I've chosen to build 0.3.6
version of it. I believe that is the most updated stable version of the library.
You can find releases of this library here - https://github.com/xianyi/OpenBLAS/releases
I encounter next problem - it seems that assembly compiler provided by clang
which can be found in XCode
doesn't seem to understand certain syntax in .S
files library provides.
I have two files (nrm2.S
and znrm2.S
) which cause all my troubles. Here's nrm2.S
. I won't provide the other file because errors there is exactly the same. But if you want to take a look at it as well, I will post it, just let me know:
/*******************************************************************************
Copyright (c) 2015, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#define ASSEMBLER
#include "common.h"
#define N x0
#define X x1
#define INC_X x2
#define I x3
#if !defined(DOUBLE)
#define SSQ s0
#define SCALE s1
#define REGZERO s5
#define REGONE s6
#else
#define SSQ d0
#define SCALE d1
#define REGZERO d5
#define REGONE d6
#endif
/*******************************************************************************
* Macro definitions
*******************************************************************************/
.macro KERNEL_F1
#if !defined(DOUBLE)
ldr s4, [X], #4
fcmp s4, REGZERO
beq KERNEL_F1_NEXT_\@
fabs s4, s4
fcmp SCALE, s4
bge KERNEL_F1_SCALE_GE_X_\@
fdiv s2, SCALE, s4
fmul s2, s2, s2
fmul s3, SSQ, s2
fadd SSQ, REGONE, s3
fmov SCALE, s4
b KERNEL_F1_NEXT_\@
KERNEL_F1_SCALE_GE_X_\@:
fdiv s2, s4, SCALE
fmla SSQ, s2, v2.s[0]
#else
ldr d4, [X], #8
fcmp d4, REGZERO
beq KERNEL_F1_NEXT_\@
fabs d4, d4
fcmp SCALE, d4
bge KERNEL_F1_SCALE_GE_X_\@
fdiv d2, SCALE, d4
fmul d2, d2, d2
fmul d3, SSQ, d2
fadd SSQ, REGONE, d3
fmov SCALE, d4
b KERNEL_F1_NEXT_\@
KERNEL_F1_SCALE_GE_X_\@:
fdiv d2, d4, SCALE
fmla SSQ, d2, v2.d[0]
#endif
KERNEL_F1_NEXT_\@:
.endm
.macro KERNEL_S1
#if !defined(DOUBLE)
ldr s4, [X]
fcmp s4, REGZERO
beq KERNEL_S1_NEXT
fabs s4, s4
fcmp SCALE, s4
bge KERNEL_S1_SCALE_GE_X
fdiv s2, SCALE, s4
fmul s2, s2, s2
fmul s3, SSQ, s2
fadd SSQ, REGONE, s3
fmov SCALE, s4
b KERNEL_S1_NEXT
KERNEL_S1_SCALE_GE_X:
fdiv s2, s4, SCALE
fmla SSQ, s2, v2.s[0]
#else
ldr d4, [X]
fcmp d4, REGZERO
beq KERNEL_S1_NEXT
fabs d4, d4
fcmp SCALE, d4
bge KERNEL_S1_SCALE_GE_X
fdiv d2, SCALE, d4
fmul d2, d2, d2
fmul d3, SSQ, d2
fadd SSQ, REGONE, d3
fmov SCALE, d4
b KERNEL_S1_NEXT
KERNEL_S1_SCALE_GE_X:
fdiv d2, d4, SCALE
fmla SSQ, d2, v2.d[0]
#endif
KERNEL_S1_NEXT:
add X, X, INC_X
.endm
.macro KERNEL_F8
KERNEL_F1
KERNEL_F1
KERNEL_F1
KERNEL_F1
KERNEL_F1
KERNEL_F1
KERNEL_F1
KERNEL_F1
.endm
.macro INIT_S
#if !defined(DOUBLE)
lsl INC_X, INC_X, #2 // INC_X * SIZE
#else
lsl INC_X, INC_X, #3 // INC_X * SIZE
#endif
.endm
.macro INIT
eor v1.16b, v1.16b, v1.16b // scale=0.0
fmov SSQ, #1.0
fmov REGONE, SSQ
fmov REGZERO, SCALE
.endm
/*******************************************************************************
* End of macro definitions
*******************************************************************************/
PROLOGUE
.align 5
INIT
cmp N, #0
ble .Lnrm2_kernel_L999
cmp INC_X, #0
beq .Lnrm2_kernel_L999
cmp INC_X, #1
bne .Lnrm2_kernel_S_BEGIN
.Lnrm2_kernel_F_BEGIN:
asr I, N, #3 // I = N / 8
cmp I, xzr
ble .Lnrm2_kernel_F1
.Lnrm2_kernel_F8:
KERNEL_F8
subs I, I, #1
bne .Lnrm2_kernel_F8
.Lnrm2_kernel_F1:
ands I, N, #7
ble .Lnrm2_kernel_L999
.Lnrm2_kernel_F10:
KERNEL_F1
subs I, I, #1
bne .Lnrm2_kernel_F10
b .Lnrm2_kernel_L999
.Lnrm2_kernel_S_BEGIN:
INIT_S
mov I, N
.align 5
.Lnrm2_kernel_S10:
KERNEL_S1
subs I, I, #1
bne .Lnrm2_kernel_S10
.Lnrm2_kernel_L999:
fsqrt SSQ, SSQ
fmul SSQ, SCALE, SSQ
ret
EPILOGUE
When compiler tries to handle that file, it gives me next errors:
<instantiation>:7:2: note: while in macro instantiation
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -arch arm64 -miphoneos-version-min=10.0 -O2 -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=8 -DMAX_PARALLEL_NUMBER=1 -DVERSION=\"0.3.6\" -march=armv8-a -DASMNAME=_sgemm_oncopy -DASMFNAME=_sgemm_oncopy_ -DNAME=sgemm_oncopy_ -DCNAME=sgemm_oncopy -DCHAR_NAME=\"sgemm_oncopy_\" -DCHAR_CNAME=\"sgemm_oncopy\" -DNO_AFFINITY -I.. -UDOUBLE -UCOMPLEX -c -UDOUBLE -UCOMPLEX ../kernel/arm64/../generic/gemm_ncopy_4.c -o sgemm_oncopy.o
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:14:22: error: unknown token in expression
KERNEL_F1_SCALE_GE_X_\@:
^
<instantiation>:7:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:14:22: error: invalid operand
KERNEL_F1_SCALE_GE_X_\@:
^
<instantiation>:7:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
../kernel/arm64/nrm2.S:87:16: error: unknown token in expression
KERNEL_F1_NEXT_\@:
^
<instantiation>:7:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
../kernel/arm64/nrm2.S:87:16: error: invalid operand
KERNEL_F1_NEXT_\@:
^
<instantiation>:7:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:4:21: error: unexpected token in argument list
beq KERNEL_F1_NEXT_\@
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:7:27: error: unexpected token in argument list
bge KERNEL_F1_SCALE_GE_X_\@
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:13:19: error: unexpected token in argument list
b KERNEL_F1_NEXT_\@
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:14:22: error: unknown token in expression
KERNEL_F1_SCALE_GE_X_\@:
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:14:22: error: invalid operand
KERNEL_F1_SCALE_GE_X_\@:
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
../kernel/arm64/nrm2.S:87:16: error: unknown token in expression
KERNEL_F1_NEXT_\@:
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
../kernel/arm64/nrm2.S:87:16: error: invalid operand
KERNEL_F1_NEXT_\@:
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:4:21: error: unexpected token in argument list
beq KERNEL_F1_NEXT_\@
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
<instantiation>:7:27: error: unexpected token in argument list
bge KERNEL_F1_SCALE_GE_X_\@
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
<instantiation>:13:19: error: unexpected token in argument list
b KERNEL_F1_NEXT_\@
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
<instantiation>:14:22: error: unknown token in expression
KERNEL_F1_SCALE_GE_X_\@:
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
<instantiation>:14:22: error: invalid operand
KERNEL_F1_SCALE_GE_X_\@:
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
../kernel/arm64/nrm2.S:87:16: error: unknown token in expression
KERNEL_F1_NEXT_\@:
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
../kernel/arm64/nrm2.S:87:16: error: invalid operand
KERNEL_F1_NEXT_\@:
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
While I was searching for an explanation of the issue I found this link - https://www.avrfreaks.net/forum/labels-inside-macros . It gave me an understanding that troubled \@
symbol is sort of label counter which handles the problem of unique label names inside GAS
macro.
Unfortunately, I know almost nothing about Assembler and can not provide a fix to it on my own. So I figured maybe there're assembly gurus here who is willing to guide me through that "dark forest" .
Is there a chance that \@
is relatively new symbol and Apple's compiler doesn't know about it yet? What should I do to fix that problem?
Thanks in advance!