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

ELVIRA MIR 2D support #1523

Open
wants to merge 104 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
8613f79
Initial ElviraAlgorithm class.
BradWhitlock Dec 13, 2024
8c6a568
Expose Hex-Hex clip function.
BradWhitlock Jan 11, 2025
b61ed91
Allow setting the node we want to use in SelectedZones.
BradWhitlock Jan 11, 2025
8019cd6
Remove some obsolete code.
BradWhitlock Jan 11, 2025
33329cd
Initial TopologyMapper.
BradWhitlock Jan 11, 2025
45918ee
Moved file
BradWhitlock Jan 11, 2025
6bdad55
Build fixes
BradWhitlock Jan 11, 2025
9c7aeb1
Merged from mir_update
BradWhitlock Jan 11, 2025
71269b5
Adding new test. make style.
BradWhitlock Jan 13, 2025
5c8ae4f
Update data dir.
BradWhitlock Jan 14, 2025
6573362
CUDA porting
BradWhitlock Jan 14, 2025
6a43014
Added sorting routines for multiple arrays.
BradWhitlock Jan 17, 2025
3d168c7
Corrections
BradWhitlock Jan 17, 2025
ed88951
Added another method for splitting selected zones based on materials.
BradWhitlock Jan 17, 2025
21eedd8
Reworked Sorting because previous approach did not compile under nvcc.
BradWhitlock Jan 17, 2025
f54406a
Adding to algorithm
BradWhitlock Jan 28, 2025
58d0e0f
MakeZoneCenters
BradWhitlock Jan 28, 2025
1bf434d
Merge branch 'feature/whitlock/mir_update' into feature/whitlock/mir_…
BradWhitlock Jan 28, 2025
76f94ed
Merge branch 'develop' into feature/whitlock/mir_elvira
BradWhitlock Feb 11, 2025
0cc3adc
Improve MakeZoneCenters and add test.
BradWhitlock Feb 19, 2025
a70e699
make style
BradWhitlock Feb 19, 2025
4f80379
Some progress
BradWhitlock Feb 25, 2025
537a76d
specialized code that invokes elvira by dimension.
BradWhitlock Feb 25, 2025
cc424e3
Fix bug in ZoneListBuilder.
BradWhitlock Feb 25, 2025
a4800ab
Moved some ELVIRA functions to cpp file. Save more data for debugging…
BradWhitlock Feb 26, 2025
52d96b4
Moved some helper classes into their own files.
BradWhitlock Feb 27, 2025
49a7161
Compute zone centers
BradWhitlock Feb 28, 2025
eab541c
sort_multiple functions.
BradWhitlock Feb 28, 2025
4292824
Clip polygon/plane
BradWhitlock Feb 28, 2025
addb229
Added reverse_sort_multiple
BradWhitlock Mar 1, 2025
3607a2a
Test reverse_sort_multiple
BradWhitlock Mar 1, 2025
9ad521d
Added more Polygon template arguments for compute_bounding_box so it …
BradWhitlock Mar 1, 2025
a131ca5
Added initial clip polygon vs plane.
BradWhitlock Mar 1, 2025
4f15b7c
Initial code to find plane origin in fragments.
BradWhitlock Mar 1, 2025
799f7ac
Improve VTK support
BradWhitlock Mar 4, 2025
ef30db1
Improve polygon/plane clipping.
BradWhitlock Mar 4, 2025
0f8bfc5
Move fill function
BradWhitlock Mar 4, 2025
5958222
Started making output mesh.
BradWhitlock Mar 4, 2025
4bdef97
ELVIRA improvements
BradWhitlock Mar 5, 2025
fff8df6
Added clamp method to structured indexing classes. I used the method …
BradWhitlock Mar 5, 2025
4b1ddcb
make style
BradWhitlock Mar 5, 2025
c5b9dec
Making ELVIRA output the clean zones too.
BradWhitlock Mar 6, 2025
4fef2b5
Moved some I/O to MIRAlgorithm. Enhanced MergeMeshes so it can handle…
BradWhitlock Mar 6, 2025
93402b3
make style
BradWhitlock Mar 6, 2025
6e5e24e
Added some ELVIRA doc.
BradWhitlock Mar 6, 2025
bd7c263
doc fixes
BradWhitlock Mar 6, 2025
d5d1916
Moved some elvira code to a header for HIP to work.
BradWhitlock Mar 7, 2025
668b460
Removed obsolete cpp file.
BradWhitlock Mar 7, 2025
4a52bb9
make style
BradWhitlock Mar 7, 2025
5accc89
Fixed some problems that prevented Polygon with static array to work …
BradWhitlock Mar 8, 2025
b70958f
Always add the constructors.
BradWhitlock Mar 8, 2025
2c0d531
Added make_unibuffer_matset. Changed some as_int to to_int.
BradWhitlock Mar 10, 2025
d888ad8
Starting a test program that does elvira then mapping.
BradWhitlock Mar 10, 2025
7b8a885
Make MIR honor the naming options
BradWhitlock Mar 10, 2025
b6c2406
View improvements. Hook up topology mapper in mir_coupling test.
BradWhitlock Mar 11, 2025
3307b96
Improvements to TopologyMapper.
BradWhitlock Mar 11, 2025
5b62069
Do not print node. It still might contain device memory.
BradWhitlock Mar 11, 2025
d66de27
Make sure to use the right Conduit node.
BradWhitlock Mar 11, 2025
3d389ea
Added some more docs about the importance of where to store data in m…
BradWhitlock Mar 11, 2025
d94d423
Fixed memory issues in GPU versions.
BradWhitlock Mar 11, 2025
35fba73
make style
BradWhitlock Mar 11, 2025
0948b5a
Add Elvira support to mir_concentric_circles.
BradWhitlock Mar 12, 2025
9a8ade2
Add some casting because isNearlyEqual does not accept mixed argument…
BradWhitlock Mar 12, 2025
e6020c1
Elvira fixes
BradWhitlock Mar 12, 2025
c26ab45
polygon/plane clip fix.
BradWhitlock Mar 12, 2025
fca14ae
make style
BradWhitlock Mar 12, 2025
7e0d4fe
Improve search
BradWhitlock Mar 13, 2025
1a65c53
Moved code to a detail header file.
BradWhitlock Mar 13, 2025
2d4a510
Added elvira test for selectedZones. Fixed bug in ElviraAlgorithm rel…
BradWhitlock Mar 14, 2025
405728f
Added selectedZones support in mir_coupling test. Fixed bugs. Improve…
BradWhitlock Mar 14, 2025
e2e6e82
Lower clip tolerance
BradWhitlock Mar 14, 2025
5fcfec7
SLIC_ASSERT
BradWhitlock Mar 14, 2025
7f46a7c
Enhancements for strided-structured mesh support in ElviraAlgorithm. …
BradWhitlock Mar 15, 2025
9399b7a
Turned off some debugging prints
BradWhitlock Mar 15, 2025
2fcb9f2
Fixed some errors in TopologyMapper.
BradWhitlock Mar 17, 2025
cb36366
Added more doc
BradWhitlock Mar 17, 2025
1ea7f0a
Small testing fixes
BradWhitlock Mar 17, 2025
1cc272a
Release notes
BradWhitlock Mar 17, 2025
1a4f67b
make style
BradWhitlock Mar 17, 2025
562750f
Updated data directory version.
BradWhitlock Mar 17, 2025
2c87ddd
Removed an obsolete macro
BradWhitlock Mar 17, 2025
12630b2
Fixed mir_concentric_circles.py script so it measures the right quant…
BradWhitlock Mar 18, 2025
a70d6c5
Small fixes for mir_elvira2d.dpp and update data dir.
BradWhitlock Mar 18, 2025
27e2bf3
Moved CLI app declaration in a test. Made some other test main functi…
BradWhitlock Mar 18, 2025
fc404ed
Fix copy/paste mistake
BradWhitlock Mar 18, 2025
a6aec51
Fix exception catch order.
BradWhitlock Mar 18, 2025
3bcc6ff
Merge branch 'develop' into feature/whitlock/mir_elvira
BradWhitlock Mar 18, 2025
fc79100
parallel mir_concentric_circles
BradWhitlock Mar 18, 2025
b6b30bf
make style
BradWhitlock Mar 18, 2025
ea09a86
Enhance mir_concentric_circles.py so we can run parallel timings.
BradWhitlock Mar 19, 2025
d293c5a
Merge branch 'feature/whitlock/mir_elvira' of github.com:LLNL/axom in…
BradWhitlock Mar 19, 2025
e3306b3
Resolved conflict. Moved/improved a sorting test.
BradWhitlock Mar 24, 2025
96fbe99
Sort fixes for when IndexType is long.
BradWhitlock Mar 24, 2025
efb3d1d
make style
BradWhitlock Mar 24, 2025
01da30d
Changed comments.
BradWhitlock Mar 28, 2025
7371475
Minor sorting changes.
BradWhitlock Mar 28, 2025
247d0df
Moved improved version of MeshTester function to this branch.
BradWhitlock Mar 28, 2025
e0cb466
Fix typo
BradWhitlock Mar 28, 2025
35f6a30
Make pjoin take multiple arguments.
BradWhitlock Mar 28, 2025
82b79b4
Fixed a few portability issues. Changed clipHexahedron so it will bet…
BradWhitlock Mar 28, 2025
a341596
make style
BradWhitlock Mar 28, 2025
5ed40af
Tweaks to documentation and a comment.
BradWhitlock Mar 28, 2025
09937b7
Updated data directory version.
BradWhitlock Mar 28, 2025
fd8f9e8
Merge branch 'develop' into feature/whitlock/mir_elvira
BradWhitlock Mar 31, 2025
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
4 changes: 3 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -24,7 +24,9 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
MIR algorithms take Blueprint meshes with a matset and they use the matset's material information
to split any input zones that contain multiple materials into zones that contain a single material.
The Mir component provides an implementation of the Equi-Z MIR algorithm, which is a visualization-
oriented algorithm that produces smooth interfaces between zones and their neighbors.
oriented algorithm that produces smooth interfaces between zones and their neighbors. The Mir
component also provides a 2D ELVIRA algorithm, which reconstructs polygonal shapes and preserves
volume fractions.
- Support in `quest::IntersectionShaper` for Blueprint mesh stored in a `conduit::Node`
or `sidre::Group`.
- Adds new CMake configuration options, `AXOM_ENABLE_ASAN` and `AXOM_ENABLE_UBSAN`, to enable/disable AddressSanitizer and UndefinedBehaviorSanitizer respectively in Axom. Default is OFF for both.
270 changes: 241 additions & 29 deletions scripts/benchmarks/mir_concentric_circles.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,73 @@
import os, sys
import argparse

