Skip to content

Commit

Permalink
Changed mm_prof_opt enum labels to lowercase mm_*
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlaine committed Nov 13, 2020
1 parent 3105225 commit f6eaec6
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 34 deletions.
4 changes: 2 additions & 2 deletions native/src/seal/c/memorymanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ SEAL_C_FUNC MemoryManager_GetPool1(int prof_opt, bool clear_on_destruction, void
mm_prof_opt profile_opt = static_cast<mm_prof_opt>(prof_opt);
MemoryPoolHandle handle;

// clear_on_destruction is only used when using FORCE_NEW
if (profile_opt == mm_prof_opt::FORCE_NEW)
// clear_on_destruction is only used when using mm_force_new
if (profile_opt == mm_prof_opt::mm_force_new)
{
handle = MemoryManager::GetPool(profile_opt, clear_on_destruction);
}
Expand Down
2 changes: 1 addition & 1 deletion native/src/seal/decryptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace seal
void dot_product_ct_sk_array(const Ciphertext &encrypted, util::RNSIter destination, MemoryPoolHandle pool);

// We use a fresh memory pool with `clear_on_destruction' enabled.
MemoryPoolHandle pool_ = MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true);
MemoryPoolHandle pool_ = MemoryManager::GetPool(mm_prof_opt::mm_force_new, true);

SEALContext context_;

Expand Down
2 changes: 1 addition & 1 deletion native/src/seal/keygenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ namespace seal
GaloisKeys create_galois_keys(const std::vector<std::uint32_t> &galois_elts, bool save_seed);

// We use a fresh memory pool with `clear_on_destruction' enabled.
MemoryPoolHandle pool_ = MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true);
MemoryPoolHandle pool_ = MemoryManager::GetPool(mm_prof_opt::mm_force_new, true);

SEALContext context_;

Expand Down
24 changes: 12 additions & 12 deletions native/src/seal/memorymanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ namespace seal
*/
enum mm_prof_opt : mm_prof_opt_t
{
DEFAULT = 0x0,
FORCE_GLOBAL = 0x1,
FORCE_NEW = 0x2,
FORCE_THREAD_LOCAL = 0x4
mm_default = 0x0,
mm_force_global = 0x1,
mm_force_new = 0x2,
mm_force_thread_local = 0x4
};

/**
Expand Down Expand Up @@ -471,12 +471,12 @@ namespace seal
profile and prof_opt. The following values for prof_opt have an effect
independent of the current profile:
mm_prof_opt::FORCE_NEW: return MemoryPoolHandle::New()
mm_prof_opt::FORCE_GLOBAL: return MemoryPoolHandle::Global()
mm_prof_opt::FORCE_THREAD_LOCAL: return MemoryPoolHandle::ThreadLocal()
mm_prof_opt::force_new: return MemoryPoolHandle::New()
mm_prof_opt::force_global: return MemoryPoolHandle::Global()
mm_prof_opt::force_thread_local: return MemoryPoolHandle::ThreadLocal()
Other values for prof_opt are forwarded to the current profile and, depending
on the profile, may or may not have an effect. The value mm_prof_opt::DEFAULT
on the profile, may or may not have an effect. The value mm_prof_opt::default
will always invoke a default behavior for the current profile.
@param[in] prof_opt A mm_prof_opt_t parameter used to provide additional
Expand All @@ -487,13 +487,13 @@ namespace seal
{
switch (prof_opt)
{
case mm_prof_opt::FORCE_GLOBAL:
case mm_prof_opt::mm_force_global:
return MemoryPoolHandle::Global();

case mm_prof_opt::FORCE_NEW:
case mm_prof_opt::mm_force_new:
return MemoryPoolHandle::New(std::forward<Args>(args)...);
#ifndef _M_CEE
case mm_prof_opt::FORCE_THREAD_LOCAL:
case mm_prof_opt::mm_force_thread_local:
return MemoryPoolHandle::ThreadLocal();
#endif
default:
Expand All @@ -513,7 +513,7 @@ namespace seal

SEAL_NODISCARD static inline MemoryPoolHandle GetPool()
{
return GetPool(mm_prof_opt::DEFAULT);
return GetPool(mm_prof_opt::mm_default);
}

private:
Expand Down
5 changes: 3 additions & 2 deletions native/src/seal/randomgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,14 @@ namespace seal
UniformRandomGenerator(prng_seed_type seed)
: seed_([&seed]() {
// Create a new seed allocation
DynArray<std::uint64_t> new_seed(seed.size(), MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true));
DynArray<std::uint64_t> new_seed(
seed.size(), MemoryManager::GetPool(mm_prof_opt::mm_force_new, true));

// Assign the given seed and return
std::copy(seed.cbegin(), seed.cend(), new_seed.begin());
return new_seed;
}()),
buffer_(buffer_size_, MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true)),
buffer_(buffer_size_, MemoryManager::GetPool(mm_prof_opt::mm_force_new, true)),
buffer_begin_(buffer_.begin()), buffer_end_(buffer_.end()), buffer_head_(buffer_.end())
{}

Expand Down
8 changes: 4 additions & 4 deletions native/src/seal/secretkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace seal
*/
SecretKey &operator=(const SecretKey &assign)
{
Plaintext new_sk(MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true));
Plaintext new_sk(MemoryManager::GetPool(mm_prof_opt::mm_force_new, true));
new_sk = assign.sk_;
std::swap(sk_, new_sk);
return *this;
Expand Down Expand Up @@ -155,7 +155,7 @@ namespace seal
using namespace std::placeholders;

