Browse Source

Merge pull request #2827 from SChernykh/dev

GhostRider: set correct priority for helper threads
pull/2830/head
xmrig 3 years ago
committed by GitHub
parent
commit
5747ccfafc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/backend/cpu/CpuWorker.cpp
  2. 14
      src/crypto/ghostrider/ghostrider.cpp
  3. 2
      src/crypto/ghostrider/ghostrider.h

2
src/backend/cpu/CpuWorker.cpp

@ -100,7 +100,7 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
}
# 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
}

14
src/crypto/ghostrider/ghostrider.cpp

@ -166,7 +166,7 @@ static struct AlgoTune
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_cond_init(&m_cond);
@ -241,6 +241,8 @@ struct HelperThread
}
}
Platform::setThreadPriority(m_priority);
uv_mutex_lock(&m_mutex);
m_ready = true;
@ -268,6 +270,7 @@ struct HelperThread
volatile bool m_ready = false;
volatile bool m_finished = false;
hwloc_bitmap_t m_cpuSet = {};
int m_priority = -1;
bool m_is8MB = false;
std::thread* m_thread = nullptr;
@ -297,6 +300,7 @@ void benchmark()
}
Platform::setThreadAffinity(thread_index1);
Platform::setThreadPriority(3);
constexpr uint32_t N = 1U << 21;
@ -375,7 +379,7 @@ void benchmark()
hwloc_bitmap_t helper_set = hwloc_bitmap_alloc();
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 (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
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) {
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() {}
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*) {}

2
src/crypto/ghostrider/ghostrider.h

@ -39,7 +39,7 @@ namespace ghostrider
struct HelperThread;
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 hash_octa(const uint8_t* data, size_t size, uint8_t* output, cryptonight_ctx** ctx, HelperThread* helper, bool verbose = true);

Loading…
Cancel
Save