Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,8 @@ hheei <hheei@users.noreply.github.com>
* Aadityansha Verma <https://github.com/aadityansha06>
* [2026-07-14] Add independent transpose support for C in GEADD (sgeadd/dgeadd/cgeadd/zgeadd).

* Vincent Lovero <https://github.com/vlovero>
* [2026-08-11] ARM v9.2 SME GEMM kernels for Apple M

* Hugo Meiland <hugo@meiland.nl>
* [2026-08-09] Add Cortex-A72 DGEMM 6x8 microkernel and blocking
4 changes: 2 additions & 2 deletions Makefile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ endif
endif

ifeq ($(CORE), ARMV9SME)
CCOMMON_OPT += -march=armv9-a+sve2+sme
CCOMMON_OPT += -march=armv9-a+sve2+sme+sme-f64f64
FCOMMON_OPT += -march=armv9-a+sve2
ifdef OS_WINDOWS
ifeq ($(C_COMPILER), CLANG)
Expand Down Expand Up @@ -310,7 +310,7 @@ endif

ifeq ($(CORE), VORTEXM4)
ifneq ($(C_COMPILER), GCC)
CCOMMON_OPT += -march=armv8.4-a+sme
CCOMMON_OPT += -march=armv8.4-a+sme+sme-f64f64
#ifneq ($(APPLECLANG),1)
#override LDFLAGS += -lclang_rt_builtins-aarch64
#endif
Expand Down
36 changes: 35 additions & 1 deletion benchmark/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ else
GOTO_HFLOAT_TARGETS=
endif

ifeq ($(USE_OPENMP), 1)
SMALLSCALING=smallscaling
endif

ifeq ($(OSNAME), WINNT)

goto :: slinpack.goto dlinpack.goto clinpack.goto zlinpack.goto \
scholesky.goto dcholesky.goto ccholesky.goto zcholesky.goto \
cblas_sgemm.goto cblas_dgemm.goto cblas_cgemm.goto cblas_zgemm.goto \
sgemm.goto dgemm.goto cgemm.goto zgemm.goto \
strmm.goto dtrmm.goto ctrmm.goto ztrmm.goto \
strsm.goto dtrsm.goto ctrsm.goto ztrsm.goto \
Expand Down Expand Up @@ -268,6 +273,7 @@ mkl :: slinpack.mkl dlinpack.mkl clinpack.mkl zlinpack.mkl \
else

goto :: sgemm.goto dgemm.goto cgemm.goto zgemm.goto \
cblas_sgemm.goto cblas_dgemm.goto cblas_cgemm.goto cblas_zgemm.goto \
strmm.goto dtrmm.goto ctrmm.goto ztrmm.goto \
strsm.goto dtrsm.goto ctrsm.goto ztrsm.goto \
sspr.goto dspr.goto \
Expand Down Expand Up @@ -301,7 +307,7 @@ goto :: sgemm.goto dgemm.goto cgemm.goto zgemm.goto \
stpsv.goto dtpsv.goto ctpsv.goto ztpsv.goto \
strsv.goto dtrsv.goto ctrsv.goto ztrsv.goto \
ssymm.goto dsymm.goto csymm.goto zsymm.goto \
smallscaling \
$(SMALLSCALING) \
isamax.goto idamax.goto icamax.goto izamax.goto \
ismax.goto idmax.goto \
isamin.goto idamin.goto icamin.goto izamin.goto \
Expand Down Expand Up @@ -681,6 +687,18 @@ endif
sgemm.goto : sgemm.$(SUFFIX) ../$(LIBNAME)
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm

cblas_sgemm.goto : cblas_sgemm.$(SUFFIX) ../$(LIBNAME)
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm

cblas_dgemm.goto : cblas_dgemm.$(SUFFIX) ../$(LIBNAME)
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm

cblas_cgemm.goto : cblas_cgemm.$(SUFFIX) ../$(LIBNAME)
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm

cblas_zgemm.goto : cblas_zgemm.$(SUFFIX) ../$(LIBNAME)
$(CC) $(CFLAGS) -o $(@F) $^ $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB) -lm

