dev
MITSUNARI Shigeo 6 years ago
parent e29218ac58
commit 67a1f0cfaf
  1. 16
      src/fp_generator.hpp
  2. 4
      test/fp_generator_test.cpp

@ -2903,24 +2903,24 @@ private:
struct FpGenerator {
static const size_t codeSize = 4096 * 8;
static const size_t pageSize = 4096;
uint8_t *mem_;
Code code_;
uint8_t *mem;
Code code;
FpGenerator()
: mem_((uint8_t*)cybozu::AlignedMalloc(codeSize, pageSize))
, code_(mem_, codeSize)
: mem((uint8_t*)cybozu::AlignedMalloc(codeSize, pageSize))
, code(mem, codeSize)
{
}
void init(Op& op)
{
code_.init(op);
if (!Xbyak::CodeArray::protect(mem_, codeSize, Xbyak::CodeArray::PROTECT_RE)) {
code.init(op);
if (!Xbyak::CodeArray::protect(mem, codeSize, Xbyak::CodeArray::PROTECT_RE)) {
throw cybozu::Exception("err protect read/exec");
}
}
~FpGenerator()
{
Xbyak::CodeArray::protect(mem_, codeSize, Xbyak::CodeArray::PROTECT_RW);
cybozu::AlignedFree(mem_);
Xbyak::CodeArray::protect(mem, codeSize, Xbyak::CodeArray::PROTECT_RW);
cybozu::AlignedFree(mem);
}
};

@ -152,7 +152,7 @@ void testMulI(const mcl::fp::FpGenerator& fg, int pn)
mpz_class my;
mcl::gmp::set(my, y);
mx *= my;
uint64_t d = fg.mulUnit_(z, x, y);
uint64_t d = fg.code.mulUnit_(z, x, y);
z[pn] = d;
mcl::gmp::setArray(my, z, pn + 1);
CYBOZU_TEST_EQUAL(mx, my);
@ -162,7 +162,7 @@ void testMulI(const mcl::fp::FpGenerator& fg, int pn)
uint64_t z[MAX_N + 1];
rg.read(x, pn);
uint64_t y = rg.get64();
CYBOZU_BENCH_C("mulUnit", 10000000, fg.mulUnit_, z, x, y);
CYBOZU_BENCH_C("mulUnit", 10000000, fg.code.mulUnit_, z, x, y);
}
}

Loading…
Cancel
Save