My question: how to make multi-threads use 100% CPU (at least 80%), say let 4 threads use 4 cores to 100%?
The whole story: I wrote some posix multi-threads code. When run it on a multi-core (up to 16) cluster server, although the wall time decrease with using more cores, the overall computation time ( the sum of time spent on the part of code ~without~ any synchronization ). I guess it is because some cores did not dedicate to running my thread. My guess is confirmed when run the code on my laptop.
I tried to assign affinity with pthread_setaffinity_np and to set priority pthread_attr_setschedpolicy(&attributes_, SCHED_FIFO); pthread_attr_setschedparam(&attributes_, &p);
which doesn't help.