Skip to content

Commit

Permalink
Remove trailing whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Mar 25, 2022
1 parent 964a96f commit 70e2683
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 50 deletions.
10 changes: 5 additions & 5 deletions src/Reducer.h
Expand Up @@ -45,25 +45,25 @@ unsigned int lzcnt64_hard(unsigned long long x) WEAK;
namespace {
const int_fast64_t THRESH{1ul << 31};
const int_fast64_t EXP_THRESH{31};
}
}

/**
* @brief The Reducer class that does custom reduce operation for VDF
* @brief The Reducer class that does custom reduce operation for VDF
* repeated squaring algorithm. The implementation is based on
* Akashnil VDF competition entry and further optimized for speed.
*/
class alignas(64) Reducer {
public:
/**
* @brief Reducer - constructs by using reference into cg context.
*/
*/
Reducer(ClassGroupContext &ctx_) : ctx(ctx_) {}

~Reducer() {}

/**
* @brief run - runs reduction algorithm for cg context params
*/
*/
inline void run() {
while (!isReduced()) {
int_fast64_t a, b, c;
Expand Down Expand Up @@ -140,7 +140,7 @@ bool bLZCHasHW=false;
bLZCHasHW=has_lzcnt_hard();
bLZCChecked=true;
}

int_fast64_t lg2;

if(bLZCHasHW)
Expand Down
4 changes: 2 additions & 2 deletions src/asm_gcd_unsigned.h
Expand Up @@ -470,8 +470,8 @@ void gcd_unsigned(
#else
for (int end_index=0;end_index<int_size;++end_index) {
int size=end_index+1;
int mapped_size=size;

int mapped_size=size;
while (mapped_size==0 || mapped_size%4!=0) {
++mapped_size;
}
Expand Down
4 changes: 2 additions & 2 deletions src/callback.h
Expand Up @@ -89,7 +89,7 @@ class OneWesolowskiCallback: public WesolowskiCallback {

void OnIteration(int type, void *data, uint64_t iteration) {
iteration++;
if (iteration > wanted_iter)
if (iteration > wanted_iter)
return ;

if (iteration % kl == 0) {
Expand Down Expand Up @@ -189,7 +189,7 @@ class FastAlgorithmCallback : public WesolowskiCallback {
return &(forms[pos]);
}

// We need to store:
// We need to store:
// 2^16 * k + 10 * l
// 2^(18 + 2*m) * k + 12 * 2^(2*m) * l
void OnIteration(int type, void *data, uint64_t iteration) {
Expand Down
2 changes: 1 addition & 1 deletion src/compile_asm.cpp
Expand Up @@ -44,7 +44,7 @@ int main(int argc, char** argv) {
set_rounding_mode();

string filename="asm_compiled.s";

bool compile_avx512=false;

if((argc==2)&&(strcmp(argv[1],"avx2")==0))
Expand Down
6 changes: 3 additions & 3 deletions src/fast_storage.h
@@ -1,5 +1,5 @@

// If 'FAST_MACHINE' is set to 1, the machine needs to have a high number
// If 'FAST_MACHINE' is set to 1, the machine needs to have a high number
// of CPUs. This will optimize the runtime,
// by not storing any intermediate values in main VDF worker loop.
// Other threads will come back and redo the work, this
Expand Down Expand Up @@ -80,7 +80,7 @@ class FastStorage {
}
}
nudupl_form(y, y, D, L);
reducer.reduce(y);
reducer.reduce(y);
}
AddIntermediates(iter_begin);
}
Expand All @@ -99,7 +99,7 @@ class FastStorage {
intermediates_iter += (1 << 16);
}
return intermediates_iter;
}
}

void CalculateIntermediatesThread() {
while (!stopped) {
Expand Down
2 changes: 1 addition & 1 deletion src/integer_common.h
Expand Up @@ -244,7 +244,7 @@ struct integer {
string to_string_dec() const {
string res_string;
res_string.resize(mpz_sizeinbase(impl, 10));

mpz_get_str(&(res_string[0]), 10, impl);

return res_string.c_str();
Expand Down
18 changes: 9 additions & 9 deletions src/nucomp.h
Expand Up @@ -3,22 +3,22 @@

/**
Copyright (C) 2012 William Hart
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
MIT licensing permission obtained January 13, 2020 by Chia Network Inc. from William Hart
Copyright 2020 Chia Network Inc
Expand Down Expand Up @@ -89,11 +89,11 @@ void qfb_nucomp(qfb_t r, const qfb_t f, const qfb_t g, mpz_t& D, mpz_t& L)

mpz_mul(k, m, v1);
mpz_fdiv_r(k, k, a1);

if (mpz_cmp_ui(sp, 1))
{
mpz_gcdext(s, v2, u2, ss, sp);

/* k = k*u2 - v2*c2 */
mpz_mul(k, k, u2);
mpz_mul(t, v2, c2);
Expand Down Expand Up @@ -163,7 +163,7 @@ void qfb_nucomp(qfb_t r, const qfb_t f, const qfb_t g, mpz_t& D, mpz_t& L)
mpz_sub(cb, cb, g->b);
mpz_mul_2exp(temp, ca, 1);
mpz_fdiv_r(cb, cb, temp);

/* cc = (cb*cb - D) / (4*ca) */
mpz_mul(cc, cb, cb);
mpz_sub(cc, cc, D);
Expand Down
8 changes: 4 additions & 4 deletions src/prover_slow.h
Expand Up @@ -28,10 +28,10 @@ uint64_t GetBlock(uint64_t i, uint64_t k, uint64_t T, integer& B) {
return res_vector[0];
}

form GenerateWesolowski(form &y, form &x_init,
integer &D, PulmarkReducer& reducer,
form GenerateWesolowski(form &y, form &x_init,
integer &D, PulmarkReducer& reducer,
std::vector<form>& intermediates,
uint64_t num_iterations,
uint64_t num_iterations,
uint64_t k, uint64_t l) {
integer B = GetB(D, x_init, y);
integer L=root(-D, 4);
Expand Down Expand Up @@ -95,7 +95,7 @@ std::vector<uint8_t> ProveSlow(integer& D, form& x, uint64_t num_iterations) {
}
nudupl_form(y, y, D, L);
reducer.reduce(y);
}
}
form proof = GenerateWesolowski(y, x, D, reducer, intermediates, num_iterations, k, l);
std::vector<uint8_t> result = SerializeForm(y, d_bits);
std::vector<uint8_t> proof_bytes = SerializeForm(proof, d_bits);
Expand Down
4 changes: 2 additions & 2 deletions src/util.h
Expand Up @@ -46,7 +46,7 @@ struct Segment {
is_empty = true;
}

Segment(uint64_t start, uint64_t length, form& x, form& y) {
Segment(uint64_t start, uint64_t length, form& x, form& y) {
this->start = start;
this->length = length;
this->x = x;
Expand All @@ -62,7 +62,7 @@ struct Segment {
}
if (length > other.length)
return true;
if (length < other.length)
if (length < other.length)
return false;
return start > other.start;
}
Expand Down
12 changes: 6 additions & 6 deletions src/vdf.h
Expand Up @@ -451,7 +451,7 @@ class ProverManager {
while (!valid_proof && !stopped) {
std::unique_lock<std::mutex> lk(proof_mutex);
proof_cv.wait(lk, [this, iteration] {
if (max_proving_iteration >= iteration - iteration % (1 << 16))
if (max_proving_iteration >= iteration - iteration % (1 << 16))
return true;
return stopped.load();
});
Expand Down Expand Up @@ -562,16 +562,16 @@ class ProverManager {
if (provers[i].first->IsFinished()) {
provers[i].second.proof = provers[i].first->GetProof();
if (debug_mode) {
std::cout << "Done segment: [" << provers[i].second.start
<< ", " << provers[i].second.start + provers[i].second.length
std::cout << "Done segment: [" << provers[i].second.start
<< ", " << provers[i].second.start + provers[i].second.length
<< "]. Bucket: " << provers[i].second.GetSegmentBucket() << ".\n";
}
if (provers[i].second.length == (1 << 16)) {
new_small_segment = true;
}
int index = provers[i].second.GetSegmentBucket();
int position = provers[i].second.start / provers[i].second.length;
while (done_segments[index].size() <= position)
while (done_segments[index].size() <= position)
done_segments[index].emplace_back(Segment());
done_segments[index][position] = provers[i].second;
if (provers[i].first->IsFullyFinished()) {
Expand All @@ -588,7 +588,7 @@ class ProverManager {
expected_proving_iters = done_segments[0][done_segments[0].size() - 1].start +
done_segments[0][done_segments[0].size() - 1].length;
}

if (pending_iters.size() > 0)
best_pending_iter = *pending_iters.begin();
if (pending_iters.size() > 0 && expected_proving_iters >= best_pending_iter - best_pending_iter % (1 << 16)) {
Expand Down Expand Up @@ -689,7 +689,7 @@ class ProverManager {
// Otherwise, pause one already running segment, if candidate is better.
Segment worst_running;
int worst_index;
for (int i = 0; i < provers.size(); i++)
for (int i = 0; i < provers.size(); i++)
if (provers[i].first->IsRunning()) {
if (worst_running.is_empty == true || provers[i].second.IsWorseThan(worst_running)) {
worst_running = provers[i].second;
Expand Down
2 changes: 1 addition & 1 deletion src/vdf_new.h
Expand Up @@ -131,7 +131,7 @@ struct form {
static form generator(const integer& d) {
return from_abd(integer(2), integer(1), d);
}

void reduce() {
::reduce(a, b, c);
}
Expand Down
4 changes: 2 additions & 2 deletions src/vdf_original.h
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
class vdf_original
{
public:

struct form {
// y = ax^2 + bxy + y^2
mpz_t a;
Expand Down Expand Up @@ -321,6 +321,6 @@ class vdf_original

~vdf_original() {
mpz_clears(negative_a, r, denom, old_a, old_b, ra, s, x, g, d, e, q, w, m,
u, a, b, k, mu, v, sigma, lambda, f3.a, f3.b, f3.c, NULL); //,);
u, a, b, k, mu, v, sigma, lambda, f3.a, f3.b, f3.c, NULL); //,);
}
};
24 changes: 12 additions & 12 deletions src/xgcd_partial.c
Expand Up @@ -2,9 +2,9 @@
Copyright (C) 2012 William Hart
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
Expand All @@ -16,7 +16,7 @@
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
MIT licensing permission obtained January 13, 2020 by Chia Network Inc. from William Hart
*/

Expand All @@ -33,17 +33,17 @@ void mpz_xgcd_partial(mpz_t co2, mpz_t co1,
mp_limb_signed_t bits, bits1, bits2;

mpz_init(q); mpz_init(r);

mpz_set_ui(co2, 0);
mpz_set_si(co1, -1);

while (mpz_cmp_ui(r1, 0) && mpz_cmp(r1, L) > 0)
{
bits2 = mpz_sizeinbase(r2, 2);
bits1 = mpz_sizeinbase(r1, 2);
bits = __GMP_MAX(bits2, bits1) - GMP_LIMB_BITS + 1;
if (bits < 0) bits = 0;

mpz_tdiv_q_2exp(r, r2, bits);
rr2 = mpz_get_ui(r);
mpz_tdiv_q_2exp(r, r1, bits);
Expand All @@ -58,14 +58,14 @@ void mpz_xgcd_partial(mpz_t co2, mpz_t co1,
{
qq = rr2 / rr1;

t1 = rr2 - qq*rr1;
t2 = aa2 - qq*aa1;
t3 = bb2 - qq*bb1;
t1 = rr2 - qq*rr1;
t2 = aa2 - qq*aa1;
t3 = bb2 - qq*bb1;

if (i & 1)
{
if (t1 < -t3 || rr1 - t1 < t2 - aa1) break;
} else
} else
{
if (t1 < -t2 || rr1 - t1 < t3 - bb1) break;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ void mpz_xgcd_partial(mpz_t co2, mpz_t co1,
}

if (mpz_sgn(r2) < 0)
{
{
mpz_neg(co2, co2); mpz_neg(co1, co1);
mpz_neg(r2, r2);
}
Expand Down

0 comments on commit 70e2683

Please sign in to comment.