diff --git a/src/1weso_test.cpp b/src/1weso_test.cpp index 48329ce2..51e8d36e 100644 --- a/src/1weso_test.cpp +++ b/src/1weso_test.cpp @@ -24,7 +24,6 @@ int main(int argc, char const* argv[]) try ? std::stoull(argv[1]) : 1000000; assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0 - init_gmp(); debug_mode = true; if(hasAVX2()) { diff --git a/src/2weso_test.cpp b/src/2weso_test.cpp index be9c12ab..f377843c 100644 --- a/src/2weso_test.cpp +++ b/src/2weso_test.cpp @@ -32,7 +32,6 @@ int main(int argc, char const* argv[]) try ? std::stoull(argv[1]) : 1000000; assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0 - init_gmp(); debug_mode = true; if(hasAVX2()) { diff --git a/src/alloc.hpp b/src/alloc.hpp deleted file mode 100644 index a53d9f0c..00000000 --- a/src/alloc.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef ALLOC_H -#define ALLOC_H - -#include // for posix_memalign - -inline void* mp_alloc_func(size_t new_bytes) -{ - new_bytes = ((new_bytes + 8) + 15) & ~15; -#if defined _MSC_VER - uint8_t* ret = static_cast(_aligned_malloc(new_bytes, 16)); -#else - void* ptr = nullptr; - if (::posix_memalign(&ptr, 16, new_bytes) != 0) return nullptr; - uint8_t* ret = static_cast(ptr); -#endif - return ret + 8; -} - -inline void mp_free_func(void* old_ptr, size_t) { - // if the old_ptr alignment is not to 16 bytes + 8 bytes offset, we did not - // allocate it. It's an in-place buffer and should not be freed - if ((std::uintptr_t(old_ptr) & 15) == 8) { -#if defined _MSC_VER - _aligned_free(static_cast(old_ptr) - 8); -#else - std::free(static_cast(old_ptr) - 8); -#endif - } - else if ((std::uintptr_t(old_ptr) & 63) != 0) { - // this is a bit mysterious. Our allocator only allocates buffers - // aligned to 16 bytes + 8 (i.e. the address always ends with 8) - // The only other kind of buffer there should be, are the in-place - // buffers that are members of the mpz class. Those are specifically - // made to be 64 byte aligned (the assumed cache line size). If we're - // asked to free such buffer, we just ignore it, since it wasn't - // heap allocated. however, this isn't aligned to 64 bytes, so it may - // be a default allocated buffer. It's not supposed to happen, but if it - // does, we better free it - std::free(old_ptr); - } -} - -inline void* mp_realloc_func(void* old_ptr, size_t old_size, size_t new_bytes) { - - void* ret = mp_alloc_func(new_bytes); - ::memcpy(ret, old_ptr, std::min(old_size, new_bytes)); - mp_free_func(old_ptr, old_size); - return ret; -} - -//must call this before calling any gmp functions -//(the mpz class constructor does not call any gmp functions) -inline void init_gmp() { - mp_set_memory_functions(mp_alloc_func, mp_realloc_func, mp_free_func); - allow_integer_constructor=true; //make sure the old gmp allocator isn't used -} - -#endif diff --git a/src/avx512_test.cpp b/src/avx512_test.cpp index 9fab0b29..be0cdd64 100644 --- a/src/avx512_test.cpp +++ b/src/avx512_test.cpp @@ -77,7 +77,6 @@ template void int main(int argc, char **argv) { assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0 - init_gmp(); set_rounding_mode(); enable_avx512_ifma=false; diff --git a/src/hw/emu_funcs.cpp b/src/hw/emu_funcs.cpp index 8f6cb0ca..a1945240 100644 --- a/src/hw/emu_funcs.cpp +++ b/src/hw/emu_funcs.cpp @@ -3,7 +3,6 @@ //#include "verifier.h" //#include "bit_manipulation.h" -//#include "alloc.hpp" //#include "double_utility.h" #include diff --git a/src/hw/hw_test.cpp b/src/hw/hw_test.cpp index 20df7694..605cee09 100644 --- a/src/hw/hw_test.cpp +++ b/src/hw/hw_test.cpp @@ -5,7 +5,6 @@ //#include //#include //#include -//#include "alloc.hpp" //#include "create_discriminant.h" //#include "libft4222.h" @@ -30,7 +29,6 @@ static const char *discrs[] = { void init_chia(void) { VdfBaseInit(); - //init_gmp(); //set_rounding_mode(); //fesetround(FE_TOWARDZERO); } diff --git a/src/integer_common.h b/src/integer_common.h index 4f015234..a19214cb 100644 --- a/src/integer_common.h +++ b/src/integer_common.h @@ -111,18 +111,14 @@ struct track_max_type { } }; track_max_type track_max; -//#define TRACK_MAX(data) track_max.add(#data " {" __func__ ":" "__LINE__" ")", (data).num_bits()) #define TRACK_MAX(data) track_max.add(__LINE__, #data, (data).num_bits(), (data)<0) -//typedef __mpz_struct mpz_t[1]; typedef __mpz_struct mpz_struct; int mpz_num_bits_upper_bound(mpz_struct* v) { return mpz_size(v)*sizeof(mp_limb_t)*8; } -static bool allow_integer_constructor=false; //don't want static integers because they use the wrong allocator - //16 bytes struct integer { mpz_struct impl[1]; @@ -132,7 +128,6 @@ struct integer { } inline integer() { - //assert(allow_integer_constructor); mpz_init(impl); } diff --git a/src/prover_test.cpp b/src/prover_test.cpp index 30d5e198..07578aa1 100644 --- a/src/prover_test.cpp +++ b/src/prover_test.cpp @@ -30,7 +30,6 @@ int gcd_128_max_iter=3; int main() { assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0 - init_gmp(); if(hasAVX2()) { gcd_base_bits=63; diff --git a/src/python_bindings/fastvdf.cpp b/src/python_bindings/fastvdf.cpp index 4a4e6780..e94302b3 100644 --- a/src/python_bindings/fastvdf.cpp +++ b/src/python_bindings/fastvdf.cpp @@ -1,7 +1,6 @@ #include #include "../verifier.h" #include "../prover_slow.h" -#include "../alloc.hpp" namespace py = pybind11; diff --git a/src/threading.h b/src/threading.h index 50d4b49a..d235c774 100644 --- a/src/threading.h +++ b/src/threading.h @@ -1,7 +1,6 @@ #ifndef THREADING_H #define THREADING_H -#include "alloc.hpp" #include //mp_limb_t is an unsigned integer diff --git a/src/vdf_base.cpp b/src/vdf_base.cpp index fd332c15..5c1eed0f 100644 --- a/src/vdf_base.cpp +++ b/src/vdf_base.cpp @@ -1,12 +1,10 @@ #include "verifier.h" #include "prover_slow.h" -#include "alloc.hpp" #include "prover_base.hpp" #include "prover_parallel.hpp" void VdfBaseInit(void) { - init_gmp(); fesetround(FE_TOWARDZERO); } diff --git a/src/vdf_bench.cpp b/src/vdf_bench.cpp index fdd121e0..3601a8e5 100644 --- a/src/vdf_bench.cpp +++ b/src/vdf_bench.cpp @@ -26,7 +26,6 @@ static void usage(const char *progname) int main(int argc, char **argv) { assert(is_vdf_test); //assertions should be disabled in VDF_MODE==0 - init_gmp(); set_rounding_mode(); if (argc < 3) { diff --git a/src/vdf_client.cpp b/src/vdf_client.cpp index f22badc6..55bddcf1 100644 --- a/src/vdf_client.cpp +++ b/src/vdf_client.cpp @@ -311,7 +311,6 @@ int gcd_base_bits = 50; int gcd_128_max_iter = 3; int main(int argc, char* argv[]) try { - init_gmp(); if (argc != 4) { std::cerr << "Usage: ./vdf_client \n"; return 1;