Skip to content

Commit

Permalink
Merge pull request #792 from wildmeshing/mtao/cleanup_old_pragmas
Browse files Browse the repository at this point in the history
Pruning old library options
  • Loading branch information
mtao authored Aug 18, 2024
2 parents 61cbb4d + 32e7437 commit 0bca191
Show file tree
Hide file tree
Showing 76 changed files with 95 additions and 2,083 deletions.
20 changes: 0 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,10 @@ target_compile_definitions(wildmeshing_toolkit PUBLIC WMTK_MAX_ATTRIBUTE_DIMENSI



option(WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE "Use monotonic allocator to store the cache buffer" OFF)
if(WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE)
target_compile_definitions(wildmeshing_toolkit PRIVATE WMTK_USE_MONOTONIC_ATTRIBUTE_CACHE)
endif()


option(WMTK_ENABLE_GENERIC_CHECKPOINTS "Enable checkpoint selection" OFF)
if(WMTK_ENABLE_GENERIC_CHECKPOINTS)
target_compile_definitions(wildmeshing_toolkit PRIVATE WMTK_ENABLE_GENERIC_CHECKPOINTS)
endif()
option(WMTK_ENABLE_MAP_CACHE "Enable checkpoint selection" ON)
if(WMTK_ENABLE_MAP_CACHE)
target_compile_definitions(wildmeshing_toolkit PUBLIC WMTK_ENABLE_MAP_CACHE)
endif()

option(WMTK_ENABLE_TRANSACTION_STACK "Enable transaction stack" ON)
if(WMTK_ENABLE_TRANSACTION_STACK)
target_compile_definitions(wildmeshing_toolkit PUBLIC WMTK_ENABLE_TRANSACTION_STACK)
endif()

option(WMTK_ENABLE_HASH_UPDATE "Enable hash update" OFF)
if(WMTK_ENABLE_HASH_UPDATE)
target_compile_definitions(wildmeshing_toolkit PUBLIC WMTK_ENABLE_HASH_UPDATE)
endif()


target_link_libraries(wildmeshing_toolkit PRIVATE wmtk::warnings)
Expand Down
37 changes: 1 addition & 36 deletions src/wmtk/EdgeMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ Tuple EdgeMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const
1 - tuple.m_local_vid,
tuple.m_local_eid,
tuple.m_local_fid,
tuple.m_global_cid,
tuple.m_hash);
tuple.m_global_cid);
case PrimitiveType::Edge: {
const int64_t gvid = id(tuple, PrimitiveType::Vertex);

Expand Down Expand Up @@ -77,18 +76,7 @@ Tuple EdgeMesh::switch_tuple(const Tuple& tuple, PrimitiveType type) const
assert(lvid_new != -1);


#if defined(WMTK_ENABLE_HASH_UPDATE)
const attribute::Accessor<int64_t> hash_accessor = get_const_cell_hash_accessor();
const Tuple res(
lvid_new,
tuple.m_local_eid,
tuple.m_local_fid,
gcid_new,
get_cell_hash(gcid_new, hash_accessor));
#else
const Tuple res(lvid_new, tuple.m_local_eid, tuple.m_local_fid, gcid_new);

#endif
assert(is_valid(res));
return res;
}
Expand Down Expand Up @@ -187,11 +175,7 @@ Tuple EdgeMesh::vertex_tuple_from_id(int64_t id) const
auto ev = ev_accessor.index_access().const_vector_attribute<2>(e);
for (int64_t i = 0; i < 2; ++i) {
if (ev(i) == id) {
#if defined(WMTK_ENABLE_HASH_UPDATE)
Tuple v_tuple = Tuple(i, -1, -1, e, get_cell_hash_slow(e));
#else
Tuple v_tuple = Tuple(i, -1, -1, e);
#endif
return v_tuple;
}
}
Expand All @@ -202,11 +186,7 @@ Tuple EdgeMesh::vertex_tuple_from_id(int64_t id) const

Tuple EdgeMesh::edge_tuple_from_id(int64_t id) const
{
#if defined(WMTK_ENABLE_HASH_UPDATE)
Tuple e_tuple = Tuple(0, -1, -1, id, get_cell_hash_slow(id));
#else
Tuple e_tuple = Tuple(0, -1, -1, id);
#endif

assert(is_valid(e_tuple));
return e_tuple;
Expand All @@ -226,16 +206,7 @@ Tuple EdgeMesh::tuple_from_global_ids(int64_t eid, int64_t vid) const
}
assert(lvid != -1);

#if defined(WMTK_ENABLE_HASH_UPDATE)
return Tuple(
lvid,
-1,
-1,
eid,
get_cell_hash_slow(eid)); // TODO replace by function that takes hash accessor as parameter
#else
return Tuple(lvid, -1, -1, eid);
#endif
}


