Skip to content

Commit

Permalink
Arena: Add Methods & Properties (#269)
Browse files Browse the repository at this point in the history
Add some fundamental `Arena` methods and properties.
  • Loading branch information
ax3l authored Feb 27, 2024
1 parent 1ec75d6 commit db7c1de
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/Base/Arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,31 @@
void init_Arena(py::module &m) {
using namespace amrex;

py::class_< Arena >(m, "Arena");
py::class_< Arena >(m, "Arena")
.def_static("initialize", &Arena::Initialize)
.def_static("print_usage", &Arena::PrintUsage)
.def_static("print_usage_to_files", &Arena::PrintUsageToFiles,
py::arg("filename"), py::arg("message"))
.def_static("finalize", &Arena::Finalize)

// these two can be true at the same time
.def_property_readonly("is_device_accessible", &Arena::isDeviceAccessible)
.def_property_readonly("is_host_accessible", &Arena::isHostAccessible)

// the next three are mutually exclusive
.def_property_readonly("is_managed", &Arena::isManaged)
.def_property_readonly("is_device", &Arena::isDevice)
.def_property_readonly("is_pinned", &Arena::isPinned)

#ifdef AMREX_USE_GPU
.def_property_readonly("is_stream_ordered_arena", &Arena::isStreamOrderedArena)
#endif

.def("has_free_device_memory", &Arena::hasFreeDeviceMemory,
py::arg("sz"),
"Does the device have enough free memory for allocating this "
"much memory? For CPU builds, this always return true.")
;

m.def("The_Arena", &The_Arena, py::return_value_policy::reference)
.def("The_Async_Arena", &The_Async_Arena, py::return_value_policy::reference)
Expand Down

0 comments on commit db7c1de

Please sign in to comment.