Skip to content

Commit

Permalink
Simplified --no-rmm-reinit to use existing markers instead of modifyi…
Browse files Browse the repository at this point in the history
…ng fixture params directly (this also means all runs always have the same number of params, which helps reporting), updated ini file to only show common columns in report by default, remove -x from default options to work better with nightly runs.
  • Loading branch information
rlratzel committed Jun 12, 2020
1 parent 103ea02 commit 158c8f5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 46 deletions.
36 changes: 23 additions & 13 deletions benchmarks/bench_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,26 @@ def createGraph(csvFileName, graphType=None):
renumber=True)


# Record the current RMM settings so reinitialize() will be called only when a
# change is needed (RMM defaults both values to False). This allows the
# --no-rmm-reinit option to prevent reinitialize() from being called at all
# (see conftest.py for details).
RMM_SETTINGS = {"managed_mem": False,
"pool_alloc": False}


def reinitRMM(managed_mem, pool_alloc):
rmm.reinitialize(
managed_memory=managed_mem,
pool_allocator=pool_alloc,
initial_pool_size=2 << 27
)

if (managed_mem != RMM_SETTINGS["managed_mem"]) or \
(pool_alloc != RMM_SETTINGS["pool_alloc"]):

rmm.reinitialize(
managed_memory=managed_mem,
pool_allocator=pool_alloc,
initial_pool_size=2 << 27
)
RMM_SETTINGS.update(managed_mem=managed_mem,
pool_alloc=pool_alloc)


###############################################################################
Expand All @@ -78,8 +92,7 @@ def edgelistCreated(request):
setFixtureParamNames(request, ["dataset", "managed_mem", "pool_allocator"])

csvFileName = request.param[0]
if len(request.param) > 1:
reinitRMM(request.param[1], request.param[2])
reinitRMM(request.param[1], request.param[2])
return utils.read_csv_file(csvFileName)


Expand All @@ -92,8 +105,7 @@ def graphWithAdjListComputed(request):
"""
setFixtureParamNames(request, ["dataset", "managed_mem", "pool_allocator"])
csvFileName = request.param[0]
if len(request.param) > 1:
reinitRMM(request.param[1], request.param[2])
reinitRMM(request.param[1], request.param[2])

G = createGraph(csvFileName, cugraph.structure.graph.Graph)
G.view_adj_list()
Expand All @@ -109,8 +121,7 @@ def anyGraphWithAdjListComputed(request):
"""
setFixtureParamNames(request, ["dataset", "managed_mem", "pool_allocator"])
csvFileName = request.param[0]
if len(request.param) > 1:
reinitRMM(request.param[1], request.param[2])
reinitRMM(request.param[1], request.param[2])

G = createGraph(csvFileName)
G.view_adj_list()
Expand All @@ -126,8 +137,7 @@ def anyGraphWithTransposedAdjListComputed(request):
"""
setFixtureParamNames(request, ["dataset", "managed_mem", "pool_allocator"])
csvFileName = request.param[0]
if len(request.param) > 1:
reinitRMM(request.param[1], request.param[2])
reinitRMM(request.param[1], request.param[2])

G = createGraph(csvFileName)
G.view_transposed_adj_list()
Expand Down
30 changes: 12 additions & 18 deletions benchmarks/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# pytest customizations specific to these benchmarks
import sys
from os import path
import importlib


def pytest_addoption(parser):
parser.addoption("--no-rmm-reinit", action="store_true", default=False,
Expand All @@ -11,21 +7,19 @@ def pytest_addoption(parser):


def pytest_sessionstart(session):
# if the --no-rmm-reinit option is given, import the benchmark's "params"
# module and change the FIXTURE_PARAMS accordingly.
# if the --no-rmm-reinit option is given, set (or add to) the CLI "mark
# expression" (-m) the markers for no managedmem and no poolallocator. This
# will cause the RMM reinit() function to not be called.
if session.config.getoption("no_rmm_reinit"):
paramsPyFile = path.join(path.dirname(path.abspath(__file__)),
"params.py")
newMarkexpr = "managedmem_off and poolallocator_off"
currentMarkexpr = session.config.getoption("markexpr")

# A simple "import" statement will not find the modules here (unless if
# this package is on the import path) since pytest evaluates this from
# a different location.
spec = importlib.util.spec_from_file_location("params", paramsPyFile)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
if ("managedmem" in currentMarkexpr) or \
("poolallocator" in currentMarkexpr):
raise RuntimeError("managedmem and poolallocator markers cannot "
"be used with --no-rmm-reinit")

module.FIXTURE_PARAMS = module.NO_RMMREINIT_FIXTURE_PARAMS
if currentMarkexpr:
newMarkexpr = f"({currentMarkexpr}) and ({newMarkexpr})"

# If "benchmarks.params" is registered in sys.modules, all future
# imports of the module will simply refer to this one.
sys.modules["benchmarks.params"] = module
session.config.option.markexpr = newMarkexpr
19 changes: 5 additions & 14 deletions benchmarks/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def genFixtureParamsProduct(*args):

# FIXME: write and use mechanism described here for specifying datasets:
# https://docs.rapids.ai/maintainers/datasets
# FIXME: rlr: soc-twitter-2010.csv crashes with OOM error on my HP-Z8!
# FIXME: rlr: soc-twitter-2010.csv crashes with OOM error on my RTX-8000
UNDIRECTED_DATASETS = [
pytest.param("../datasets/csv/undirected/hollywood.csv",
marks=[pytest.mark.small, pytest.mark.undirected]),
Expand Down Expand Up @@ -88,16 +88,7 @@ def genFixtureParamsProduct(*args):
marks=[pytest.mark.poolallocator_off]),
]

ALL_FIXTURE_PARAMS = genFixtureParamsProduct(
(DIRECTED_DATASETS + UNDIRECTED_DATASETS, "ds"),
(MANAGED_MEMORY, "mm"),
(POOL_ALLOCATOR, "pa"))

NO_RMMREINIT_FIXTURE_PARAMS = genFixtureParamsProduct(
(DIRECTED_DATASETS +
UNDIRECTED_DATASETS, "ds"))

# conftest.py will switch this to NO_RMMREINIT_FIXTURE_PARAMS
# if the --no-rmm-reinit option is passed.
# See conftest.py for details
FIXTURE_PARAMS = ALL_FIXTURE_PARAMS
FIXTURE_PARAMS = genFixtureParamsProduct(
(DIRECTED_DATASETS + UNDIRECTED_DATASETS, "ds"),
(MANAGED_MEMORY, "mm"),
(POOL_ALLOCATOR, "pa"))
2 changes: 1 addition & 1 deletion benchmarks/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[pytest]
addopts =
-x
--benchmark-warmup=on
--benchmark-warmup-iterations=1
--benchmark-min-rounds=3
--benchmark-columns="min, max, mean, stddev, outliers, gpu_mem, rounds"

markers =
managedmem_on: RMM managed memory enabled
Expand Down

0 comments on commit 158c8f5

Please sign in to comment.