def flux_run(np):
return f"flux run -n {np}"

def srun(np):
return f"srun -n {np}"

def lrun(np):
return f"lrun -n {np}"

# Parallel options use 4 ranks per node since that is how many GPUs there are.
runs = {
"[email protected]_cuda-release" : ["seq", "omp", "cuda"],
"[email protected]" : ["seq", "omp"],
"[email protected]" : ["seq", "omp"],
"[email protected]" : ["seq", "omp"],
"[email protected]_hip-release" : ["seq", "hip"],
"[email protected]_hip-release" :["seq", "hip"]
"[email protected]_cuda-release" : {"policies":["seq", "omp", "cuda"], "launch":lrun},
"[email protected]" : {"policies":["seq", "omp"], "launch":srun},
"[email protected]" : {"policies":["seq", "omp"], "launch":srun},
"[email protected]" : {"policies":["seq", "omp"], "launch":srun},
"[email protected]_hip-release" : {"policies":["seq", "hip"], "launch":srun},
"[email protected]_hip-release" : {"policies":["seq", "hip"], "launch":srun},
"[email protected]_hip-release" :{"policies":["seq", "hip"], "launch":flux_run},
"[email protected]_hip-release" :{"policies":["seq", "hip"], "launch":flux_run}
}

sizes = (50, 100, 200, 500, 1000, 1500, 2000, 4000, 8000)

