Skip to content

Commit

Permalink
Merge pull request #962 from madMAx43v3r/final-output
Browse files Browse the repository at this point in the history
Option to create plot directly in finaldir
  • Loading branch information
madMAx43v3r committed Oct 21, 2021
2 parents f2b8199 + 144ae6d commit 0cf1586
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Usage:
-c, --contract arg Pool Contract Address (62 chars)
-f, --farmerkey arg Farmer Public Key (48 bytes)
-G, --tmptoggle Alternate tmpdir/tmpdir2 (default = false)
-D, --directout Create plot directly in finaldir (default = false)
-K, --rmulti2 arg Thread multiplier for P2 (default = 1)
--help Print help
```
Expand Down
5 changes: 3 additions & 2 deletions include/chia/phase3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,16 @@ void compute( phase2::output_t& input, output_t& out,
const int num_threads, const int log_num_buckets,
const std::string plot_name,
const std::string tmp_dir,
const std::string tmp_dir_2)
const std::string tmp_dir_2,
const std::string plot_dir)
{
const auto total_begin = get_wall_time_micros();

const int k = input.params.k;
const std::string prefix_2 = tmp_dir_2 + plot_name + ".";

out.params = input.params;
out.plot_file_name = tmp_dir + plot_name + ".plot.tmp";
out.plot_file_name = plot_dir + plot_name + ".plot.tmp";

FILE* plot_file = fopen(out.plot_file_name.c_str(), "wb");
if(!plot_file) {
Expand Down
5 changes: 3 additions & 2 deletions include/chia/phase4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ void compute( const phase3::output_t& input, output_t& out,
const int num_threads, const int log_num_buckets,
const std::string plot_name,
const std::string tmp_dir,
const std::string tmp_dir_2)
const std::string tmp_dir_2,
const std::string plot_dir)
{
const auto total_begin = get_wall_time_micros();

Expand All @@ -260,7 +261,7 @@ void compute( const phase3::output_t& input, output_t& out,
fclose(plot_file);

out.params = input.params;
out.plot_file_name = tmp_dir + plot_name + ".plot";
out.plot_file_name = plot_dir + plot_name + ".plot";

std::rename(input.plot_file_name.c_str(), out.plot_file_name.c_str());

Expand Down
25 changes: 15 additions & 10 deletions src/chia_plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ phase4::output_t create_plot( const int k,
const vector<uint8_t>& puzzle_hash_bytes,
const vector<uint8_t>& farmer_key_bytes,
const std::string& tmp_dir,
const std::string& tmp_dir_2)
const std::string& tmp_dir_2,
const std::string& plot_dir)
{
const auto total_begin = get_wall_time_micros();
const bool have_puzzle = !puzzle_hash_bytes.empty();
Expand Down Expand Up @@ -192,10 +193,10 @@ phase4::output_t create_plot( const int k,
phase2::compute(out_1, out_2, num_threads, log_num_buckets_3, plot_name, tmp_dir, tmp_dir_2);

phase3::output_t out_3;
phase3::compute(out_2, out_3, num_threads, log_num_buckets_3, plot_name, tmp_dir, tmp_dir_2);
phase3::compute(out_2, out_3, num_threads, log_num_buckets_3, plot_name, tmp_dir, tmp_dir_2, plot_dir);

phase4::output_t out_4;
phase4::compute(out_3, out_4, num_threads, log_num_buckets_3, plot_name, tmp_dir, tmp_dir_2);
phase4::compute(out_3, out_4, num_threads, log_num_buckets_3, plot_name, tmp_dir, tmp_dir_2, plot_dir);

const auto time_secs = (get_wall_time_micros() - total_begin) / 1e6;
std::cout << "Total plot creation time was "
Expand Down Expand Up @@ -237,6 +238,7 @@ int main(int argc, char** argv)
int num_buckets_3 = 0;
bool waitforcopy = false;
bool tmptoggle = false;
bool directout = false;

options.allow_unrecognised_options().add_options()(
"k, size", "K size (default = 32, k <= 32)", cxxopts::value<int>(k))(
Expand All @@ -252,7 +254,8 @@ int main(int argc, char** argv)
"p, poolkey", "Pool Public Key (48 bytes)", cxxopts::value<std::string>(pool_key_str))(
"c, contract", "Pool Contract Address (62 chars)", cxxopts::value<std::string>(contract_addr_str))(
"f, farmerkey", "Farmer Public Key (48 bytes)", cxxopts::value<std::string>(farmer_key_str))(
"G, tmptoggle", "Alternate tmpdir/tmpdir2", cxxopts::value<bool>(tmptoggle))(
"G, tmptoggle", "Alternate tmpdir/tmpdir2 (default = false)", cxxopts::value<bool>(tmptoggle))(
"D, directout", "Create plot directly in finaldir (default = false)", cxxopts::value<bool>(directout))(
"K, rmulti2", "Thread multiplier for P2 (default = 1)", cxxopts::value<int>(phase2::g_thread_multi))(
"version", "Print version")(
"help", "Print help");
Expand Down Expand Up @@ -489,15 +492,17 @@ int main(int argc, char** argv)
<< " (" << get_date_string_ex("%Y/%m/%d %H:%M:%S") << ")" << std::endl;
const auto out = create_plot(
k, port, num_threads, log_num_buckets, log_num_buckets_3,
pool_key, puzzle_hash, farmer_key, tmp_dir, tmp_dir2);
pool_key, puzzle_hash, farmer_key, tmp_dir, tmp_dir2, directout ? final_dir : tmp_dir);

if(final_dir != tmp_dir)
{
const auto dst_path = final_dir + out.params.plot_name + ".plot";
std::cout << "Started copy to " << dst_path << std::endl;
copy_thread.take_copy(std::make_pair(out.plot_file_name, dst_path));
if(waitforcopy) {
copy_thread.wait();
if(!directout) {
const auto dst_path = final_dir + out.params.plot_name + ".plot";
std::cout << "Started copy to " << dst_path << std::endl;
copy_thread.take_copy(std::make_pair(out.plot_file_name, dst_path));
if(waitforcopy) {
copy_thread.wait();
}
}
}
else if(tmptoggle) {
Expand Down

0 comments on commit 0cf1586

Please sign in to comment.