Yes, I'm starting to think its the OS. Pthread support for SMP boxes is relatively new, their first SMP kernel was around 2004 IIRC. The threads were all running on the same processor until I changed the PTHREAD_CONCURRENCY environment variable as described. I looked at the pthread_attr before, but there was nothing about thread-to-CPU matching.bob wrote:What kernel is that based on. Not Linux if I recall? If so, that is the problem. BSD/solaris threads are not particularly efficient. And you might have to use pthread_attr() to make sure that logical threads and physical processes are matched up... Solaris doesn't do that by default, but NetBSD I don't know about.
BTW I can run your code on our 8-core box to test if you want...
It would be pretty cool to run it on 8 CPUs, though with my luck it will crash quickly. The easiest way would be to get both the threads and processes versions through CVS:
cvs -z3 -d:pserver:anonymous@zct.cvs.sourceforge.net:/cvsroot/zct co -P zct
cvs -z3 -d:pserver:anonymous@zct.cvs.sourceforge.net:/cvsroot/zct co -r zct0_3_2472_threads -P zct
Then for each, modify line 47 to have 8 for MAX_CPUS. Then run a "make release" for each, and type "bench" after starting them.
Now, as ZCT's SMP support is still incomplete, the idle time will probably be pretty big. It's usually around 10% for 4 cpus with processes, and 20-30% with threads. It also hangs occasionally, but it should get through a benchmark just fine.