Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/chia/phase1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ uint64_t compute_matches( int R_index, int num_threads,
}
}, "phase1/slice");

L_sort->read(&read_thread, std::max(num_threads / 2, 2));
L_sort->read(&read_thread, std::max(num_threads / 2, 2), std::max(num_threads / g_read_thread_divider, 2));

read_thread.close();
match_pool.close();
Expand Down
2 changes: 1 addition & 1 deletion include/chia/phase2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void compute_table( int R_index, int num_threads,
bitfield* L_used,
const bitfield* R_used)
{
const int num_threads_read = std::max(num_threads / 4, 2);
const int num_threads_read = std::max(num_threads / g_read_thread_divider, 1);

DiskTable<T> R_input(R_table);
{
Expand Down
15 changes: 8 additions & 7 deletions include/chia/phase3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ void compute_stage1(int L_index, int num_threads,
DiskTable<S>* R_table = nullptr)
{
const auto begin = get_wall_time_micros();
const int num_threads_merge = std::max(num_threads / 4, 1);
const int num_threads_read = std::max(num_threads / g_read_thread_divider, 2);
const int num_threads_merge = std::max(num_threads / 8, 1);

struct merge_buffer_t {
uint64_t offset = 0; // position offset at buffer[0]
Expand Down Expand Up @@ -164,11 +165,11 @@ void compute_stage1(int L_index, int num_threads,
}, &R_add_2, num_threads_merge, "phase3/merge");

std::thread R_sort_read(
[&mutex, &signal_1, num_threads, L_table, R_sort, R_table, &R_read, &R_is_end]() {
[&mutex, &signal_1, num_threads, num_threads_read, L_table, R_sort, R_table, &R_read, &R_is_end]() {
if(R_table) {
R_table->read(&R_read, std::max(num_threads / 4, 2));
R_table->read(&R_read, std::max(num_threads_read / 2, 1));
} else {
R_sort->read(&R_read, std::max(num_threads / (L_table ? 1 : 2), 1));
R_sort->read(&R_read, std::max(num_threads / (L_table ? 1 : 2), 1), std::max(num_threads_read / 2, 1));
}
R_read.close();
{
Expand All @@ -179,10 +180,10 @@ void compute_stage1(int L_index, int num_threads,
});

if(L_table) {
L_table->read(&L_read_1, std::max(num_threads / 4, 2));
L_table->read(&L_read_1, std::max(num_threads_read / 2, 1));
L_read_1.close();
} else {
L_sort->read(&L_read, std::max(num_threads / (R_table ? 1 : 2), 1));
L_sort->read(&L_read, std::max(num_threads / (R_table ? 1 : 2), 1), std::max(num_threads_read / 2, 1));
}
L_read.close();
{
Expand Down Expand Up @@ -439,7 +440,7 @@ uint64_t compute_stage2(int L_index, int num_threads,
L_add.take(input);
}, "phase3/slice");

R_sort->read(&R_read, num_threads);
R_sort->read(&R_read, num_threads, std::max(num_threads / g_read_thread_divider, 2));
R_read.close();

// Since we don't have a perfect multiple of EPP entries, this writes the last ones
Expand Down
2 changes: 1 addition & 1 deletion include/chia/phase4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ uint64_t compute( FILE* plot_file, const int header_size,
p7_threads.take(parks);
}, "phase4/read");

L_sort_7->read(&read_thread, num_threads);
L_sort_7->read(&read_thread, num_threads, std::max(num_threads / g_read_thread_divider, 2));
read_thread.close();

park_data.offset = final_file_writer_3;
Expand Down
6 changes: 6 additions & 0 deletions include/chia/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ extern size_t g_read_chunk_size;
*/
extern size_t g_write_chunk_size;

/*
* Divider for number of read threads.
* default = 4
*/
extern int g_read_thread_divider;

namespace phase2 {
extern int g_thread_multi;
}
Expand Down
1 change: 1 addition & 0 deletions src/chia_plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ int main(int argc, char** argv)
"f, farmerkey", "Farmer Public Key (48 bytes)", cxxopts::value<std::string>(farmer_key_str))(
"G, tmptoggle", "Alternate tmpdir/tmpdir2", cxxopts::value<bool>(tmptoggle))(
"K, rmulti2", "Thread multiplier for P2 (default = 1)", cxxopts::value<int>(phase2::g_thread_multi))(
"R, rtdiv", "Number of read threads divider (default = 4)", cxxopts::value<int>(g_read_thread_divider))(
"help", "Print help");

if(argc <= 1) {
Expand Down
2 changes: 2 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
size_t g_read_chunk_size = 65536;
size_t g_write_chunk_size = 4096;

int g_read_thread_divider = 4;

namespace phase2 {
int g_thread_multi = 1;
}