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

Memory allocation #1

Merged
merged 4 commits into from
Nov 9, 2022
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ To install the build-time dependencies run the following installation commands f
### Debian/Ubuntu

``` bash
sudo apt-get update && sudo apt-get install -y libboost-dev swig autoconf libtool
sudo apt-get update && sudo apt-get install -y libboost-dev libmpfr-dev libgmp-dev swig autoconf libtool
```

## Build and install
Expand Down
14 changes: 11 additions & 3 deletions src/_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,14 @@ PYBIND11_MODULE(_ext, m) {
auto bufparid = parid.request();
int *ptrid = (int *)bufparid.ptr;

auto eventoffsets = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {len}, {sizeof(int)}));
auto eventoffsets = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {len+1}, {sizeof(int)}));
auto bufeventoffsets = eventoffsets.request();
int *ptreventoffsets = (int *)bufeventoffsets.ptr;
size_t eventidx = 0;

ptreventoffsets[eventidx] = 0;
eventidx++;

auto jetoffsets = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {jk}, {sizeof(int)}));
auto bufjetoffsets = jetoffsets.request();
int *ptrjetoffsets = (int *)bufjetoffsets.ptr;
Expand Down Expand Up @@ -315,11 +318,14 @@ PYBIND11_MODULE(_ext, m) {
auto bufparid = parid.request();
int *ptrid = (int *)bufparid.ptr;

auto eventoffsets = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {len}, {sizeof(int)}));
auto eventoffsets = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {len+1}, {sizeof(int)}));
auto bufeventoffsets = eventoffsets.request();
int *ptreventoffsets = (int *)bufeventoffsets.ptr;
size_t eventidx = 0;

ptreventoffsets[eventidx] = 0;
eventidx++;

auto jetoffsets = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {jk}, {sizeof(int)}));
auto bufjetoffsets = jetoffsets.request();
int *ptrjetoffsets = (int *)bufjetoffsets.ptr;
Expand Down Expand Up @@ -1477,10 +1483,12 @@ PYBIND11_MODULE(_ext, m) {
auto parid = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {jk}, {sizeof(int)}));
auto bufparid = parid.request();
int *ptrid = (int *)bufparid.ptr;
auto eventoffsets = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {len}, {sizeof(int)}));
auto eventoffsets = py::array(py::buffer_info(nullptr, sizeof(int), py::format_descriptor<int>::value, 1, {len+1}, {sizeof(int)}));
auto bufeventoffsets = eventoffsets.request();
int *ptreventoffsets = (int *)bufeventoffsets.ptr;
size_t eventidx = 0;
ptreventoffsets[eventidx] = 0;
eventidx++;
size_t idxh = 0;
auto eventprev = 0;
for (unsigned int i = 0; i < css.size(); i++){
Expand Down
10 changes: 5 additions & 5 deletions src/fastjet/_generalevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def constituents(self, min_pt):
self._input_flag = 0
for i in range(len(self._clusterable_level)):
np_results = self._results[i].to_numpy_with_constituents(min_pt)
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(np_results[0]),
Expand Down Expand Up @@ -637,7 +637,7 @@ def exclusive_jets_constituents(self, njets):
np_results = self._results[i].to_numpy_exclusive_njet_with_constituents(
njets
)
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(np_results[0]),
Expand All @@ -661,7 +661,7 @@ def constituent_index(self, min_pt):
self._input_flag = 0
for i in range(len(self._clusterable_level)):
np_results = self._results[i].to_numpy_with_constituents(min_pt)
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(np_results[0]),
Expand All @@ -687,7 +687,7 @@ def exclusive_jets_constituent_index(self, njets):
np_results = self._results[i].to_numpy_exclusive_njet_with_constituents(
njets
)
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(np_results[0]),
Expand Down Expand Up @@ -873,7 +873,7 @@ def unique_history_order(self):
self._input_flag = 0
for i in range(len(self._clusterable_level)):
np_results = self._results[i].to_numpy_unique_history_order()
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
self._out.append(
ak.Array(
ak.layout.ListOffsetArray64(
Expand Down
6 changes: 3 additions & 3 deletions src/fastjet/_multievent.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def exclusive_jets_ycut(self, ycut):

def constituent_index(self, min_pt):
np_results = self._results.to_numpy_with_constituents(min_pt)
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(np_results[0]), ak.layout.NumpyArray(np_results[1])
Expand All @@ -189,7 +189,7 @@ def exclusive_jets_constituent_index(self, njets):
raise ValueError("Njets cannot be <= 0")

np_results = self._results.to_numpy_exclusive_njet_with_constituents(njets)
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(np_results[0]), ak.layout.NumpyArray(np_results[1])
Expand All @@ -200,7 +200,7 @@ def exclusive_jets_constituent_index(self, njets):

def unique_history_order(self):
np_results = self._results.to_numpy_unique_history_order()
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(off), ak.layout.NumpyArray(np_results[0])
Expand Down
8 changes: 4 additions & 4 deletions src/fastjet/_singleevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def exclusive_jets_ycut(self, ycut):

def constituent_index(self, min_pt):
np_results = self._results.to_numpy_with_constituents(min_pt)
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(np_results[0]), ak.layout.NumpyArray(np_results[1])
Expand All @@ -177,7 +177,7 @@ def exclusive_jets_constituent_index(self, njets):
raise ValueError("Njets cannot be <= 0")

np_results = self._results.to_numpy_exclusive_njet_with_constituents(njets)
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(np_results[0]), ak.layout.NumpyArray(np_results[1])
Expand All @@ -193,7 +193,7 @@ def unique_history_order(self):

def constituents(self, min_pt):
np_results = self._results.to_numpy_with_constituents(min_pt)
off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(np_results[0]), ak.layout.NumpyArray(np_results[1])
Expand All @@ -214,7 +214,7 @@ def exclusive_jets_constituents(self, njets):

np_results = self._results.to_numpy_exclusive_njet_with_constituents(njets)

off = np.insert(np_results[-1], 0, 0)
off = np_results[-1]
out = ak.Array(
ak.layout.ListOffsetArray64(
ak.layout.Index64(np_results[0]), ak.layout.NumpyArray(np_results[1])
Expand Down
2 changes: 1 addition & 1 deletion src/fastjet/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import re

__version__ = "3.4.0.0rc2"
__version__ = "3.4.0.0"
version = __version__
version_info = tuple(re.split(r"[-\.]", __version__))

Expand Down