def generate():
def generate(params):
"""
Generate scripts to run the program to create timings.
"""
method = params["method"]

for r in runs:
if not os.path.exists(r):
print(f"Skipping {r}.")
continue
filename = os.path.join(r, "run_concentric_circles.bash")
f = open(filename, "wt")
f.write("#!/bin/bash\n\n")
f.write("CONCENTRIC_CIRCLES=./examples/mir_concentric_circles\n\n")
f.write("CONCENTRIC_CIRCLES=./examples/mir_concentric_circles\n")
f.write("CONCENTRIC_CIRCLES_MPI=./examples/mir_concentric_circles_mpi\n\n")

for s in sizes:
f.write(f"# Size {s}\n")
for policy in runs[r]:
f.write(f'echo "Running --gridsize {s} --numcircles 5 --policy {policy}"\n')
f.write(f'$CONCENTRIC_CIRCLES --gridsize {s} --numcircles 5 --policy {policy} > result_{policy}_{s}.txt\n\n')
if len(params["parallel"]) > 0:
# parallel
for np in params["parallel"]:
launch = runs[r]["launch"](np)
for policy in runs[r]["policies"]:
f.write(f'echo "Running {launch} $CONCENTRIC_CIRCLES_MPI --gridsize {s} --numcircles 5 --policy {policy} --method {method} --disable-write"\n')
f.write(f'{launch} $CONCENTRIC_CIRCLES_MPI --gridsize {s} --numcircles 5 --policy {policy} --method {method} --disable-write > result_{policy}_np{np}_s{s}.txt\n\n')
else:
# serial
for policy in runs[r]["policies"]:
f.write(f'echo "Running --gridsize {s} --numcircles 5 --policy {policy} --method {method} --disable-write"\n')
f.write(f'$CONCENTRIC_CIRCLES --gridsize {s} --numcircles 5 --policy {policy} --method {method} --disable-write > result_{policy}_s{s}.txt\n\n')