sgemm.acml : sgemm.$(SUFFIX)
-$(CC) $(CFLAGS) -o $(@F) $^ $(LIBACML) $(CEXTRALIB) $(EXTRALIB) $(FEXTRALIB)

Expand Down Expand Up @@ -3027,6 +3045,18 @@ cgemm.$(SUFFIX) : gemm.c
zgemm.$(SUFFIX) : gemm.c
$(CC) $(CFLAGS) -c -DCOMPLEX -DDOUBLE -o $(@F) $^

cblas_sgemm.$(SUFFIX) : cblasgemm.c
$(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^

cblas_dgemm.$(SUFFIX) : cblasgemm.c
$(CC) $(CFLAGS) -c -UCOMPLEX -DDOUBLE -o $(@F) $^

cblas_cgemm.$(SUFFIX) : cblasgemm.c
$(CC) $(CFLAGS) -c -DCOMPLEX -UDOUBLE -o $(@F) $^

cblas_zgemm.$(SUFFIX) : cblasgemm.c
$(CC) $(CFLAGS) -c -DCOMPLEX -DDOUBLE -o $(@F) $^

ssymm.$(SUFFIX) : symm.c
$(CC) $(CFLAGS) -c -UCOMPLEX -UDOUBLE -o $(@F) $^

Expand Down Expand Up @@ -3533,7 +3563,11 @@ zomatcopy.$(SUFFIX) : omatcopy.c


smallscaling: smallscaling.c ../$(LIBNAME)
ifeq ($(C_COMPILER), GCC)
$(CC) $(CFLAGS) -o $(@F) $^ $(EXTRALIB) -fopenmp -lm -lpthread
else
$(CC) $(CFLAGS) -o $(@F) $^ $(EXTRALIB) -quak -openmp -lm -lpthread
endif

clean ::
@rm -f *.goto *.mkl *.acml *.atlas *.veclib *.essl smallscaling
Expand Down
233 changes: 233 additions & 0 deletions benchmark/cblasgemm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
/***************************************************************************
Copyright (c) 2014, 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.
*****************************************************************************/

#include "bench.h"
#include "cblas.h"
#undef GEMM

#ifndef COMPLEX

#ifdef DOUBLE
#define GEMM cblas_dgemm
#elif defined(BFLOAT16) && defined(BGEMM)
#define GEMM cblas_bgemm
#elif defined(BFLOAT16)
#define GEMM cblas_sbgemm
#undef IFLOAT
#define IFLOAT bfloat16
#elif defined(HFLOAT16)
#define GEMM cblas_shgemm
#undef IFLOAT
#define IFLOAT hfloat16
#else
#define GEMM cblas_sgemm
#undef IFLOAT
#define IFLOAT float
#endif

#else

#ifdef DOUBLE
#define GEMM cblas_zgemm
#else
#define GEMM cblas_cgemm
#endif

#endif

int main(int argc, char *argv[]){

IFLOAT *a, *b;
//IFLOAT *aa, *bb;
FLOAT *c;
//FLOAT *cc;
#ifdef BGEMM
blasint one=1;
blasint two=2;
float alpha_in[] = {1.0, 0.0};
float beta_in[] = {0.0, 0.0};
FLOAT alpha[2], beta[2];
sbstobf16_(&two, alpha_in, &one, alpha, &one);
sbstobf16_(&two, beta_in, &one, beta, &one);
#else
#ifdef COMPLEX
FLOAT alpha[] = {1.0, 0.0};
FLOAT beta [] = {0.0, 0.0};
#else
FLOAT alpha = 1.0;
FLOAT beta = 0.0;
#endif
#endif
CBLAS_TRANSPOSE transa = CblasNoTrans;
CBLAS_TRANSPOSE transb = CblasNoTrans;
char transac, transbc;
blasint m, n, k, i, j, lda, ldb, ldc;
int loops = 1;
int has_param_m = 0;
int has_param_n = 0;
int has_param_k = 0;
int has_param_lda = 0;
int has_param_ldb = 0;
char *p;
//blasint sme=0;
int from = 1;
int to = 200;
int step = 1;

double time1, timeg;

argc--;argv++;

if (argc > 0) { from = atol(*argv); argc--; argv++; }
if (argc > 0) { to = MAX(atol(*argv), from); argc--; argv++; }
if (argc > 0) { step = atol(*argv); argc--; argv++; }

if ((p = getenv("OPENBLAS_TRANS"))) {
transa=(*p=='N') ? CblasNoTrans : CblasTrans;
transb=(*p=='N') ? CblasNoTrans : CblasTrans;
}
if ((p = getenv("OPENBLAS_TRANSA"))) {
transa=(*p=='N') ? CblasNoTrans : CblasTrans;
}
if ((p = getenv("OPENBLAS_TRANSB"))) {
transb=(*p=='N') ? CblasNoTrans : CblasTrans;
}

transac=(transa==CblasNoTrans) ? 'N' : 'T';
transbc=(transb==CblasNoTrans) ? 'N' : 'T';
fprintf(stderr, "From : %3d To : %3d Step=%d : Transa=%c : Transb=%c\n", from, to, step, transac, transbc);

p = getenv("OPENBLAS_LOOPS");
if ( p != NULL ) {
loops = atoi(p);
}

if ((p = getenv("OPENBLAS_PARAM_M"))) {
m = atoi(p);
has_param_m=1;
} else {
m = to;
}
if ((p = getenv("OPENBLAS_PARAM_N"))) {
n = atoi(p);
has_param_n=1;
} else {
n = to;
}
if ((p = getenv("OPENBLAS_PARAM_K"))) {
k = atoi(p);
has_param_k=1;
} else {
k = to;
}
if ((p = getenv("OPENBLAS_PARAM_LDA"))) {
lda = atoi(p);
has_param_lda=1;
}
if ((p = getenv("OPENBLAS_PARAM_LDB"))) {
ldb = atoi(p);
has_param_ldb=1;
}

if (( a = (IFLOAT *)malloc(sizeof(IFLOAT) * m * k * COMPSIZE)) == NULL) {
fprintf(stderr,"Out of Memory!!\n");exit(1);
}
if (( b = (IFLOAT *)malloc(sizeof(IFLOAT) * k * n * COMPSIZE)) == NULL) {
fprintf(stderr,"Out of Memory!!\n");exit(1);
}
if (( c = (FLOAT *)malloc(sizeof(FLOAT) * m * n * COMPSIZE)) == NULL) {
fprintf(stderr,"Out of Memory!!\n");exit(1);
}
//if (( aa = (IFLOAT *)malloc(sizeof(IFLOAT) * m * k * COMPSIZE)) == NULL) {
// fprintf(stderr,"Out of Memory!!\n");exit(1);
//}
//if (( bb = (IFLOAT *)malloc(sizeof(IFLOAT) * k * n * COMPSIZE)) == NULL) {
// fprintf(stderr,"Out of Memory!!\n");exit(1);
//}
//if (( cc = (FLOAT *)malloc(sizeof(FLOAT) * m * n * COMPSIZE)) == NULL) {
// fprintf(stderr,"Out of Memory!!\n");exit(1);
//}

#ifdef __linux
srandom(getpid());
#endif

for (i = 0; i < m * k * COMPSIZE; i++) {
a[i] = ((IFLOAT) rand() / (IFLOAT) RAND_MAX) - 0.5;
// aa[i]=a[i];
}
for (i = 0; i < k * n * COMPSIZE; i++) {
b[i] = ((IFLOAT) rand() / (IFLOAT) RAND_MAX) - 0.5;
// bb[i]=b[i];
}
for (i = 0; i < m * n * COMPSIZE; i++) {
c[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
// cc[i]=c[i];
}

fprintf(stderr, " SIZE Flops Time\n");

for (i = from; i <= to; i += step) {

timeg=0;

if (!has_param_m) { m = i; }
if (!has_param_n) { n = i; }
if (!has_param_k) { k = i; }

if (!has_param_lda) {
if (transa == CblasNoTrans) { lda = k; }
else { lda = m; }
}
if (!has_param_ldb) {
if (transb == CblasNoTrans) { ldb = n; }
else { ldb = k; }
}
ldc = n;

fprintf(stderr, " M=%4d, N=%4d, K=%4d : ", (int)m, (int)n, (int)k);
begin();

for (j=0; j<loops; j++) {
GEMM (CblasRowMajor,transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc);
}

// for (ii = 0; ii < m * n * COMPSIZE; ii++) if (fabsf(c[ii]-cc[ii])>1.5e-5){fprintf(stderr,"mismatch %d %f != %f: %g\n",ii,c[ii],cc[ii],fabsf(c[ii]-cc[ii]));}
end();
time1 = getsec();

timeg = time1/loops;
fprintf(stderr,
" %10.2f MFlops %10.6f sec\n",
COMPSIZE * COMPSIZE * 2. * (double)k * (double)m * (double)n / timeg * 1.e-6, time1);

}

return 0;
}

// void main(int argc, char *argv[]) __attribute__((weak, alias("MAIN__")));
4 changes: 3 additions & 1 deletion benchmark/gemm.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//#pragma clang optimize off
/***************************************************************************
Copyright (c) 2014, The OpenBLAS Project
All rights reserved.
Expand Down Expand Up @@ -45,6 +46,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define IFLOAT hfloat16
#else
#define GEMM BLASFUNC(sgemm)
#undef IFLOAT
#define IFLOAT float
#endif

Expand Down Expand Up @@ -186,7 +188,7 @@ int main(int argc, char *argv[]){

timeg = time1/loops;
fprintf(stderr,
" %10.2f MFlops %10.6f sec\n",
" %10.2lf MFlops %10.6f sec\n",
COMPSIZE * COMPSIZE * 2. * (double)k * (double)m * (double)n / timeg * 1.e-6, time1);

}
Expand Down
4 changes: 2 additions & 2 deletions cmake/cc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ if (${CORE} STREQUAL ARMV9SME)
if (${CMAKE_C_COMPILER_ID} STREQUAL "NVHPC" AND NOT NO_SVE)
set (CCOMMON_OPT "${CCOMMON_OPT} -tp=host")
else ()
set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv9-a+sme")
set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv9-a+sme+sme-f64f64")
if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_C_COMPILER_ID MATCHES "Clang")
set (CCOMMON_OPT "${CCOMMON_OPT} -mllvm --aarch64-stack-hazard-size=0")
endif ()
Expand All @@ -329,7 +329,7 @@ if (${CORE} STREQUAL VORTEXM4)
set (CCOMMON_OPT "${CCOMMON_OPT} -tp=host")
else ()
if (${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang")
set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.4-a+sme -mcpu=apple-m4")
set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.4-a+sme+sme-f64f64 -mcpu=apple-m4")
else ()
set (CCOMMON_OPT "${CCOMMON_OPT} -march=armv8.4-a -mcpu=apple-m4")
endif ()
Expand Down
4 changes: 2 additions & 2 deletions cmake/system.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,13 @@ if (${TARGET} STREQUAL NEOVERSEV1)
endif()
endif()
if (${TARGET} STREQUAL ARMV9SME)
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -march=armv9-a+sme -O3")
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -march=armv9-a+sme+sme-f64f64 -O3")
if (${CMAKE_SYSTEM_NAME} STREQUAL Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "Clang")
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -mllvm --aarch64-stack-hazard-size=0")
endif()
endif()
if (${TARGET} STREQUAL VORTEXM4)
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -march=armv8.4-a+sme -O3")
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -march=armv8.4-a+sme+sme-f64f64 -O3")
if (${CMAKE_SYSTEM_NAME} STREQUAL Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "Clang")
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -mllvm --aarch64-stack-hazard-size=0")
endif()
Expand Down
Loading
Loading