// We use a fresh memory pool with `clear_on_destruction' enabled.
Plaintext new_sk(MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true));
Plaintext new_sk(MemoryManager::GetPool(mm_prof_opt::mm_force_new, true));
auto in_size = Serialization::Load(
std::bind(&Plaintext::load_members, &new_sk, std::move(context), _1, _2), stream,
/* clear_on_destruction */ true);
Expand Down Expand Up @@ -229,7 +229,7 @@ namespace seal
using namespace std::placeholders;

// We use a fresh memory pool with `clear_on_destruction' enabled.
Plaintext new_sk(MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true));
Plaintext new_sk(MemoryManager::GetPool(mm_prof_opt::mm_force_new, true));
auto in_size =
Serialization::Load(std::bind(&Plaintext::load_members, &new_sk, std::move(context), _1, _2), in, size);
std::swap(sk_, new_sk);
Expand Down Expand Up @@ -293,6 +293,6 @@ namespace seal

private:
// We use a fresh memory pool with `clear_on_destruction' enabled.
Plaintext sk_{ MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true) };
Plaintext sk_{ MemoryManager::GetPool(mm_prof_opt::mm_force_new, true) };
};
} // namespace seal
8 changes: 4 additions & 4 deletions native/src/seal/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ namespace seal
temp_stream.exceptions(ios_base::badbit | ios_base::failbit);
save_members(temp_stream);

auto safe_pool(MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true));
auto safe_pool(MemoryManager::GetPool(mm_prof_opt::mm_force_new, true));

// Create temporary aliasing DynArray to wrap safe_buffer
DynArray<seal_byte> safe_buffer_array(
Expand All @@ -301,7 +301,7 @@ namespace seal
temp_stream.exceptions(ios_base::badbit | ios_base::failbit);
save_members(temp_stream);

auto safe_pool(MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, clear_on_destruction));
auto safe_pool(MemoryManager::GetPool(mm_prof_opt::mm_force_new, clear_on_destruction));

