MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / set_thread_affinity

Function set_thread_affinity

src/runtime/CPP/CPPScheduler.cpp:99–112  ·  view source on GitHub ↗

Set thread affinity. Pin current thread to a particular core * * @param[in] core_id ID of the core to which the current thread is pinned */

Source from the content-addressed store, hash-verified

97 * @param[in] core_id ID of the core to which the current thread is pinned
98 */
99void set_thread_affinity(int core_id)
100{
101 if (core_id < 0)
102 {
103 return;
104 }
105
106#if !defined(_WIN64) && !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__QNX__)
107 cpu_set_t set;
108 CPU_ZERO(&set);
109 CPU_SET(core_id, &set);
110 ARM_COMPUTE_EXIT_ON_MSG(sched_setaffinity(0, sizeof(set), &set), "Error setting thread affinity");
111#endif /* !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__QNX__) */
112}
113
114/** There are currently 2 scheduling modes supported by CPPScheduler
115 *

Callers 2

worker_threadMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected