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

BLD: Split EWAH bool array code #2711

Merged
merged 2 commits into from
May 15, 2023
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ yt/utilities/lib/cyoctree.c
yt/utilities/lib/depth_first_octree.c
yt/utilities/lib/distance_queue.c
yt/utilities/lib/element_mappings.c
yt/utilities/lib/ewah_bool_wrap.cpp
yt/utilities/lib/fnv_hash.c
yt/utilities/lib/fortran_reader.c
yt/utilities/lib/freetype_writer.c
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ requires = [
# https://github.com/yt-project/yt/issues/4355
"Cython>=0.29.33,<3.0",
"oldest-supported-numpy",
"ewah-bool-utils>=1.0.2",
]

[project]
Expand Down Expand Up @@ -45,6 +46,7 @@ keywords = [
requires-python = ">=3.8"
dependencies = [
"cmyt>=1.1.2",
"ewah-bool-utils>=1.0.2",
"ipywidgets>=8.0.0",
"matplotlib!=3.4.2,>=3.2", # keep in sync with tests/windows_conda_requirements.txt
"more-itertools>=8.4",
Expand Down Expand Up @@ -204,6 +206,7 @@ mapserver = [
]
minimal = [
"cmyt==1.1.2",
"ewah-bool-utils==1.0.2",
"ipywidgets==8.0.0",
"matplotlib==3.2",
"more-itertools==8.4",
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
check_for_openmp,
check_for_pyembree,
create_build_ext,
get_ewah_bool_utils_path,
install_ccompiler,
)

Expand Down Expand Up @@ -41,14 +42,14 @@

cythonize_aliases = {
"LIB_DIR": "yt/utilities/lib/",
"LIB_DIR_EWAH": ["yt/utilities/lib/", "yt/utilities/lib/ewahboolarray/"],
"LIB_DIR_GEOM": ["yt/utilities/lib/", "yt/geometry/"],
"LIB_DIR_GEOM_ARTIO": [
"yt/utilities/lib/",
"yt/geometry/",
"yt/frontends/artio/artio_headers/",
],
"STD_LIBS": std_libs,
"EWAH_LIBS": std_libs + [get_ewah_bool_utils_path()],
"OMP_ARGS": omp_args,
"FIXED_INTERP": "yt/utilities/lib/fixed_interpolator.cpp",
"ARTIO_SOURCE": glob.glob("yt/frontends/artio/artio_headers/*.c"),
Expand Down
8 changes: 8 additions & 0 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from distutils.sysconfig import customize_compiler
from subprocess import PIPE, Popen
from sys import platform as _platform
import ewah_bool_utils
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools.command.sdist import sdist as _sdist
from setuptools.errors import CompileError, LinkError
Expand Down Expand Up @@ -203,6 +204,12 @@ def check_CPP14_flags(possible_compile_flags):
)
return []

def get_ewah_bool_utils_path():
if sys.version_info >= (3, 9):
return os.path.abspath(importlib_resources.files("ewah_bool_utils"))
else:
from pkg_resources import resource_filename
return os.path.dirname(os.path.abspath(resource_filename("ewah_bool_utils", "ewah_bool_wrap.pxd")))

def check_for_pyembree(std_libs):
embree_libs = []
Expand Down Expand Up @@ -400,6 +407,7 @@ def finalize_options(self):
import numpy

self.include_dirs.append(numpy.get_include())
self.include_dirs.append(ewah_bool_utils.get_include())

def build_extensions(self):
self.check_extensions_list(self.extensions)
Expand Down
2 changes: 1 addition & 1 deletion yt/geometry/particle_geometry_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import weakref

import numpy as np
from ewah_bool_utils.ewah_bool_wrap import BoolArrayCollection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems worth noting that this is the one and only import that makes ewah_bool_array a runtime dependency. If we could somehow avoid it, it would only be a dependency at build time, which would be much more robust to potential ABI compat breakage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, is that true? I think that even though we're building the cython files, when we do the cimport it will be using dlopen and make it a runtime dependency as well.


from yt.data_objects.index_subobjects.particle_container import ParticleContainer
from yt.funcs import get_pbar, only_on_root
from yt.geometry.geometry_handler import Index, YTDataChunk
from yt.geometry.particle_oct_container import ParticleBitmap
from yt.utilities.lib.ewah_bool_wrap import BoolArrayCollection
from yt.utilities.lib.fnv_hash import fnv_hash
from yt.utilities.logger import ytLogger as mylog
from yt.utilities.parallel_tools.parallel_analysis_interface import parallel_objects
Expand Down
27 changes: 14 additions & 13 deletions yt/geometry/particle_oct_container.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# distutils: include_dirs = LIB_DIR_EWAH
# distutils: language = c++
neutrinoceros marked this conversation as resolved.
Show resolved Hide resolved
# distutils: extra_compile_args = CPP14_FLAG
# distutils: libraries = STD_LIBS
# distutils: include_dirs = LIB_DIR
# distutils: libraries = EWAH_LIBS
"""
Oct container tuned for Particles

Expand All @@ -10,17 +10,16 @@ Oct container tuned for Particles
"""


from libc.math cimport ceil, log2
from libc.stdlib cimport free, malloc
from libcpp.map cimport map as cmap
from libcpp.vector cimport vector

from yt.utilities.lib.ewah_bool_array cimport (
from ewah_bool_utils.ewah_bool_array cimport (
bool_array,
ewah_bool_array,
ewah_bool_iterator,
ewah_word_type,
)
from libc.math cimport ceil, log2
from libc.stdlib cimport free, malloc
from libcpp.map cimport map as cmap
from libcpp.vector cimport vector

import numpy as np

Expand Down Expand Up @@ -55,19 +54,21 @@ from .selection_routines cimport AlwaysSelector, SelectorObject

from yt.funcs import get_pbar

from ..utilities.lib.ewah_bool_wrap cimport BoolArrayCollection
from ewah_bool_utils.ewah_bool_wrap cimport BoolArrayCollection

import os


_bitmask_version = np.uint64(5)

from ..utilities.lib.ewah_bool_wrap cimport (
from ewah_bool_utils.ewah_bool_wrap cimport (
BoolArrayCollectionUncompressed as BoolArrayColl,
FileBitmasks,
SparseUnorderedRefinedBitmaskSet as SparseUnorderedRefinedBitmask,
)


_bitmask_version = np.uint64(5)



ctypedef cmap[np.uint64_t, bool_array] CoarseRefinedSets

cdef class ParticleOctreeContainer(OctreeContainer):
Expand Down
103 changes: 0 additions & 103 deletions yt/utilities/lib/ewah_bool_array.pxd

This file was deleted.

Loading