Accelerate framework uses only one core on Mac M1

The following C program (dgesv_ex.c)
Code Block
#include <stdlib.h>
#include <stdio.h>
/* DGESV prototype */
extern void dgesv( int* n, int* nrhs, double* a, int* lda, int* ipiv,
double* b, int* ldb, int* info );
/* Main program */
int main() {
/* Locals */
int n = 10000, info;
/* Local arrays */
/* Initialization */
double *a = malloc(n*n*sizeof(double));
double *b = malloc(n*n*sizeof(double));
int *ipiv = malloc(n*sizeof(int));
for (int i = 0; i < n*n; i++ )
a[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
for(int i=0;i<n*n;i++)
b[i] = ((double) rand()) / ((double) RAND_MAX) - 0.5;
/* Solve the equations A*X = B */
dgesv( &n, &n, a, &n, ipiv, b, &n, &info );
exit( 0 );
} /* End of DGESV Example */

compiled on a Mac mini M1 with the command
Code Block
clang -o dgesv_ex dgesv_ex.c -framework accelerate

uses only one core of the processor (as also shown by the activity monitor)
Code Block
me@macmini-M1 ~ % time ./dgesv_ex
./dgesv_ex 35,54s user 0,27s system 100% cpu 35,758 total

I checked that the binary is of the right type:
Code Block
me@macmini-M1 ~ % lipo -info dgesv
Non-fat file: dgesv is architecture: arm64

As a comparaison, on my Intel MacBook Pro I get the following output :
Code Block
me@macbook-intel ˜ % time ./dgesv_ex
./dgesv_ex 142.69s user 0,51s system 718% cpu 19.925 total

Is it a known problem ? Maybe a compilation flag or else ?
Post not yet marked as solved Up vote post of mottelet Down vote post of mottelet


This is expected (and not a problem!). For sufficiently large matrices on Apple Silicon, linear algebra is performed using the AMX engine, which can be driven by a single core, allowing the other cores to do other work.

Ok, then, prove it with some piece of code...