Expand Down Expand Up @@ -302,13 +273,7 @@ std::vector<std::vector<TypedAttributeHandle<int64_t>>> EdgeMesh::connectivity_a
std::vector<Tuple> EdgeMesh::orient_vertices(const Tuple& tuple) const
{
int64_t cid = tuple.m_global_cid;
#if defined(WMTK_ENABLE_HASH_UPDATE)
auto hash = get_cell_hash_slow(cid);

return {Tuple(0, -1, -1, cid, hash), Tuple(1, -1, -1, cid, hash)};
#else
return {Tuple(0, -1, -1, cid), Tuple(1, -1, -1, cid)};
#endif
}


Expand Down
23 changes: 0 additions & 23 deletions src/wmtk/EdgeMeshOperationExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,13 @@

namespace wmtk {
// constructor
#if defined(WMTK_ENABLE_HASH_UPDATE)
EdgeMesh::EdgeMeshOperationExecutor::EdgeMeshOperationExecutor(
EdgeMesh& m,
const Tuple& operating_tuple,
attribute::Accessor<int64_t>& hash_acc)
#else
EdgeMesh::EdgeMeshOperationExecutor::EdgeMeshOperationExecutor(
EdgeMesh& m,
const Tuple& operating_tuple)
#endif
: flag_accessors{{m.get_flag_accessor(PrimitiveType::Vertex), m.get_flag_accessor(PrimitiveType::Edge)}}
, ee_accessor(m.create_accessor<int64_t>(m.m_ee_handle))
, ev_accessor(m.create_accessor<int64_t>(m.m_ev_handle))
, ve_accessor(m.create_accessor<int64_t>(m.m_ve_handle))
#if defined(WMTK_ENABLE_HASH_UPDATE)
, hash_accessor(hash_acc)
#endif
, m_mesh(m)
{
m_operating_tuple = operating_tuple;
Expand All @@ -30,20 +20,11 @@ EdgeMesh::EdgeMeshOperationExecutor::EdgeMeshOperationExecutor(
m_spine_vids[1] = m_mesh.id_vertex(operating_tuple_switch_vertex);

// update hash on neighborhood
#if defined(WMTK_ENABLE_HASH_UPDATE)
cell_ids_to_update_hash.emplace_back(m_mesh.id_edge(m_operating_tuple));
#endif
if (!m_mesh.is_boundary_vertex(m_operating_tuple)) {
m_neighbor_eids[0] = m_mesh.id_edge(m_mesh.switch_edge(m_operating_tuple));
#if defined(WMTK_ENABLE_HASH_UPDATE)
cell_ids_to_update_hash.emplace_back(m_neighbor_eids[0]);
#endif
}
if (!m_mesh.is_boundary_vertex(operating_tuple_switch_vertex)) {
m_neighbor_eids[1] = m_mesh.id_edge(m_mesh.switch_edge(operating_tuple_switch_vertex));
#if defined(WMTK_ENABLE_HASH_UPDATE)
cell_ids_to_update_hash.emplace_back(m_neighbor_eids[1]);
#endif
}


Expand All @@ -63,10 +44,6 @@ void EdgeMesh::EdgeMeshOperationExecutor::delete_simplices()

void EdgeMesh::EdgeMeshOperationExecutor::update_cell_hash()
{
#if defined(WMTK_ENABLE_HASH_UPDATE)

m_mesh.update_cell_hashes(cell_ids_to_update_hash, hash_accessor);
#endif
}

const std::array<std::vector<int64_t>, 2>
Expand Down
10 changes: 0 additions & 10 deletions src/wmtk/EdgeMeshOperationExecutor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,16 @@ namespace wmtk {
class EdgeMesh::EdgeMeshOperationExecutor : public operations::edge_mesh::EdgeOperationData
{
public:
#if defined(WMTK_ENABLE_HASH_UPDATE)
EdgeMeshOperationExecutor(
EdgeMesh& m,
const Tuple& operating_tuple,
attribute::Accessor<int64_t>& hash_acc);
#else
EdgeMeshOperationExecutor(
EdgeMesh& m,
const Tuple& operating_tuple);
#endif
void delete_simplices();
void update_cell_hash();

std::array<attribute::Accessor<char>, 2> flag_accessors;
attribute::Accessor<int64_t,EdgeMesh> ee_accessor;
attribute::Accessor<int64_t,EdgeMesh> ev_accessor;
attribute::Accessor<int64_t,EdgeMesh> ve_accessor;
#if defined(WMTK_ENABLE_HASH_UPDATE)
attribute::Accessor<int64_t>& hash_accessor;
#endif

/**
* @brief gather all simplices that are deleted in a split
Expand Down
137 changes: 0 additions & 137 deletions src/wmtk/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,48 +61,6 @@ bool Mesh::is_boundary(const simplex::Simplex& s) const
}


#if defined(WMTK_ENABLE_HASH_UPDATE)
bool Mesh::is_hash_valid(const Tuple& tuple, const attribute::Accessor<int64_t>& hash_accessor)
const
{
const int64_t cid = tuple.m_global_cid;

const int64_t desired_hash = get_cell_hash(cid, hash_accessor);
if (tuple.m_hash != desired_hash) {
// logger().debug("Hash is not valid: {} != {}", tuple.m_hash, desired_hash);
return false;
}
return true;
}

bool Mesh::is_hash_valid(const Tuple& tuple) const
{
auto ha = get_const_cell_hash_accessor();
return is_hash_valid(tuple, ha);
}


bool Mesh::is_valid_with_hash(const Tuple& tuple) const
{
auto ha = get_const_cell_hash_accessor();
return is_valid_with_hash(tuple, ha);
}
bool Mesh::is_valid_with_hash(const Tuple& tuple, const attribute::Accessor<int64_t>& hash_accessor)
const
{
if (!is_valid(tuple)) {
return false;
}
if (!is_hash_valid(tuple, hash_accessor)) {
return false;
}
// #else
// const auto& flag_accessor = get_const_flag_accessor(top_simplex_type());
// return flag_accessor.index_access().const_scalar_attribute(tuple.m_global_cid) & 0x1;
// #endif
return true;
}
#endif

bool Mesh::is_valid(const Tuple& tuple) const
{
Expand Down Expand Up @@ -154,95 +112,8 @@ attribute::Accessor<char> Mesh::get_flag_accessor(PrimitiveType type)
return create_accessor(m_flag_handles.at(get_primitive_type_id(type)));
}

#if defined(WMTK_ENABLE_HASH_UPDATE)
const attribute::Accessor<int64_t> Mesh::get_const_cell_hash_accessor() const
{
return create_const_accessor(m_cell_hash_handle);
}

const attribute::Accessor<int64_t> Mesh::get_cell_hash_accessor() const
{
return get_const_cell_hash_accessor();
}
attribute::Accessor<int64_t> Mesh::get_cell_hash_accessor()
{
return create_accessor(m_cell_hash_handle);
}

void Mesh::update_cell_hash(const Tuple& cell, attribute::Accessor<int64_t>& hash_accessor)
{
const int64_t cid = cell.m_global_cid;
update_cell_hash(cid, hash_accessor);
}
void Mesh::update_cell_hash(const int64_t cid, attribute::Accessor<int64_t>& hash_accessor)
{
auto& h = hash_accessor.index_access().scalar_attribute(cid);
h = (h + 1) % (1 << 6);
}

void Mesh::update_cell_hashes(
const std::vector<Tuple>& cells,
attribute::Accessor<int64_t>& hash_accessor)
{
for (const Tuple& t : cells) {
update_cell_hash(t, hash_accessor);
}
}
void Mesh::update_cell_hashes(
const std::vector<int64_t>& cells,
attribute::Accessor<int64_t>& hash_accessor)
{
for (const int64_t t : cells) {
update_cell_hash(t, hash_accessor);
}
}

void Mesh::update_cell_hashes_slow(const std::vector<Tuple>& cells)
{
attribute::Accessor<int64_t> hash_accessor = get_cell_hash_accessor();
update_cell_hashes(cells, hash_accessor);
}
#endif


#if defined(WMTK_ENABLE_HASH_UPDATE)
Tuple Mesh::resurrect_tuple(const Tuple& tuple, const attribute::Accessor<int64_t>& hash_accessor)
const
{
#if defined(WMTK_ENABLE_HASH_UPDATE)

Tuple t = tuple;
t.m_hash = get_cell_hash(tuple.m_global_cid, hash_accessor);
return t;
#else
return tuple;
#endif
}

Tuple Mesh::resurrect_tuple_slow(const Tuple& tuple) const
{
#if defined(WMTK_ENABLE_HASH_UPDATE)
attribute::Accessor<int64_t> hash_accessor = get_cell_hash_accessor();
return resurrect_tuple(tuple, hash_accessor);
#else
return tuple;
#endif
}
#endif

#if defined(WMTK_ENABLE_HASH_UPDATE)
int64_t Mesh::get_cell_hash(int64_t cell_index, const attribute::Accessor<int64_t>& hash_accessor)
const
{
return hash_accessor.index_access().const_scalar_attribute(cell_index);
}

int64_t Mesh::get_cell_hash_slow(int64_t cell_index) const
{
const attribute::Accessor<int64_t> hash_accessor = get_cell_hash_accessor();
return get_cell_hash(cell_index, hash_accessor);
}
#endif

void Mesh::set_capacities_from_flags()
{
Expand Down Expand Up @@ -289,14 +160,6 @@ Tuple Mesh::switch_tuples_unsafe(
}


#if defined(WMTK_ENABLE_HASH_UPDATE)
void Mesh::update_vertex_operation_hashes(
const Tuple& vertex,
attribute::Accessor<int64_t>& hash_accessor)
{
MultiMeshManager::update_vertex_operation_hashes_internal(*this, vertex, hash_accessor);
}
#endif

void Mesh::assert_capacity_valid() const
{
Expand Down
Loading

0 comments on commit 0bca191

Please sign in to comment.