SWDEV-280773 - Honor CPU affinity with env var
Setting AMD_CPU_AFFINITY = 1 will make runtime honor core affinity that
the process may set. This is disabled by default as it can prevent
worker thread or any thread that runtime creates from getting scheduled
thus affecting performance.
Change-Id: Ibe4cc95e7b99caee5ce750b7bf66e09e999cc9a3
[ROCm/clr commit: 1398719b0d]
这个提交包含在:
@@ -23,6 +23,7 @@
|
||||
#include "os/os.hpp"
|
||||
#include "thread/thread.hpp"
|
||||
#include "utils/util.hpp"
|
||||
#include "utils/flags.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdarg.h>
|
||||
@@ -368,14 +369,16 @@ const void* Os::createOsThread(amd::Thread* thread) {
|
||||
|
||||
// We never plan the use join, so free the resources now.
|
||||
::pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHED);
|
||||
cpu_set_t cpuset;
|
||||
if (processorCount_ > 0) {
|
||||
CPU_ZERO(&cpuset);
|
||||
for (int i = 0; i < processorCount_; i++) {
|
||||
CPU_SET(i, &cpuset);
|
||||
}
|
||||
if (0 != pthread_attr_setaffinity_np(&threadAttr, sizeof(cpu_set_t), &cpuset)) {
|
||||
fatal("pthread_attr_setaffinity_np failed to set affinity");
|
||||
if (!AMD_CPU_AFFINITY) {
|
||||
cpu_set_t cpuset;
|
||||
if (processorCount_ > 0) {
|
||||
CPU_ZERO(&cpuset);
|
||||
for (int i = 0; i < processorCount_; i++) {
|
||||
CPU_SET(i, &cpuset);
|
||||
}
|
||||
if (0 != pthread_attr_setaffinity_np(&threadAttr, sizeof(cpu_set_t), &cpuset)) {
|
||||
fatal("pthread_attr_setaffinity_np failed to set affinity");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -233,8 +233,6 @@ release(uint, HIP_HIDDEN_FREE_MEM, 0, \
|
||||
"0 = Disable") \
|
||||
release(size_t, GPU_FORCE_BLIT_COPY_SIZE, 0, \
|
||||
"Size in KB of the threshold below which to force blit instead for sdma") \
|
||||
release(bool, ROC_BARRIER_SYNC, true, \
|
||||
"Enable AQL barrier packet for synchronization") \
|
||||
release(bool, ROC_ACTIVE_WAIT, false, \
|
||||
"Forces unconditional active wait for GPU") \
|
||||
release(bool, ROC_ENABLE_LARGE_BAR, true, \
|
||||
@@ -254,10 +252,12 @@ release(bool, PAL_EMBED_KERNEL_MD, false, \
|
||||
release(cstring, ROC_GLOBAL_CU_MASK, "", \
|
||||
"Sets a global CU mask (entered as hex value) for all queues," \
|
||||
"Each active bit represents using one CU (e.g., 0xf enables only 4 CUs)") \
|
||||
release(cstring, AMD_LOG_LEVEL_FILE, "", \
|
||||
"Set output file for AMD_LOG_LEVEL, Default is stderr") \
|
||||
release(size_t, PAL_PREPINNED_MEMORY_SIZE, 64, \
|
||||
"Size in KBytes of prepinned memory")
|
||||
release(cstring, AMD_LOG_LEVEL_FILE, "", \
|
||||
"Set output file for AMD_LOG_LEVEL, Default is stderr") \
|
||||
release(size_t, PAL_PREPINNED_MEMORY_SIZE, 64, \
|
||||
"Size in KBytes of prepinned memory") \
|
||||
release(bool, AMD_CPU_AFFINITY, false, \
|
||||
"Reset CPU affinity of any runtime threads")
|
||||
|
||||
namespace amd {
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户