f.close()
os.chmod(filename, 0o700)
print(f"Wrote {filename}")

def read_timings(filename):
def read_timings(filename, searchKey):
"""
Read a single Caliper log and pull out the timings we want.
"""
retval = "" # no data
try:
lines = open(filename, "rt").readlines()
for line in lines:
pos = line.find("runMIR")
pos = line.find(searchKey)
if pos != -1:
toks = [x for x in line.split() if x != '']
retval = float(toks[2]) # timings (I)
@@ -42,25 +76,75 @@ def read_timings(filename):
pass
return retval

def make_csv(outputfile):
def make_columns(params):
"""
Read the available timing files and make columns of data.
"""
# I was measuring runMIR before, which includes device transfers and HDF5 output.
# I don't want that stuff in the timings because it is not relevant to timing MIR
# and it can vary wildly.

def is_selected(selections, name):
"""
Checks whether a name is being selected.
"""
selected = True
if len(selections) > 0:
selected = False
for s in selections:
if name.find(s) != -1:
selected = True
break
return selected

# Measure just the MIR algorithm
searchKey = "EquiZAlgorithm"
if params["method"] == "elvira":
searchKey = "ElviraAlgorithm"

columns = []
# Add sizes column
sc = ["Sizes"]
# Add NumZones column (nzones = s*s)
sc = ["NumZones"]
for s in sizes:
sc.append(s)
sc.append(s*s)
columns.append(sc)

# Gather data.
for r in sorted(runs.keys()):
for policy in runs[r]:
# Make sure r exists
if not os.path.exists(r):
continue

