Skip to content

Commit 3da3f9c

Browse files
Prerak SinghPrerak Singh
authored andcommitted
bug fix
1 parent ee430b9 commit 3da3f9c

File tree

3 files changed

+31
-52
lines changed

3 files changed

+31
-52
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
# sphinx-build -b html docs/source/ docs/build/html
7777

7878
test-ubuntu-py39-py310:
79-
runs-on: ${{matrix.os}}
79+
runs-on: ${{ matrix.os }}
8080
timeout-minutes: 20
8181
strategy:
8282
fail-fast: false
@@ -102,30 +102,33 @@ jobs:
102102
run: |
103103
python -m pip install -r requirements.txt
104104
python -m pip install -r docs/requirements.txt
105+
python -m pip install meson ninja pytest
105106
106-
- name: Build package
107+
- name: Build package (Meson)
107108
env:
108109
CXXFLAGS: "-std=c++17"
109110
run: |
110-
spin build -v
111+
meson setup build
112+
meson compile -C build
113+
meson install -C build
111114
112115
- name: Run tests
113116
run: |
114-
spin test -v
117+
pytest --import-mode=importlib
115118
116119
- name: Build Documentation
117120
run: |
118121
sphinx-build -b html docs/source/ docs/build/html
119122
120123
test-macos:
121-
runs-on: ${{matrix.os}}
124+
runs-on: ${{ matrix.os }}
122125
timeout-minutes: 20
123126
strategy:
124127
fail-fast: false
125128
matrix:
126129
os: [macos-latest]
127130
python-version:
128-
# - "3.8"
131+
# - "3.8"
129132
- "3.9"
130133
- "3.10"
131134

@@ -145,16 +148,20 @@ jobs:
145148
run: |
146149
python -m pip install -r requirements.txt
147150
python -m pip install -r docs/requirements.txt
151+
python -m pip install meson ninja pytest
148152
149-
- name: Build package
153+
- name: Build package (Meson)
150154
env:
151155
MACOSX_DEPLOYMENT_TARGET: 11.0
152156
CXXFLAGS: "-std=c++17"
153157
run: |
154-
spin build -v
158+
meson setup build
159+
meson compile -C build
160+
meson install -C build
161+
155162
- name: Run tests
156163
run: |
157-
spin test -v
164+
pytest --import-mode=importlib
158165
159166
- name: Build Documentation
160167
run: |

pydatastructs/linear_data_structures/_backend/cpp/algorithms/llvm_algorithms.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
_fn_ptr_cache = {}
1414

1515
def _cleanup():
16-
"""Clean up LLVM resources on exit."""
1716
global _engines, _target_machine, _fn_ptr_cache
1817
_engines.clear()
1918
_target_machine = None
@@ -27,9 +26,8 @@ def _ensure_target_machine():
2726
return
2827

2928
try:
30-
binding.initialize()
31-
binding.initialize_native_target()
32-
binding.initialize_native_asmprinter()
29+
binding.initialize_all_targets()
30+
binding.initialize_all_asmprinters()
3331

3432
target = binding.Target.from_default_triple()
3533
_target_machine = target.create_target_machine(
@@ -40,7 +38,6 @@ def _ensure_target_machine():
4038
raise RuntimeError(f"Failed to initialize LLVM target machine: {e}")
4139

4240
def get_bubble_sort_ptr(dtype: str) -> int:
43-
"""Get function pointer for bubble sort with specified dtype."""
4441
dtype = dtype.lower().strip()
4542
if dtype not in _SUPPORTED:
4643
raise ValueError(f"Unsupported dtype '{dtype}'. Supported: {list(_SUPPORTED)}")
@@ -148,31 +145,15 @@ def _materialize(dtype: str) -> int:
148145
mod = binding.parse_assembly(llvm_ir)
149146
mod.verify()
150147

151-
pmb = binding.PassManagerBuilder()
152-
pmb.opt_level = 3
153-
pmb.loop_vectorize = True
154-
pmb.slp_vectorize = True
155-
156-
fpm = binding.create_function_pass_manager(mod)
157-
pm = binding.create_module_pass_manager()
158-
159-
pm.add_basic_alias_analysis_pass()
160-
pm.add_type_based_alias_analysis_pass()
161-
pm.add_instruction_combining_pass()
162-
pm.add_gvn_pass()
163-
pm.add_cfg_simplification_pass()
164-
pm.add_loop_unroll_pass()
165-
pm.add_loop_unswitch_pass()
166-
167-
pmb.populate(fpm)
168-
pmb.populate(pm)
169-
170-
fpm.initialize()
171-
for func in mod.functions:
172-
fpm.run(func)
173-
fpm.finalize()
174-
175-
pm.run(mod)
148+
try:
149+
pm = binding.ModulePassManager()
150+
pm.add_instruction_combining_pass()
151+
pm.add_reassociate_pass()
152+
pm.add_gvn_pass()
153+
pm.add_cfg_simplification_pass()
154+
pm.run(mod)
155+
except AttributeError:
156+
pass
176157

177158
engine = binding.create_mcjit_compiler(mod, _target_machine)
178159
engine.finalize_object()

pydatastructs/utils/__init__.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,17 @@
33
from . import (
44
misc_util,
55
testing_util,
6+
_extensions
67
)
78

8-
from ._backend.cpp import _graph_utils
9-
10-
AdjacencyListGraphNode = _graph_utils.AdjacencyListGraphNode
11-
AdjacencyMatrixGraphNode = _graph_utils.AdjacencyMatrixGraphNode
12-
GraphNode = _graph_utils.GraphNode
13-
GraphEdge = _graph_utils.GraphEdge
14-
159
from .misc_util import (
1610
TreeNode,
1711
MAryTreeNode,
1812
LinkedListNode,
1913
BinomialTreeNode,
14+
AdjacencyListGraphNode,
15+
AdjacencyMatrixGraphNode,
16+
GraphEdge,
2017
Set,
2118
CartesianTreeNode,
2219
RedBlackTreeNode,
@@ -29,11 +26,5 @@
2926
)
3027
from .testing_util import test
3128

32-
__all__.extend([
33-
'AdjacencyListGraphNode',
34-
'AdjacencyMatrixGraphNode',
35-
'GraphNode',
36-
'GraphEdge',
37-
])
3829
__all__.extend(misc_util.__all__)
3930
__all__.extend(testing_util.__all__)

0 commit comments

Comments
 (0)