Merge pull request #2827 from SChernykh/dev

GhostRider: set correct priority for helper threads
This commit is contained in:
xmrig 2021-12-20 18:07:23 +07:00 committed by GitHub
commit 5747ccfafc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View file

@ -100,7 +100,7 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
} }
# ifdef XMRIG_ALGO_GHOSTRIDER # ifdef XMRIG_ALGO_GHOSTRIDER
m_ghHelper = ghostrider::create_helper_thread(affinity(), data.affinities); m_ghHelper = ghostrider::create_helper_thread(affinity(), data.priority, data.affinities);
# endif # endif
} }

View file

@ -166,7 +166,7 @@ static struct AlgoTune
struct HelperThread struct HelperThread
{ {
HelperThread(hwloc_bitmap_t cpu_set, bool is8MB) : m_cpuSet(cpu_set), m_is8MB(is8MB) HelperThread(hwloc_bitmap_t cpu_set, int priority, bool is8MB) : m_cpuSet(cpu_set), m_priority(priority), m_is8MB(is8MB)
{ {
uv_mutex_init(&m_mutex); uv_mutex_init(&m_mutex);
uv_cond_init(&m_cond); uv_cond_init(&m_cond);
@ -241,6 +241,8 @@ struct HelperThread
} }
} }
Platform::setThreadPriority(m_priority);
uv_mutex_lock(&m_mutex); uv_mutex_lock(&m_mutex);
m_ready = true; m_ready = true;
@ -268,6 +270,7 @@ struct HelperThread
volatile bool m_ready = false; volatile bool m_ready = false;
volatile bool m_finished = false; volatile bool m_finished = false;
hwloc_bitmap_t m_cpuSet = {}; hwloc_bitmap_t m_cpuSet = {};
int m_priority = -1;
bool m_is8MB = false; bool m_is8MB = false;
std::thread* m_thread = nullptr; std::thread* m_thread = nullptr;
@ -297,6 +300,7 @@ void benchmark()
} }
Platform::setThreadAffinity(thread_index1); Platform::setThreadAffinity(thread_index1);
Platform::setThreadPriority(3);
constexpr uint32_t N = 1U << 21; constexpr uint32_t N = 1U << 21;
@ -375,7 +379,7 @@ void benchmark()
hwloc_bitmap_t helper_set = hwloc_bitmap_alloc(); hwloc_bitmap_t helper_set = hwloc_bitmap_alloc();
hwloc_bitmap_set(helper_set, thread_index2); hwloc_bitmap_set(helper_set, thread_index2);
HelperThread* helper = new HelperThread(helper_set, false); HelperThread* helper = new HelperThread(helper_set, 3, false);
for (uint32_t algo = 0; algo < 6; ++algo) { for (uint32_t algo = 0; algo < 6; ++algo) {
for (uint64_t step : { 1, 2, 4}) { for (uint64_t step : { 1, 2, 4}) {
@ -465,7 +469,7 @@ static inline bool findByType(hwloc_obj_t obj, hwloc_obj_type_t type, func lambd
} }
HelperThread* create_helper_thread(int64_t cpu_index, const std::vector<int64_t>& affinities) HelperThread* create_helper_thread(int64_t cpu_index, int priority, const std::vector<int64_t>& affinities)
{ {
#ifndef XMRIG_ARM #ifndef XMRIG_ARM
hwloc_bitmap_t helper_cpu_set = hwloc_bitmap_alloc(); hwloc_bitmap_t helper_cpu_set = hwloc_bitmap_alloc();
@ -520,7 +524,7 @@ HelperThread* create_helper_thread(int64_t cpu_index, const std::vector<int64_t>
}); });
if (hwloc_bitmap_weight(helper_cpu_set) > 0) { if (hwloc_bitmap_weight(helper_cpu_set) > 0) {
return new HelperThread(helper_cpu_set, is8MB); return new HelperThread(helper_cpu_set, priority, is8MB);
} }
} }
} }
@ -761,7 +765,7 @@ void hash_octa(const uint8_t* data, size_t size, uint8_t* output, cryptonight_ct
void benchmark() {} void benchmark() {}
HelperThread* create_helper_thread(int64_t, const std::vector<int64_t>&) { return nullptr; } HelperThread* create_helper_thread(int64_t, int, const std::vector<int64_t>&) { return nullptr; }
void destroy_helper_thread(HelperThread*) {} void destroy_helper_thread(HelperThread*) {}

View file

@ -39,7 +39,7 @@ namespace ghostrider
struct HelperThread; struct HelperThread;
void benchmark(); void benchmark();
HelperThread* create_helper_thread(int64_t cpu_index, const std::vector<int64_t>& affinities); HelperThread* create_helper_thread(int64_t cpu_index, int priority, const std::vector<int64_t>& affinities);
void destroy_helper_thread(HelperThread* t); void destroy_helper_thread(HelperThread* t);
void hash_octa(const uint8_t* data, size_t size, uint8_t* output, cryptonight_ctx** ctx, HelperThread* helper, bool verbose = true); void hash_octa(const uint8_t* data, size_t size, uint8_t* output, cryptonight_ctx** ctx, HelperThread* helper, bool verbose = true);