multithreading - High performance computing pthread parameters - c++ -
i'm working on project need utilize multiple threads using pthread (c++). have question:
what best pthread parameter configuration setting when want high performance computing in thread without much other threads interrupting it?
currently i'm using this:
pthread_t thread; struct sched_param param; int sched = sched_fifo; memset(¶m, 0, sizeof(sched_param)); // set priority max value (sched_get_priority_max() returns value) param.sched_priority = sched_get_priority_max(); // create thread pthread_create(&thread, null, (void *) &hard_number_crunching, (void *) &structure_passed_to_thread); // set parameters thread pthread_setschedparam(&thread, sched, ¶m);
i switching "int sched" between sched_fifo , sched_rr, didn't help me much. possible forcefulness thread run longer on cpu @ moment?
if creating 1 thread per core, want set thread's affinity prevent roaming between cores. improves performance ensuring each thread remains close cached data. see:
int sched_setaffinity(pid_t pid,size_t cpusetsize,cpu_set_t *mask);
note: should not set affinity if creating more threads cores! cause kind of crazy things happen, deadlocks mention one.
c multithreading performance pthreads posix
No comments:
Post a Comment