diff --git a/projects/clr/rocclr/os/os_posix.cpp b/projects/clr/rocclr/os/os_posix.cpp index 075b3182ba..ce9b5bdb44 100644 --- a/projects/clr/rocclr/os/os_posix.cpp +++ b/projects/clr/rocclr/os/os_posix.cpp @@ -23,6 +23,7 @@ #include "os/os.hpp" #include "thread/thread.hpp" #include "utils/util.hpp" +#include "utils/flags.hpp" #include #include @@ -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"); + } } } diff --git a/projects/clr/rocclr/utils/flags.hpp b/projects/clr/rocclr/utils/flags.hpp index 3fb639f7f3..50c0b23f55 100644 --- a/projects/clr/rocclr/utils/flags.hpp +++ b/projects/clr/rocclr/utils/flags.hpp @@ -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 {