I tried using --cpu-affinity=0x3 in another computer (laptop) without setting affinity externally. Results are similarly problematic:
********** cpuminer-opt 3.9.2 ***********
A CPU miner with multi algo support and optimized for CPUs
with AES_NI and AVX2 and SHA extensions.
BTC donation address: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT
CPU: Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz.
SW built on Jun 3 2019 with GCC 7.3.0.
CPU features: SSE2 AES SSE4.2 AVX AVX2.
SW features: SSE2 AES SSE4.2 AVX AVX2.
Algo features: SSE2.
Start mining with SSE2.
[2019-06-04 14:17:20] 4 CPU cores available, 2 miner threads selected.
[2019-06-04 14:17:20] Binding process to cpu mask a5fce0
****** [2019-06-04 14:17:20] affine_to_cpu_mask for 4294967295 returned 57 ********
[2019-06-04 14:17:20] 2 miner threads started, using 'yespower' algorithm.
[2019-06-04 14:17:20] Starting Stratum on stratum+tcp://******
[2019-06-04 14:17:20] Binding thread 0 to cpu mask 32cfbe0
[2019-06-04 14:17:20] Binding thread 1 to cpu mask 34cfbe0
[2019-06-04 14:17:20] Stratum session id: 725103584be7a27346f921881f5ac7d8
[2019-06-04 14:17:20] Stratum difficulty set to 1
This "Binding process to cpu mask a5fce0" seems to occur in every machine, no matter how many CPUs it's got: it's always a5fce0.
Also, a quick look at the process affinity in Task Manager and I see all 4 CPUs affined, instead of just the first 2.
I was wondering about that when I saw it but hadn't followed up (too much multitasking).
I think I found the problem, it's day 1. The argument to SetThreadAffinityMask is supposed to be DWORD_PTR,
not a DWORD, so "&affinity_mask" instead of "affinity_mask". It supports 64 CPU by casting the pointer as DWORD64_ptr.
It's all clear now. Thanks for your persistence.