Skip to content

Commit

Permalink
Windows (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasdavis authored Aug 30, 2022
1 parent 9e3f173 commit c90091c
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-latest]
os: [ubuntu-20.04, macos-11, windows-2019]

steps:
- uses: actions/checkout@v3
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
test_pygram11:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11-dev"]
runs-on: ${{matrix.platform}}
steps:
Expand All @@ -21,15 +21,20 @@ jobs:
with:
python-version: ${{matrix.python-version}}
- name: install libomp on macOS
if: startsWith(matrix.platform, 'macOS')
shell: bash
run: |
brew install libomp
if [ "$RUNNER_OS" == "macOS" ]; then
brew install libomp
fi
- name: install
shell: bash
run: |
python -m pip install pip wheel -U
python -m pip install build
python -m pip install pytest
python -m build
pip install dist/*.whl pytest
pip list
python -m pip install dist/*.whl
python -m pip list
- name: test
run: |
python -m pytest --ignore=extern
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ else()
pybind11_add_module(_backend MODULE src/_backend.cpp)
set_target_properties(_backend PROPERTIES CXX_STANDARD 14)
target_link_libraries(_backend PUBLIC OpenMP::OpenMP_CXX)
target_compile_options(_backend PRIVATE -Wall -Wextra -pedantic)
if (NOT WIN32)
target_compile_options(_backend PRIVATE -Wall -Wextra -pedantic)
endif()
target_include_directories(_backend PRIVATE extern/mp11/include)
install(TARGETS _backend DESTINATION .)
endif()
108 changes: 72 additions & 36 deletions src/_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,16 +1141,20 @@ py::array_t<py::ssize_t> f1d(py::array_t<Tx, py::array::c_style> x, py::ssize_t
pg11::faxis_t<double> ax{nbins, xmin, xmax};
auto nx = x.shape(0);
if (nx < pg11::config_threshold("thresholds.fix1d")) { // serial
if (flow)
if (flow) {
pg11::one::s_loop_incf(x.data(), nx, ax, values.mutable_data());
else
}
else {
pg11::one::s_loop_excf(x.data(), nx, ax, values.mutable_data());
}
}
else { // parallel
if (flow)
if (flow) {
pg11::one::p_loop_incf(x.data(), nx, ax, values.mutable_data());
else
}
else {
pg11::one::p_loop_excf(x.data(), nx, ax, values.mutable_data());
}
}
return values;
}
Expand All @@ -1163,20 +1167,24 @@ py::tuple f1dw(py::array_t<Tx, py::array::c_style> x, py::array_t<Tw, py::array:
auto nx = x.shape(0);
pg11::faxis_t<double> ax{nbins, xmin, xmax};
if (nx < pg11::config_threshold("thresholds.fix1d")) { // serial
if (flow)
if (flow) {
pg11::one::s_loop_incf(x.data(), w.data(), nx, ax, values.mutable_data(),
variances.mutable_data());
else
}
else {
pg11::one::s_loop_excf(x.data(), w.data(), nx, ax, values.mutable_data(),
variances.mutable_data());
}
}
else { // parallel
if (flow)
if (flow) {
pg11::one::p_loop_incf(x.data(), w.data(), nx, ax, values.mutable_data(),
variances.mutable_data());
else
}
else {
pg11::one::p_loop_excf(x.data(), w.data(), nx, ax, values.mutable_data(),
variances.mutable_data());
}
}
return py::make_tuple(values, variances);
}
Expand All @@ -1188,10 +1196,12 @@ py::tuple f1dmw(py::array_t<Tx> x, py::array_t<Tw> w, py::ssize_t nbins, double
auto variances = pg11::zeros<Tw>(nbins, w.shape(1));
pg11::faxis_t<double> ax{nbins, xmin, xmax};
if (x.shape(0) < pg11::config_threshold("thresholds.fix1dmw")) { // serial
if (flow)
if (flow) {
pg11::one::s_loop_incf(x, w, ax, values, variances);
else
}
else {
pg11::one::s_loop_excf(x, w, ax, values, variances);
}
}
else { // parallel
if (flow)
Expand All @@ -1210,16 +1220,20 @@ py::array_t<py::ssize_t> v1d(py::array_t<Tx, py::array::c_style> x,
auto values = pg11::zeros<py::ssize_t>(nedges - 1);
auto nx = x.shape(0);
if (nx < pg11::config_threshold("thresholds.var1d")) { // serial
if (flow)
if (flow) {
pg11::one::s_loop_incf(x.data(), nx, edges_v, values.mutable_data());
else
}
else {
pg11::one::s_loop_excf(x.data(), nx, edges_v, values.mutable_data());
}
}
else { // parallel
if (flow)
if (flow) {
pg11::one::p_loop_incf(x.data(), nx, edges_v, values.mutable_data());
else
}
else {
pg11::one::p_loop_excf(x.data(), nx, edges_v, values.mutable_data());
}
}
return values;
}
Expand All @@ -1234,20 +1248,24 @@ py::tuple v1dw(py::array_t<Tx, py::array::c_style> x, py::array_t<Tw, py::array:
auto variances = pg11::zeros<Tw>(nbins);
auto nx = x.shape(0);
if (nx < pg11::config_threshold("thresholds.var1d")) { // serial
if (flow)
if (flow) {
pg11::one::s_loop_incf(x.data(), w.data(), nx, edges_v, values.mutable_data(),
variances.mutable_data());
else
}
else {
pg11::one::s_loop_excf(x.data(), w.data(), nx, edges_v, values.mutable_data(),
variances.mutable_data());
}
}
else { // parallel
if (flow)
if (flow) {
pg11::one::p_loop_incf(x.data(), w.data(), nx, edges_v, values.mutable_data(),
variances.mutable_data());
else
}
else {
pg11::one::p_loop_excf(x.data(), w.data(), nx, edges_v, values.mutable_data(),
variances.mutable_data());
}
}
return py::make_tuple(values, variances);
}
Expand All @@ -1261,10 +1279,12 @@ py::tuple v1dmw(py::array_t<Tx> x, py::array_t<Tw> w, py::array_t<double> edges,
auto values = pg11::zeros<Tw>(nbins, w.shape(1));
auto variances = pg11::zeros<Tw>(nbins, w.shape(1));
if (x.shape(0) < pg11::config_threshold("thresholds.var1dmw")) { // serial
if (flow)
if (flow) {
pg11::one::s_loop_incf(x, w, edges_v, values, variances);
else
}
else {
pg11::one::s_loop_excf(x, w, edges_v, values, variances);
}
}
else { // parallel
if (flow)
Expand All @@ -1283,16 +1303,20 @@ py::array_t<py::ssize_t> f2d(py::array_t<Tx> x, py::array_t<Ty> y, py::ssize_t n
pg11::faxis_t<double> axx{nbinsx, xmin, xmax};
pg11::faxis_t<double> axy{nbinsy, ymin, ymax};
if (x.shape(0) < pg11::config_threshold("thresholds.fix2d")) { // serial
if (flow)
if (flow) {
pg11::two::s_loop_incf(x.data(), y.data(), x.shape(0), axx, axy, values);
else
}
else {
pg11::two::s_loop_excf(x.data(), y.data(), x.shape(0), axx, axy, values);
}
}
else {
if (flow)
if (flow) {
pg11::two::p_loop_incf(x.data(), y.data(), x.shape(0), axx, axy, values);
else
}
else {
pg11::two::p_loop_excf(x.data(), y.data(), x.shape(0), axx, axy, values);
}
}
return values;
}
Expand All @@ -1306,20 +1330,24 @@ py::tuple f2dw(py::array_t<Tx> x, py::array_t<Ty> y, py::array_t<Tw> w, py::ssiz
pg11::faxis_t<double> axx{nbinsx, xmin, xmax};
pg11::faxis_t<double> axy{nbinsy, ymin, ymax};
if (x.shape(0) < pg11::config_threshold("thresholds.fix2d")) { // serial
if (flow)
if (flow) {
pg11::two::s_loop_incf(x.data(), y.data(), w.data(), x.shape(0), axx, axy, values,
variances);
else
}
else {
pg11::two::s_loop_excf(x.data(), y.data(), w.data(), x.shape(0), axx, axy, values,
variances);
}
}
else {
if (flow)
if (flow) {
pg11::two::p_loop_incf(x.data(), y.data(), w.data(), x.shape(0), axx, axy, values,
variances);
else
}
else {
pg11::two::p_loop_excf(x.data(), y.data(), w.data(), x.shape(0), axx, axy, values,
variances);
}
}
return py::make_tuple(values, variances);
}
Expand All @@ -1336,16 +1364,20 @@ py::array_t<py::ssize_t> v2d(py::array_t<Tx> x, py::array_t<Ty> y,
std::vector<double> edgesx_v(xbins.data(), xbins.data() + nedgesx);
std::vector<double> edgesy_v(ybins.data(), ybins.data() + nedgesy);
if (x.shape(0) < pg11::config_threshold("thresholds.var2d")) {
if (flow)
if (flow) {
pg11::two::s_loop_incf(x.data(), y.data(), x.shape(0), edgesx_v, edgesy_v, values);
else
}
else {
pg11::two::s_loop_excf(x.data(), y.data(), x.shape(0), edgesx_v, edgesy_v, values);
}
}
else {
if (flow)
if (flow) {
pg11::two::p_loop_incf(x.data(), y.data(), x.shape(0), edgesx_v, edgesy_v, values);
else
}
else {
pg11::two::p_loop_excf(x.data(), y.data(), x.shape(0), edgesx_v, edgesy_v, values);
}
}
return values;
}
Expand All @@ -1362,20 +1394,24 @@ py::tuple v2dw(py::array_t<Tx> x, py::array_t<Ty> y, py::array_t<Tw> w,
std::vector<double> edgesx_v(xbins.data(), xbins.data() + nedgesx);
std::vector<double> edgesy_v(ybins.data(), ybins.data() + nedgesy);
if (x.shape(0) < pg11::config_threshold("thresholds.var2d")) {
if (flow)
if (flow) {
pg11::two::s_loop_incf(x.data(), y.data(), w.data(), x.shape(0), edgesx_v, edgesy_v,
values, variances);
else
}
else {
pg11::two::s_loop_excf(x.data(), y.data(), w.data(), x.shape(0), edgesx_v, edgesy_v,
values, variances);
}
}
else {
if (flow)
if (flow) {
pg11::two::p_loop_incf(x.data(), y.data(), w.data(), x.shape(0), edgesx_v, edgesy_v,
values, variances);
else
}
else {
pg11::two::p_loop_excf(x.data(), y.data(), w.data(), x.shape(0), edgesx_v, edgesy_v,
values, variances);
}
}
return py::make_tuple(values, variances);
}
Expand Down

0 comments on commit c90091c

Please sign in to comment.