How to make full use of Intel Xeon E5-2680 Multi Core CPU

I’m testing the performance on CPU because I want to run my model on my Web Server.
The Server has two E5-2680 CPU, each CPU has 14 cores and support 28 threads.

I use the following script to test it’s performance, but when I increase the cores it can use, the speed seems not to be faster.

By increasing the core numbers form 1 to 56, at first, it becomes faster when given more cores and each core has a utilization around 100%, but when given more cores (about more than 8 cores), cores’ utilization dorps so the speed won’t go up.

Is it because of the bandwidth bottleneck between the CPU and the memory?

Testing script:

import torch
import cProfile
import pstats
import io

pr = cProfile.Profile()

x = torch.rand(5000, 5000)
y = torch.rand(5000, 5000)
z = torch.rand(5000, 5000)
for _ in range(10):
    z = torch.addmm(z, x, y)

s = io.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)

Time spent VS Core Numbers:

Command Time
taskset -c 0 python 32.635
taskset -c 0-1 python 26.074
taskset -c 0-2 python 13.610
taskset -c 0-4 python 8.057
taskset -c 0-6 python 6.664
taskset -c 0-8 python 5.731
taskset -c 0-10 python 6.340
taskset -c 0-12 python 5.357
taskset -c 0-14 python 4.993
taskset -c 0-16 python 4.842
taskset -c 0-32 python 3.908
taskset -c 0-55 python 3.630

Some of the CPU Info

$ cat /proc/cpuinfo
processor    : 0
vendor_id    : GenuineIntel
cpu family    : 6
model        : 79
model name    : Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz
stepping    : 1
microcode    : 0xb000017
cpu MHz        : 2899.968
cache size    : 35840 KB
physical id    : 0
siblings    : 28
core id        : 0
cpu cores    : 14
apicid        : 0
initial apicid    : 0
fpu        : yes
fpu_exception    : yes
cpuid level    : 20
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdseed adx smap xsaveopt cqm_llc cqm_occup_llc
bogomips    : 4800.37
clflush size    : 64
cache_alignment    : 64
address sizes    : 46 bits physical, 48 bits virtual
power management: