MoonBit bindings to METIS
python3 scripts/prepare.pymoon check --target native
moon test --target native
python3 scripts/test.py --asan
moon fmt
moon info --target nativemoon test src/README.mbt.md --target native///|
test "partition a four-cycle graph" {
let graph = CsrGraph::new(4, [0, 2, 4, 6, 8], [1, 3, 0, 2, 1, 3, 0, 2])
let result = part_graph_kway(graph, 2)
inspect(result.part.length(), content="4")
for value in result.part {
guard value >= 0 && value < 2
}
}///|
test "compute a node ordering" {
let graph = CsrGraph::new(4, [0, 2, 4, 6, 8], [1, 3, 0, 2, 1, 3, 0, 2])
let result = node_nd(graph)
inspect(result.perm.length(), content="4")
inspect(result.iperm.length(), content="4")
}///|
test "convert and partition a mesh" {
let mesh = Mesh::new(2, 4, [0, 3, 6], [0, 1, 2, 1, 2, 3])
let dual = mesh_to_dual(mesh, ncommon=2)
inspect(dual.nvtxs(), content="2")
let nodal = mesh_to_nodal(mesh)
inspect(nodal.nvtxs(), content="4")
let nodal_partition = part_mesh_nodal(
mesh,
2,
node_weights=FixedArray::make(4, 1),
node_sizes=FixedArray::make(4, 1),
)
inspect(nodal_partition.epart.length(), content="2")
inspect(nodal_partition.npart.length(), content="4")
let dual_partition = part_mesh_dual(
mesh,
2,
ncommon=2,
element_weights=FixedArray::make(2, 1),
element_sizes=FixedArray::make(2, 1),
)
inspect(dual_partition.epart.length(), content="2")
inspect(dual_partition.npart.length(), content="4")
}python3 scripts/prepare.pymoon check --target native
moon test --target native
python3 scripts/test.py --asan
moon fmt
moon info --target nativemoon test src/README.mbt.md --target native///|
test "partition a four-cycle graph" {
let graph = CsrGraph::new(4, [0, 2, 4, 6, 8], [1, 3, 0, 2, 1, 3, 0, 2])
let result = part_graph_kway(graph, 2)
inspect(result.part.length(), content="4")
for value in result.part {
guard value >= 0 && value < 2
}
}///|
test "compute a node ordering" {
let graph = CsrGraph::new(4, [0, 2, 4, 6, 8], [1, 3, 0, 2, 1, 3, 0, 2])
let result = node_nd(graph)
inspect(result.perm.length(), content="4")
inspect(result.iperm.length(), content="4")
}///|
test "convert and partition a mesh" {
let mesh = Mesh::new(2, 4, [0, 3, 6], [0, 1, 2, 1, 2, 3])
let dual = mesh_to_dual(mesh, ncommon=2)
inspect(dual.nvtxs(), content="2")
let nodal = mesh_to_nodal(mesh)
inspect(nodal.nvtxs(), content="4")
let nodal_partition = part_mesh_nodal(
mesh,
2,
node_weights=FixedArray::make(4, 1),
node_sizes=FixedArray::make(4, 1),
)
inspect(nodal_partition.epart.length(), content="2")
inspect(nodal_partition.npart.length(), content="4")
let dual_partition = part_mesh_dual(
mesh,
2,
ncommon=2,
element_weights=FixedArray::make(2, 1),
element_sizes=FixedArray::make(2, 1),
)
inspect(dual_partition.epart.length(), content="2")
inspect(dual_partition.npart.length(), content="4")
}pub struct CsrGraph {
// private fields
}fn CsrGraph::new(nvtxs : Int, xadj : FixedArray[Int], adjncy : FixedArray[Int], ncon? : Int, vwgt? : FixedArray[Int], vsize? : FixedArray[Int], adjwgt? : FixedArray[Int]) -> CsrGraph raise MetisErrorpub(all) enum DebugFlag {
Info
Time
Coarsen
Refine
InitialPartition
MoveInfo
SeparatorInfo
ConnectivityInfo
ContiguityInfo
Memory
}pub(all) enum InitialPartitioningScheme {
Grow
Random
Edge
Node
MetisRecursiveBisection
}pub struct Mesh {
// private fields
}fn Mesh::new(ne : Int, nn : Int, eptr : FixedArray[Int], eind : FixedArray[Int]) -> Mesh raise MetisErrorpub(all) struct MeshPartitionResult {
objval : Int
epart : FixedArray[Int]
npart : FixedArray[Int]
}pub struct Options {
// private fields
}fn Options::set_initial_partitioning_scheme(self : Options, scheme : InitialPartitioningScheme) -> Optionspub(all) struct OrderingResult {
perm : FixedArray[Int]
iperm : FixedArray[Int]
}pub(all) struct ParallelOrderingResult {
perm : FixedArray[Int]
iperm : FixedArray[Int]
sizes : FixedArray[Int]
}pub(all) enum RefinementScheme {
Fm
Greedy
SeparatorTwoSided
SeparatorOneSided
}pub(all) struct VertexSeparatorResult {
sepsize : Int
part : FixedArray[Int]
}fn cache_friendly_reordering(graph : CsrGraph, part : FixedArray[Int]) -> FixedArray[Int] raise MetisErrorfn compute_vertex_separator(graph : CsrGraph, options? : Options) -> VertexSeparatorResult raise MetisErrorfn node_ndp(graph : CsrGraph, npes : Int, options? : Options) -> ParallelOrderingResult raise MetisErrorfn node_refine(graph : CsrGraph, vwgt : FixedArray[Int], where_part : FixedArray[Int], hmarker : FixedArray[Int], ubfactor : Float) -> FixedArray[Int] raise MetisErrorfn part_graph_kway(graph : CsrGraph, nparts : Int, options? : Options, target_partition_weights? : FixedArray[Float], imbalance? : FixedArray[Float]) -> PartitionResult raise MetisErrorfn part_graph_recursive(graph : CsrGraph, nparts : Int, options? : Options, target_partition_weights? : FixedArray[Float], imbalance? : FixedArray[Float]) -> PartitionResult raise MetisErrorfn part_mesh_dual(mesh : Mesh, nparts : Int, ncommon? : Int, options? : Options, target_partition_weights? : FixedArray[Float], element_weights? : FixedArray[Int], element_sizes? : FixedArray[Int]) -> MeshPartitionResult raise MetisErrorfn part_mesh_nodal(mesh : Mesh, nparts : Int, options? : Options, target_partition_weights? : FixedArray[Float], node_weights? : FixedArray[Int], node_sizes? : FixedArray[Int]) -> MeshPartitionResult raise MetisErrorMoonBit bindings to METIS