Previous | Next --- Slide 22 of 47
Back to Lecture Thumbnails
wanze

If we want to decide which mapping strategy use, does that mean it require us to manually assign work to threads (instead of using dynamical assignment like in for example "launch" in ISPC)?

itoen

@wanze I think that would be OS-specific. I remember from CS 110 on the prime factorization farm we would use sched_set_affinity to assign processes to run on different cores, and the man page suggests that it works similarly for threads. If we wanted to use a specific mapping strategy we would manually call these functions.

https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html

nanoxh

How do we explicitly tell the OS to place threads on the same processor? Does std::thread support this functionality?

cmchiang

@nanoxh I don't think std::thread implement this functionality, but just as @itoen said, you can use OS specific functions (such as sched_setaffinity) to hint the OS to put the thread on a specific core.

Please log in to leave a comment.