# Gather individual data files
for policy in runs[r]["policies"]:
buildname = r[6:-8]
name = f"{buildname} {policy.upper()}"
data = [name]
for s in sizes:
filename = os.path.join(r, f"result_{policy}_{s}.txt")
value = read_timings(filename)
data.append(value)
columns.append(data)
if len(params["parallel"]) > 0:
for np in params["parallel"]:
name = f"{buildname} {policy.upper()} NP={np}"
# Check if this name is selected
if not is_selected(params["selections"], name):
continue
data = [name]
for s in sizes:
filename = os.path.join(r, f"result_{policy}_np{np}_s{s}.txt")
value = read_timings(filename, searchKey)
data.append(value)
columns.append(data)
else:
name = f"{buildname} {policy.upper()}"
data = [name]
for s in sizes:
filename = os.path.join(r, f"result_{policy}_s{s}.txt")
value = read_timings(filename, searchKey)
data.append(value)
columns.append(data)
return columns

def make_csv(params, outputfile):
"""
Read the available timing files and assemble a CSV file.
"""
columns = make_columns(params)

# Write data
f = open(outputfile, "wt")
@@ -71,10 +155,138 @@ def make_csv(outputfile):
f.write(f"{line}\n")
f.close()

def plot(params):
"""
Read the available timing files and plot them.
"""
def make_series(col1, col2):
n = len(col1)
x = []
y = []
for i in range(n):
try:
xv = float(col1[i])
yv = float(col2[i])
x.append(xv)
y.append(yv)
except ValueError:
# We probably did not get data. Stop processing.
break
return x,y

columns = make_columns(params)

import matplotlib.pyplot as plt
for c in range(1, len(columns)):
x, y = make_series(columns[0][1:], columns[c][1:])
if len(x) > 0:
plt.plot(x, y, marker='o', linestyle='-', label=columns[c][0])

# Add labels and title
plt.xlabel('Number of Zones', fontSize=18)
plt.ylabel('Time (s)', fontSize=18)
plt.title('MIR Timings', fontSize=24)
xlabels = make_series(columns[0][1:], columns[0][1:])[0]
plt.xticks(ticks=xlabels, labels=xlabels, fontsize=14)
plt.yticks(fontsize=14)

# Set x-axis to logarithmic scale
plt.xscale('log')

# Set y-axis to logarithmic scale
plt.yscale('log')

# Add a legend
plt.legend()

plt.tight_layout()

# Show the plot
plt.grid(True)
plt.show()

def get_params():
"""
Get arguments from the command line and return a dictionary.
"""
parser = argparse.ArgumentParser(description="Parse args")
parser.add_argument(
"--parallel",
type=str,
help="Comma-separated list of integer values",
required=False
)

parser.add_argument(
"--generate",
action="store_true",
help="Boolean flag to indicate whether to generate scripts",
required=False
)

parser.add_argument(
"--plot",
action="store_true",
help="Boolean flag to indicate whether to plot",
required=False
)

parser.add_argument(
"--method",
type=str,
help="MIR method to use (e.g., 'equiz', 'elvira')",
required=False
)

parser.add_argument(
"--select",
type=str,
help="Comma-separated list of strings to select specific plot data",
required=False
)

args = parser.parse_args()

# Convert the comma-separated string into a tuple of integers
parallel = ()
if args.parallel is not None:
try:
parallel = tuple(int(value) for value in args.parallel.split(","))
except ValueError:
raise argparse.ArgumentTypeError("All values in --parallel must be integers.")

selections = ()
if args.select is not None:
selections = tuple(args.select.split(","))

params = {}
params["parallel"] = parallel
if args.method is not None:
params["method"] = args.method
else:
params["method"] = "elvira"
if args.generate is not None:
params["generate"] = args.generate
else:
params["generate"] = False
if args.plot is not None:
params["plot"] = args.plot
params["generate"] = False
else:
params["plot"] = False
params["selections"] = selections

return params

def main():
if "--generate" in sys.argv:
generate()
params = get_params()

if params["generate"]:
generate(params)
elif params["plot"]:
plot(params)
else:
make_csv("concentric_circle_timings.csv")
make_csv(params, "concentric_circle_timings.csv")

main()
if __name__ == "__main__":
main()
Loading