// Create temporary aliasing DynArray to wrap safe_buffer
DynArray<seal_byte> safe_buffer_array(
Expand Down Expand Up @@ -398,7 +398,7 @@ namespace seal
// Throw an exception on non-zero return value
if (ztools::zlib_inflate_stream(
stream, safe_cast<streamoff>(compr_size), temp_stream,
MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, clear_on_destruction)))
MemoryManager::GetPool(mm_prof_opt::mm_force_new, clear_on_destruction)))
{
throw logic_error("stream decompression failed");
}
Expand All @@ -421,7 +421,7 @@ namespace seal
// Throw an exception on non-zero return value
if (ztools::zstd_inflate_stream(
stream, safe_cast<streamoff>(compr_size), temp_stream,
MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, clear_on_destruction)))
MemoryManager::GetPool(mm_prof_opt::mm_force_new, clear_on_destruction)))
{
throw logic_error("stream decompression failed");
}
Expand Down
4 changes: 2 additions & 2 deletions native/src/seal/util/rlwe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace seal
}
#endif
// We use a fresh memory pool with `clear_on_destruction' enabled
MemoryPoolHandle pool = MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true);
MemoryPoolHandle pool = MemoryManager::GetPool(mm_prof_opt::mm_force_new, true);

auto &context_data = *context.get_context_data(parms_id);
auto &parms = context_data.parms();
Expand Down Expand Up @@ -242,7 +242,7 @@ namespace seal
}
#endif
// We use a fresh memory pool with `clear_on_destruction' enabled.
MemoryPoolHandle pool = MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, true);
MemoryPoolHandle pool = MemoryManager::GetPool(mm_prof_opt::mm_force_new, true);

auto &context_data = *context.get_context_data(parms_id);
auto &parms = context_data.parms();
Expand Down
2 changes: 1 addition & 1 deletion native/src/seal/util/streambuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ namespace seal
return count;
}

DynArray<char> buf_{ MemoryManager::GetPool(mm_prof_opt::FORCE_NEW, clear_on_destruction_) };
DynArray<char> buf_{ MemoryManager::GetPool(mm_prof_opt::mm_force_new, clear_on_destruction_) };

std::streamsize size_;

Expand Down
4 changes: 2 additions & 2 deletions native/tests/seal/dynarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ namespace sealtest

TEST(DynArrayTest, Assign)
{
DynArray<char> arr(MemoryManager::GetPool(mm_prof_opt::FORCE_NEW));
DynArray<char> arr2(MemoryManager::GetPool(mm_prof_opt::FORCE_NEW));
DynArray<char> arr(MemoryManager::GetPool(mm_prof_opt::mm_force_new));
DynArray<char> arr2(MemoryManager::GetPool(mm_prof_opt::mm_force_new));
ASSERT_NE(&static_cast<util::MemoryPool &>(arr.pool()), &static_cast<util::MemoryPool &>(arr2.pool()));

arr = arr2;
Expand Down
6 changes: 3 additions & 3 deletions native/tests/seal/util/rns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace sealtest

TEST(RNSBaseTest, Copy)
{
auto pool = MemoryManager::GetPool(mm_prof_opt::FORCE_NEW);
auto pool = MemoryManager::GetPool(mm_prof_opt::mm_force_new);
RNSBase base({ 3, 4 }, pool);
ASSERT_EQ(2l, pool.use_count());
{
Expand Down Expand Up @@ -133,7 +133,7 @@ namespace sealtest

TEST(RNSBaseTest, Extend)
{
auto pool = MemoryManager::GetPool(mm_prof_opt::FORCE_NEW);
auto pool = MemoryManager::GetPool(mm_prof_opt::mm_force_new);
RNSBase base({ 3 }, pool);
ASSERT_EQ(2l, pool.use_count());

Expand Down Expand Up @@ -170,7 +170,7 @@ namespace sealtest

TEST(RNSBaseTest, Drop)
{
auto pool = MemoryManager::GetPool(mm_prof_opt::FORCE_NEW);
auto pool = MemoryManager::GetPool(mm_prof_opt::mm_force_new);
RNSBase base({ 3, 5, 7, 11 }, pool);
ASSERT_EQ(2l, pool.use_count());

Expand Down

0 comments on commit f6eaec6

Please sign in to comment.