I have a complex program which should use all cores to perform complex math calculations.
I have a system with two Intel Xeon Platinum 8160. Each of them has 24 cores
so together I have 48 cores
and 96 threads
.
My program only uses 24 cores
and not all 48
. It works on the 24
of the first CPU or the 24
of the second one but not all together.
When I start a second instance of the program, then nothing changed only one CPU is used.
I attach some screenshots.
I extracted some code to a minimal working example, which checks how many threads are available. Only 48
are detected and not all 96 threads
.
#include <stdlib.h>
#include <stdio.h>
#include <winsock.h>
#include <math.h>
#include <process.h>
static void thread_start(void *thread) {
int i;
i = *(int*)thread;
for (;;) {
i = (int)sqrt(i++);
}
}
int main (int argc, char * argv[]) {
SYSTEM_INFO sysi;
int thread_max, i;
argc = argc;
argv = argv;
GetSystemInfo(&sysi);
thread_max = sysi.dwNumberOfProcessors;
printf("\n... thread_max=%d\n", thread_max);
printf("\n\n");
for (i = 0; i < thread_max *2; i++) {
_beginthread(thread_start, 0, &i);
}
for (;;) i = i;
// return EXIT_SUCCESS;
}
My Machine runs under Windows 10 64-bit Pro. What could be the problem?