Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose C++ obj pointers to Python API #158

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bindings/python/context_shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <cstdint>
#include <pybind11/pybind11.h>

#include <context_shim.hpp>
Expand Down Expand Up @@ -51,6 +52,8 @@ register_context(pybind11::module& m)
.def(
"size", [](const context_shim& c) { return c.m.size(); },
"number of ranks within the communicator");

m.def("expose_cpp_ptr", [](context_shim* obj){return reinterpret_cast<std::uintptr_t>(&obj->m);});
}

} // namespace pyghex
3 changes: 3 additions & 0 deletions bindings/python/unstructured/communication_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <cstdint>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

Expand Down Expand Up @@ -90,6 +91,8 @@ register_communication_object(pybind11::module& m)
return type{c.m};
},
pybind11::keep_alive<0, 1>());

m.def("expose_cpp_ptr", [](type* obj){return reinterpret_cast<std::uintptr_t>(obj);});
});
}

Expand Down
3 changes: 3 additions & 0 deletions bindings/python/unstructured/domain_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <cstdint>
#include <vector>

#include <pybind11/pybind11.h>
Expand Down Expand Up @@ -53,6 +54,8 @@ register_domain_descriptor(pybind11::module& m)
"Returns the indices")
.def_property_readonly_static("__cpp_type__",
[type_name](const pybind11::object&) { return type_name; });

m.def("expose_cpp_ptr", [](type* obj){return reinterpret_cast<std::uintptr_t>(obj);});
});
}

Expand Down
3 changes: 3 additions & 0 deletions bindings/python/unstructured/pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <cstdint>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

Expand Down Expand Up @@ -68,6 +69,8 @@ register_pattern(pybind11::module& m)
cls.def("__call__", &pattern_container::template operator()<field>,
pybind11::keep_alive<0, 2>());
});

m.def("expose_cpp_ptr", [](pattern_container* obj){return reinterpret_cast<std::uintptr_t>(obj);});
});
}

Expand Down
3 changes: 3 additions & 0 deletions include/ghex/unstructured/user_concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ class data_descriptor<ghex::cpu, DomainId, Idx, T>
assert(!(outer_stride) || (outer_stride >= (levels_first ? m_levels : m_domain_size)));
}

/** @brief empty constructor*/
data_descriptor(){}

// member functions

device_id_type device_id() const noexcept { return arch_traits<arch_type>::default_id(); }
Expand Down
Loading